Google Geocode API - Indian Reservations - google-maps-api-3

Why is it that no type is returned when the address component is an Indian
Reservation? It is just returned as shown below, and because there is no type, it causes an error when trying to geocode addresses that return an Indian Reservation.
<address_component>
<long_name>Hopi Indian Reservation</long_name>
<short_name>Hopi Indian Reservation</short_name>
</address_component>
Example addreses:
HWY 160 & HWY 264
Tuba City, AZ 86045
OR
HWY 160 & HWY 163
Kayenta, AZ 86033

I guess the documentation about Address Component Types is a bit too subtle as to (not mentioning) the fact that there is no guarantee that the types[] array will always contain something, or that hese types may also be returned within address_components[] arrays ... or may not.
Your example reproduces this behavior pretty well:
http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=Hopi%20Indian%20Reservation
The types[] array is empty for the first result and its first address component.
Short term, I think your (and everybody's) code should be ready to accept empty types[] arrays. Long term, I'd agree it'd be better to give every result at least one type. For the specific case of indian reservations, I've no idea which one (if any) of the available ones would make sense. Maybe one of...
political indicates a political entity. Usually, this type indicates a polygon of some civil administration.
colloquial_area indicates a commonly-used alternative name for the entity.
park indicates a named park.
point_of_interest indicates a named point of interest. Typically, these "POI"s are prominent local entities that don't easily fit in another category such as "Empire State Building" or "Statue of Liberty."
If anyone has a clear idea how to classify these in the available Address Component Types, please file a feature request for the Geocoding API ;)

Related

Here API - Need guidance defining query, q, value

