Sharing an object (between users) with Parse SDK - ios

I want to implement a share feature in my app via an ActivityViewController. The data I want to share is just a simple dictionary of strings similar to this example:
My stores : [
Abercrombie : [
Jeans : 32
Polo : small
]
American Eagle : [
jeans : 31
Polo : extra small
]
I would think the Parse SDK would have prepackaged way to do this (similar to the validation email Parse gives you for free) but looking around in the IOS guide I really can't find anything? Can anyone point me in the right direction?

Related

Detect contact and viewing information in text

I'm trying to detect contact information in a huge list of offers I get. The offers contain text without any given structure, some examples could be the following ones:
if you're interested, send an email to test#test.com
want to know more? call 000 000 000
come to the public viewing on 25nd of january
public viewing is on the coming wednesday
is this what you're searching for? We're looking forward to hearing from you
As you can see, there are multiple possibilities:
there is no date for a viewing, but there's a phone number
there is no date for a viewing, but there's an email
there is a date for a viewing
there is no detailed information
The tricky point is, there can also be e.g. other dates in text, therefore I can't just parse out dates.
What is the best way to solve something like that? I've already tried it with regex. I think I could get it work but there is an enormous amount of cases which makes it very hard.
I've also looked into things like NLP with libraries like https://spacy.io/ or prodi.gy, but I feel like I'm not on the right track.
The original texts are written in German.
In 2020, how do I go after this?
You can use a NLP powered Rule-based matcher. With spacy, You explored the right tool, just didn't go deep with it. And it's available in german.
Here are some examples:
Some patterns:
#call number
call_pattern = [{'LOWER':'call'},{"ORTH": "(", 'OP':"?"}, {"SHAPE": "ddd"}, {"ORTH": ")", 'OP':"?"}, {"SHAPE": "ddd"},
{"ORTH": "-", "OP": "?"}, {"SHAPE": "ddd"}]
#e-mail pattern
email_pattern = [{'LIKE_EMAIL': True}]
#pattern for public viewing
public_viewing_pattern = [{'LOWER': 'public'},
{'LOWER': 'viewing'},
{'POS': 'AUX', 'OP': '?'},
{'POS': 'ADP', 'OP': '?'},
{'label': 'DATE', 'OP':'+'}]
Then, you iterate over your patterns and apply them:
import spacy
from spacy.matcher import Matcher
nlp = spacy.load('en')
#or:
#import de_core_news_sm
#nlp = de_core_news_sm.load()
matcher = Matcher(nlp.vocab)
matcher.add("call_pattern", None, call_pattern)
matcher.add("email_pattern", None, email_pattern)
matcher.add("public_viewing_pattern", None, public_viewing_pattern)
found = {'numbers':[], 'emails':[], 'public_viewings':[]}
for sent in sentences:
doc = nlp(sent)
matches = matcher(doc)
for match_id, start, end in matches:
if doc.vocab.strings[match_id] == 'call_pattern':
found['numbers'].append(doc[start:end])
if doc.vocab.strings[match_id] == 'email_pattern':
found['emails'].append(doc[start:end])
if doc.vocab.strings[match_id] == 'public_viewing_pattern':
found['public_viewings'].append(doc[start:end])
print(found)
result:
{'numbers': [call 000 000 000], 'emails': [test#test.com], 'public_viewings': [public viewing on, public viewing on 25nd, public viewing on 25nd of, public viewing on 25nd of january, public viewing is, public viewing is on, public viewing is on the, public viewing is on the coming, public viewing is on the coming wednesday]}
Ps.: This repeating is caused by a bug in spacy versions prior to 2.1. Just add some manual validation for repeating matches (get the one with most lenght) and you'll be good.
The hard part will be to generalize enough and correctly get your patterns, but they are very powerful and you can do all sort of tweaks to them. Check spacy online demo for testing. Also, refer to the manual for more complex stuff.

Killing a random directed link in both direction in netlogo

Greeting,
I am very new to netlogo, and is very interested in GIS and network feature in netlogo.
Currently, I have constructed a directed graph network.
I would like to implement a function to kill a directed link path in both direction.
I have found way to kill a link in both direction if you know which are the linkage of the 2 node to kill off. Below is the code for that (by Seth Tisue in one of the question thread) :
ask a [ ask link-with b [ die ] ]
I would like to kill of a random linkage in both direction. I assume I would need to use "ask one-of links [ die ]" and another part of the code to kill of the corresponding other direction of the linkage.
I guess my question would be how the mechanism of "one-of" work so that I would be able to store this random link first, and then kill off both direction using the first code above.
As a side line, I am also puzzled by how netlogo work with variable which is quite unlike normal C++ program(my fundamental is with c++ coding). I do quite a lot of importing for my network and GIS shapefile, and currently I am still not using netlogo engine as my computational engine(a waste for me).
How do you store a simple "x=1+1" into a global variable in netlogo?
Really sorry if this question is too simple for most.
Just as a general stackoverflow convention, if you have two questions, please ask them as separate questions. This is to make stackoverflow a useful resource for programmers, so that the title and question and answer are both together and easily found.
First, how do you even know there is a link in both directions? Typically directed graphs have many pairs of nodes where there is A to B or B to A but not both. The code below tests the other direction and kills both.
I have included your example of setting variable x to the value of 1 + 1 in the setup.
I am convinced there is a better way of doing this as NetLogo code is usually less ugly, but I can't find it. The following code is a complete runnable example that creates a bunch of nodes and links and then kills a link (including the reciprocal if it exists) whenever the kill-link procedure is run.
globals [x tonode fromnode]
to setup
clear-all
create-turtles 20
[ setxy random-xcor random-ycor]
repeat 100
[ ask one-of turtles
[ create-link-to one-of other turtles ; will not be created if already link
]
]
set x 1 + 1
end
to kill-link
ask one-of links
[ set fromnode end1
set tonode end2
die
]
ask tonode
[ if out-link-neighbor? fromnode
[ ask out-link-to fromnode [die]
]
]
end
Global variable should be declared at the beginning of program:
globals [
my-global-link; this will be my global variable
my-another-one-link; another one
]
To "store" random link use it like:
to do-something
set my-global-link one-of links
end
For local variables (inside a procedure) just use let do declare it first:
to do-something
let tmp-global-link one-of links
end

iOS App Development with SEC Edgar/Xbrl Integration

I am working on building an iOS app in Objective-C that requires data to be pulled from the SEC's Edgar Filings database. How can I integrate a search field into my code that would call on a specific company's financial statement information to display in the app? Any helpful advise or resources would be greatly appreciated. Thanks.
Using CIK is probably the best way to search for specific company filings.
One way is to have your app screen scrape the results using some of the functions available in WebKit like evaluateJavaScript. Pulling information from income statements and identifying the individual income statement line items would be very difficult because the labels would be inconsistent among companies.
In your code, you could format the http web string for an Edgar 10-K filing which contains the income statement like so
let CIK="1652044"
let SECFormName = "Form10K"
let URLStr = "https://www.sec.gov/cgi-bin/browse-edgar?company=&CIK=" + CIK + "&type=" + SECFormName + "&owner=include&count=40&action=getcurrent"
The above is in Swift syntax and conversion to Objective C is minor.

A data extraction - Need Ideas

Consider there are n rows of text similar to the ones below:
"Sony KDL46NX720 BRAVIA 46" 3D LED Backlit HDTV - 1080p, 1920 x 1080, 16:9, 120Hz, HDMI, USB, WiFi Ready » for $1148.99 at Tiger Direct"
"Samsung NV40 10.5 MP Digital Camera - Silver - 3x Zoom Lens » for $64.99 at eBay"
"Gateway NV57H27u 15.6" Notebook, Intel Core i3-2310M (2.10GHz), 4GB DDR3 Memory, 500GB HDD, DVD Super Multi-Drive, Windows 7 Home Premium 64-Bit (Pink) - LX.WZF02.002 » for $399.99 at Buy.com"
I would like to parse these strings and classify each of them as "TV, camera, laptop" etc.
The text attributes may or may not be similar.
How can this be comprehensively done?
What code/tools should I use?
What language?
I do not want to do a keyword search.
Can this strings be classified using class/attribute logic?
Can I use Protege to build the class/sub-class hierarchy?
I am totally new to this field of data-mining. So excuse my ignorance!
Thanks in advance.
Regular expresions, even a javascript can do the work
EDIT:
var criteria = {
camera : {
identifier : /.*camera.*/ ,
resolution : /.*(\d+)\s*x\s*(\d*).*/ ,
value : /.*$(\d+).*/ ,
...
},
notebook : {
identifier : /.*notebook.*/ ,
ram : /.*(d+)GB\s*(DDR.).*/
...
}
...
}
Then write a simple engine that use this structure to analize each line
EDIT 2:
This is not easy at all because you heve to feed some sort of knowlege database, but is posible, you can feed this with pages like this.
http://en.wikipedia.org/wiki/List_of_CPU_power_dissipation
but is work for more than one person or for more than one day depending on how much intelligence you want for your code.

Free City/State/Zipcode to Latitude/Longitude Database? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Is there a standard database of records mapping city/state/zip to lat/lng? I found this database, and the USPS has a simple (no lat/lng) API, but is there another recommended alternative?
Update: Found this too: http://www.geopostcodes.com/
Just a small note. Most of these 3rd party city/state/zip to lat/lng databases are based on the US Census Tiger data. Start with the Census 2000, the zip code data was replaced with ZCTA - which is an approximation of zipcodes. Here's an explanation from the Census site (from 2011):
ZIP Code Tabulation Areas (ZCTAs™) are a new statistical entity developed by the U.S. Census Bureau for tabulating summary statistics from Census 2000. This new entity was developed to overcome the difficulties in precisely defining the land area covered by each ZIP Code®. Defining the extent of an area is necessary in order to accurately tabulate census data for that area.
ZCTAs are generalized area representations of U.S. Postal Service (USPS) ZIP Code service areas. Simply put, each one is built by aggregating the Census 2000 blocks, whose addresses use a given ZIP Code, into a ZCTA which gets that ZIP Code assigned as its ZCTA code. They represent the majority USPS five-digit ZIP Code found in a given area. For those areas where it is difficult to determine the prevailing five-digit ZIP Code, the higher-level three-digit ZIP Code is used for the ZCTA code. For more information, please refer to the ZCTA (FAQ) Frequently Asked Questions Web page.
The link below is an updated explanation (2013):
http://www.census.gov/geo/reference/zctas.html
The OpenGeoCode.Org team
ADDED 12/17/13: Our (FREE) state/city/zip dataset (CSV) can be found at the link below. It is derived from public domain "government" datasets:
http://www.opengeocode.org/download.php#cityzip
Google offers this as a lookup. Can you do ajax calls from your app?
It's called webservices.
http://code.google.com/apis/maps/documentation/webservices/index.html
You'd want to use the Google Geocoding api.
It's simple to use, make a call to this url:
http://maps.googleapis.com/maps/api/geocode/json?address=sydney&sensor=false
Change "address=" to whatever you need (ie the city state and zip code)
It can also reply in xml. just change json to xml
http://code.google.com/apis/maps/documentation/geocoding/
Example Result
{
"status": "OK",
"results": [ {
"types": [ "locality", "political" ],
"formatted_address": "Sydney New South Wales, Australia",
"address_components": [ {
"long_name": "Sydney",
"short_name": "Sydney",
"types": [ "locality", "political" ]
}, {
"long_name": "New South Wales",
"short_name": "New South Wales",
"types": [ "administrative_area_level_1", "political" ]
}, {
"long_name": "Australia",
"short_name": "AU",
"types": [ "country", "political" ]
} ],
"geometry": {
"location": {
"lat": -33.8689009,
"lng": 151.2070914
},
"location_type": "APPROXIMATE",
"viewport": {
"southwest": {
"lat": -34.1648540,
"lng": 150.6948538
},
"northeast": {
"lat": -33.5719182,
"lng": 151.7193290
}
},
"bounds": {
"southwest": {
"lat": -34.1692489,
"lng": 150.5022290
},
"northeast": {
"lat": -33.4245980,
"lng": 151.3426361
}
}
}
} ]
}
Then all you need to do is open up results[0].geometry.location.lat, and results[0].geometry.location.lng
[EDIT 8/3/2015]
The free non-commercial ZIP Code database I mentioned below has moved to softwaretools.com. Note: greatdata.com still has the premium ZIP Code data for enterprises.
Just a small note. Most of these 3rd party city/state/zip to lat/lng databases are based on the US Census Tiger data. [Andrew]
I'm a developer for a commercial ZIP Code Database company (GreatData). For low-end data, Andrew's recommendation is correct and if you know your way around census data, it's pretty easy to get it. Just know it may initially take some hours to get it right. If you prefer not to do the work yourself, you can get our free/non-commercial version here (it's pretty much what Andrew is suggesting with minor enhancements. It's updated every couple months).
For a really good explanation on what is missing in it (and more importantly, what's missing in most all low-end ZIP Code data that is based on census ZCTA data) versus a commercial grade, see here.
ps - regarding suggestions to use Google's API, I see this suggested a lot but unless you're displaying it in a google map, this violates Googles TOS. Specifically: "The Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited." You'll find StackOverFlow has several threads on those who's sites have been blocked.
Hope this is beneficial
This is an old thread, but I was looking for the same information recently and also came across this free database:
http://federalgovernmentzipcodes.us
Check out zcta. You can draw the geographic boundaries of a zip code using their data.
If you have a small number of US cities you can easily build up your own database from Google which gives you the co-ordinates straight on the search page without the need to follow any links, e.g. type:
chicago illinois longitude latitude

Resources