The HERE api seems really picky about what is uses for the q parameter in API calls. According to the documentation you can use a street address, partial address, name of place, etc (documentation: https://developer.here.com/documentation/places/topics/free-text-search.html)
Im trying to take an address and return the name of the store, building, business at that location (a few million of these) In some cases I have a human typed name of the place at the address but this can be quite messy and inaccurate in a lot of cases so Im trying not to use this information. Address however Im quite confident in.
in summary Im trying to provide here with an input like "15300 Cedar Ave, Apple Valley, MN 55124" and output "Best Buy"
Here seems to be really finicky on what your q input is..
When I put in the address and geocode info, Best Buy doesn’t appear on the results list
q=15300 Cedar Ave, Apple Valley, MN 55124
in=44.7287,-93.2147;r=800
https://places.demo.api.here.com/places/v1/discover/search?q=15300+Cedar+Ave%2C+Apple+Valley%2C+MN+55124&in=44.7287%2C-93.2147%3Br%3D800&Accept-Language=en-US%2Cen%3Bq%3D0.9&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg
Based on this Im thinking maybe this info just isnt in here's database, but when I run this query which includes best buy in the search it finds it right away at the correct address!!
q=best buy 15300 Cedar Ave, Apple Valley, MN 55124
in=44.7287,-93.2147;r=800
https://places.demo.api.here.com/places/v1/discover/search?q=best+buy+15300+Cedar+Ave%2C+Apple+Valley%2C+MN+55124&in=44.7287%2C-93.2147%3Br%3D800&Accept-Language=en-US%2Cen%3Bq%3D0.9&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg
It seems like a no-brainer to me that HERE would use the q value as an address search but that doesnt always appear to be the case. Looking for guidance on how to make this smarter
if the point of interest(POI) needs to be searched by specific address, then q is significant for fetching the records. As the API will fetch only those records which have those keywords in that area.
if POIs need to be searched at specific lat-long and around defined meter range, then q is not significant.
https://places.demo.api.here.com/places/v1/discover/around?in=44.7287%2C-93.2147%3Br%3D800&Accept-Language=en-US%2Cen%3Bq%3D0.9&app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg
Is it mandatory for you to pass address all the time, or lat-long can also work ?

In Watson conversation, How to turn on fuzzy matching only for synonyms and not for the value?

I am modelling a conversation in Watson conversation. The conversation is around the facilities available at airports. I have configured airport names as an entity and have added variations of airport names as synonyms and have kept the IATA code for the airport as the entity value. For example, Schiphol airport in Amsterdam looks like the below
I have turned on fuzzy matching on this entity so that I can catch typos people will make when they try to say Schiphol or Amsterdam. However, Watson is now capturing the word am in the below sentence as this entity
I am wondering if there is wifi in schiphol airport?
How do I stop Watson from fuzzy matching on the entity value but only do it on synonyms?
I don't think it's possible to enable Fuzzy matching on synonyms only, at the moment. I see a couple of "easy" workarounds.
Option 1: Leverage Watson's confidence level.
If you place <? entities ?> within your node's response and test it in the Try it out panel, you'll notice that each detected entity has a confidence level associated with it. This is Watson's confidence level in the entity, expressed as a float ranging from 0 to 1.
When testing it with your entity value and synonyms, I got 90% confidence (i.e., 0.9) for amsterdaam but only 70% for am.
So assuming these numbers hold for you, you could use entities[0].confidence > 0.7 as the condition in your node to decide when to assign the airport to a context variable and when to ask for clarification from the user in the response.
You might have to do some testing to see if you can find a confidence level value that works reasonably well as a threshold for your #airport entity values and their common misspellings.
Option 2: Use two entities
#airport-code: Use the airport code for the value, no synonyms, and no fuzzy matching enabled.
#airport-name: Use the airport name for the value, various synonyms including city, and fuzzy matching enabled.
Depending on how your chatbot works, this might be an acceptable compromise or complicate too much your logic.
I'll give you an example. If your $airport context variable will work whether AMS or Amsterdam Airport Schiphol is stored, this solution solves the problem for you as is. If not, there is an extra step before you can assign the value to the $airport context variable. Namely, you may need to implement a lookup to retrieve the airport code for the given airport name.

Extract the address portion of a callers response

In a conversation turn the caller is asked for the address of their destination. A few response examples:
I'm heading to 123 Lombard Street.
I'll be at 2210 third Ave.
I should be arriving to 44 Cross Terrace about 3:00 this afternoon.
Is it possible to isolate and extract the the address portion of the users response:
123 Lombard Street
2210 third Ave.
44 Cross Terrace
I'm looking for advice, best practices on whether this extraction can be accomplished using intents and entities to locate the numeric portion, and (street, Ave, Terrace) portions and wild-card what's in between (Lombard, third., Cross) or will application code be required to locate and extract the address portion.
If any additional information is required I'll be happy to provide on request.
A strategy could be to use the system entity #sys-number to point to the beginning of your referenced address snippets. The metadata for each found entity holds the location information (begin / end in the input string). From there you would need to search the input string for anything not in your specific "address vocabulary".
You could add your adress vocabulary (street, road, terrace, avenue plus the synonyms) as entities. The range from smallest entity position to highest could be extracted and then used to normalize the address.
The extraction and some processing can be done inside the conversation service, but you likely need to have outside logic to normalize the found address snippets to what you need.
This blog entry about tips & tricks for building chatbots has some useful stuff and links to a repository with some detailed examples of processing entities and variables.

CSV list of all universities - google maps

I have a CSV list of university names around the world - about 13,000 university names. I'm looking for a way to pull the addresses of these universities. Google Maps API / Google Places API looks promising, but requires lat/long to map the locations.
End game is to mark to each school as a 1 if the school is in the US, and 0 if the school is outside of the US.
Any thoughts on how to search these colleges in maps and pull out the addresses - or at least the country?
Example:
is there nothing else in the csv, only the names? that's going to make it hard, i'd bet the names aren't always unique in the world.
you could write something that had different passes at biting the apple - for instance, if the university has a state name in it, check those off as 1's - then find another logic to use to take "another bit" until the apple is gone.
On top of #WEBjuju's answer, since you only want to mark if the school is in US, or outside of US, you can use the "country" type in Place Types in the Google Places API, by setting the option as country='us'.
https://developers.google.com/places/supported_types?csw=1#table2
You may also want to cross check with this list of schools.
https://www.4icu.org/reviews/index2.htm
https://en.wikipedia.org/wiki/Lists_of_universities_and_colleges_by_country

Retrieving all the possible postal codes with only the street name and country (Germany)

Trying to build a dialog with a single text box where a user can (among others) enter just a street name in Germany, and the dialog should then display a list of all the postal codes (PLZ) possible for that street name in the whole of Germany. So basically I would need a list of all the PLZ + street name combinations in Germany ordered by streets in bigger cities first (or bigger streets first, if possible). I Have tried several different HERE APIs, but cannot yield any results when doing a search with only the street name, with country set to Germany. If I additionally fill in the city (streetname + city), then I get a nice response with all I need. So is there any way to get results for queries containing only street name and country (where country='DEU'), and without any city? The search would need to be location agnostic, only assumption being that the user is in Germany.
This kind of minimalistic search seems to work at here.com map site. The only problem on the here.com site is that it's locating me on a wrong city, and thus the 3 results it's giving me are not really relevant for my location. For instance, I'm in Berlin and here.com locates me in Leipzig, and I'm searching with "Chausseestr.".
Any thoughts if an address search with only the street name and country is feasible?
Thanks!
This looks like a structured Geocoding request, but unfortunately a street only geocoding request is too broad to return a valid response. Neither does a request combining street with country. Your best bet here would be to split Germany up into a series of non-overlapping bounding box geocoding requests covering say the north-east, north-west and south of the country and to amalgamate the results.
This request looks for 'Hauptstrasse' in Eastern Germany and returns up to 100 post codes only
http://geocoder.cit.api.here.com/6.2/geocode.json?street=hauptstrasse&responseattributes=none&locationattributes=none,ar&app_id=APP_ID&app_code=APP_CODE&gen=3&addressattributes=none,pst&country=deu&mapview=LAT,LONG;LAT,LONG&maxresults=100
street sets the street name to look for,
country=deu restricts the results to Germany
responseattributes=none removes confidence meta info from the response
locationattributes=none,ar restricts the responses to address only
addressattributes=none,pst restricts the addresses to post code only
mapview defines the limit of the bounding box of the request.
maxresults=100 ensures up to 100 results are returned.
Repeat this with Western Germany, Southern Germany and so on.
What works for here.com, and may work for your dialog box, is to use the suggestion end point from the places api. Try making a series of suggestion requests as the text box is filled setting the X-Map-Viewport to cover Germany :
http://places.cit.api.here.com/places/v1/suggest?X-Map-Viewport=LNG,LAT,LNG,LAT&q=haupt&app_id=APP_ID&app_code=APP_CODE&accept=application/json&size=100
There is even a ready made JavaScript component which could do this.
have you considered just try the geocoding ? and not taking just the first result, I would suppose this is what you see on the service example you are refering to. Thus do actually loop through all of replies. Of course see the API you are using, and make sure you are setting some nice number for the max results before doing any queries.
At least in some HERE offerings the reply data also includes address, thus you could fetch the postal code from there.
Also if it is not there, then do revercegeo query with the location gotten, then at least you should be getting it
Never too late to answer such a question.
Install QGIS (free).
Then "Plugins" -> "Manage and install plugins..." -> install "OSMDownloader"
Then "Vector" -> "Openstreetmap" -> "Download data" after you've zoomed into the area of interest
When you have the .xml file, use simple unix command line utils to slice and dice accordingly.
Quick hack (bit of a caveman solution but worked for me):
$ grep -A1 'addr:post' OSM_input.xml | egrep -v '^--$' | sed 'N;s/\n/ /' | grep 'addr:street' | awk -F'v="' '{print$2"#"$3}' | sed 's/"\/> <tag k="addr:street" //' | sed 's/"\/>/,/' > output.txt
The output.txt will contain a mostly accurate (needs some manual cleanup) file whose format is: zipcode#streetname (one per line).

Resources