This call https://maps.googleapis.com/maps/api/place/autocomplete/xml?input=qqqqqqq (plus your key) returns addresses like 'qqqqqqqqqq, Florida, USA' and 'qqqqqqqqqqqqqqqqqqqqqqqq - Luizote de Freitas, Uberlândia - State of Minas Gerais, Brazil'. I understand that QQQ might be a valid name, but qqqqqqqqqqqqqqqqqqqqqqqq? And it works the same way for any sequence of repeating letters or numbers.
Ok, let's say this is google having bad data. But how to explain results for 'www': 'Best Buy, Middlesex Turnpike, Burlington, MA, USA', 'Acton Toyota of Littleton, Great Road, Littleton, MA, USA'? I do not see any sane correlation between 'www' and the results.
You can see similar behaviour in google maps, so it's not just autocomplete API.
Any theories?
When I execute request https://maps.googleapis.com/maps/api/place/autocomplete/json?input=www&key=MY_API_KEY from my location I get really weird predictions as well
Montpellier, France (place ID ChIJsZ3dJQevthIRAuiUKHRWh60, type locality)
Berlin, Germany (place ID ChIJAVkDPzdOqEcRcDteW0YgIQQ, type locality)
Hamburg, Germany (place ID ChIJuRMYfoNhsUcRoDrWe_I9JgQ, type locality)
Munich, Germany (place ID ChIJ2V-Mo_l1nkcRfZixfUq4DAE, type locality)
Vienna, Austria (place ID ChIJn8o2UZ4HbUcRRluiUYrlwv0, type locality)
Note all of them have locality type, and indeed it smells like a bug, because I cannot see how on earth the text 'www' might match these predictions. Apparently, something is broken on Google backend and leads to the strange behavior in places autocomplete.
I can confirm that I can see this problem on Google Maps web site as well
At this point I believe the best option for us is sending a feedback to Google Maps team and hope they will fix it soon.
Related
I'm testing Google Places API to retrieve the most popular tourist attraction in some locations. I can retrieve up to 60 results by using the pagination but in the results I get, I'm missing some major attractions while I did not reach the limit of 60 results and some minor attractions were available.
I use PHP to call the API and my API call uses the following URL structure:
https://maps.googleapis.com/maps/api/place/textsearch/json?type=tourist_attraction|point_of_interest|landmark|natural_feature|museum|amusement_park|park&language=fr&key=***myapi***&query=***location***
If I use Brussels as location, it returns only 20 results while there are way more results available for Brussels when looking for tourist attraction directly on the map. Some of the most popular attractions are not even displayed in the results. I have many similar cases for other cities/location, it's like the search was looking for results in a too narrow area.
Is there a way to get more results? Or do a kind of radius search to go around the narrow results provided by the api?
Query example:
https://maps.googleapis.com/maps/api/place/textsearch/json?type=tourist_attraction&language=fr&key=XXX&query=bruxelles
Places returned: 20
If I use pagination to get to page 2 and 3, it basically returns results that are already in the first page and I end up with 20 different places.
Places found:
Atomium,Grand-Place,Manneken Pis,Palais du Coudenberg,Parc du Cinquantenaire,Mont des Arts,Cathédrale des Sts Michel et Gudule, Bruxelles,Mini-Europe,Musée de la ville de Bruxelles,Monument du Cinquantenaire,Place Royale Bruxelles,Centre Belge de la Bande Dessinée,Parc de Bruxelles,Tour Noire,Colonne du Congrès,Tour Anneessens,Musées Royaux des Beaux-Arts de Belgique,Parc Léopold,Basilique Nationale du Sacré-Cœur à Koekelberg, Église Notre-Dame des Victoires au Sablon
There are a couple of big tourist attractions that are not in this list while I see them on Google Maps when searching for tourist attraction in Brussels.
Example:
Royal Palace (11k reviews), Train World (5k reviews), Horta Museum (2k reviews), Autoworld (7k reviews), Magritte Museum (5k reviews), St Hubert galleries (32k reviews),...
In the list of places coming from the api there are popular tourist attractions but some of them are way less popular in terms of reviews than some of the ones that are missing. They are all in the category "tourist_attraction".
So I don't understand why I only get those ones while there are many others.
Thanks
Laurent
You might get better results from Place Nearby Search, with some caveats.
Results are ranked by prominence by default: Ranking will favor prominent places within the set radius over nearby places that match but that are less prominent. Prominence can be affected by a place's ranking in Google's index, global popularity, and other factors. When prominence is specified, the radius parameter is required.
Example:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?radius=10000&type=tourist_attraction&location=50.847642,4.35717
To find the nearest results to a given location, use rankby=distance (without radius) and type=tourist_attraction (only one type).
Example: https://maps.googleapis.com/maps/api/place/nearbysearch/json?rankby=distance&type=tourist_attraction&location=50.847642,4.35717
Caveats:
This method is called Nearby Search for a reason: it only returns results that are near to the given location, if the only results that match the given type are far away they won't be returned.
The region where results are returns (search radius) is adjusted dynamically based on area density, independent of rankby parameter, so might still get less than 60 results in some places.
I'm trying to collect a dataset that could be used for automatically generating baseball articles.
I have play-by-play records of MLB games from retrosheet.org that I would like to be written out to plain text, as those that could possibly appear as part of a recap news article.
Here are some examples of the play-by-play records:
play,2,0,semim001,32,.CBFFFBBX,9/F
play,2,0,phegj001,01,FX,S7/G
play,2,0,martn003,01,CX,3/G
play,2,1,youne003,00,,NP
The following is what I would like to achieve:
For the first example
play,2,0,semim001,32,.CBFFFBBX,9/F,
I want it to be written out as something like:
"semim001 (Marcus Semien) was on three balls and two strikes in the second inning as the away player. He hit the ball into play after one called strike, one ball, three fouls, and another two balls. The fly ball was caught by the right outfielder."
The plays are formatted in the following way:
The first field is the inning, an integer starting at 1.
The second field is either 0 (for visiting team) or 1 (for home team).
The third field is the Retrosheet player id of the player at the plate.
The fourth field is the count on the batter when this particular event (play) occurred. Most Retrosheet games do not have this information, and in such cases, "??" appears in this field.
The fifth field is of variable length and contains all pitches to this batter in this plate appearance and is described below. If pitches are unknown, this field is left empty, nothing is between the commas.
The sixth field describes the play or event that occurred.
Explanations for all the symbols in the fifth and sixth field can be found on this Retrosheet page.
With Python 3, I've been able to format all the info of invariable length into a formatted sentence, which is all but the last two fields. I'm having difficulty in thinking of an efficient way to unparse (correct me if this is the wrong term to use here) the fifth and sixth fields, the pitches and the events that occurred, due to their variable length and wide variety of things that can occur.
I think I could write out all the rules based on the info on the Retrosheet website, but I'm looking for suggestions for a smarter way to do this. I wrote natural language processing as tags, hoping this could be a trivial problem in that field. Any pointers will be greatly appreciated!
I've this URL from which I can find all the Cafes in the defined area using google apis:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=26.272514,50.195682&radius=15000&types=cafe&key=<myAPI>
The area covered in the range above is within the circle shown below:
The actual area of the city I'm considering is as appearing below:
https://www.google.com.sa/maps/place/Al+Khobar/#26.2435009,50.0472298,11z/data=!4m5!3m4!1s0x3e49e839e8ef58d9:0xef778812d8b6aad1!8m2!3d26.2171906!4d50.1971381?hl=en
How can I get all the cafes which are exactly in this city (no more no less, without using radius)?
After digging at Google Places API here I found this code, which looks to be fine for me:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=cafes+in+Khobar&key=YOUR_API_KEY
You can achieve that using the text search endpoint like this:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Khobar&type=cafe®ion=SA&key=API_KEY
The tricky part comes when you want to specify concrete locations like:
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Macdonalds+in+Toledo+in+Spain&type=restaurant&key=API_KEY
as it performs a partial match of your query and if you will enter some name composed of two strings(example Sweet Burger) that you know doesn't exist in that city, it'll still get you back to some places that encounter combinations of | sweet | burger | Toledo | Spain | but you'd expect to return [].
I am using google place to retrieve address, and somehow we want the street(route in google terminology) to be separated into street name and street type. We also want the street type to match an existing column in database.
But things get difficult when google place sometimes use XXXX Street and some times XXXX st
For instance, this is a typical google address
{
administrative_area_level_1: ['short_name', 'VIC'],
locality: ['long_name', 'Carlton'],
postal_code: ['long_name', '3053'],
route: ['long_name', 'Canada Ln'],
street_number: ['short_name', '12'],
subpremise: ['short_name', '13']
}
But it always shows Canada Lane in the suggestion box.
And sometimes even worse when the abbreviation does not match my local data model. For instance we use la instead of ln for short of lane.
It will be appreciated if anyone could tell me where to find a list of street type (and abbreviation) used by google API. Or Is there a way to disable the abbreviation option?
Sounds like you're after "street suffixes". These are complicated.
Not only they change across countries and languages, even within the same country and language they can be used in different ways; abbreviations can have multiple meanings: "St" can be "Street" of "Saint"; abbreviations are used or not depending on subtle rules that also change from place to place.
Same goes for cardinal points (North, South, East, West) that are parts of road / street names: "North St" or "N 11st Street"? It's complicated.
If you already have a good amount of addresses, and you only care about addresses in English, you could take the last word from each street name as the suffix. When matching to your own data, allow for abbreviations when matching, rather than trying to expand them.
For instance, don't try to expand "Canada La" into "Canada Lane" so that it matches "Lane". Instead, expand "Lane" into ["Lane", "La", "Ln"] and match suffixes to all values.
Then you'd need a strategy for "collisions", abbreviations that can mean 2+ suffixes. These seem to be rare, I can't remember any ("St" isn't, because "Saint" isn't a suffix) and USPS' http://pe.usps.gov/text/pub28/28apc_002.htm doesn't seem to have any.
iPhone has a pretty good telephone number splitting function, for example:
Singapore mobile: +65 9852 4135
Singapore resident line: +65 6325 6524
China mobile: +86 135-6952-3685
China resident line: +86 10-65236528
HongKong: +886 956-238-82
USA: +1 (732) 865-3286
Notice the nice features here:
- the splitting of country code, area code, and the rest is automatic;
- the delimiter is also nicely adopted to different countries, e.g. "()", "-" and space.
Note the parsing logic is doable to me, however, I don't know where to get the knowledge of most countries' telephone number format.
where could i found such knowledge, or an open source code that implemented it?
You can get similar functionality with the libphonenumber code library.
Interestingly enough, you cannot use an NSNumberFormatter for this, but you can write your own custom class for it. Just create a new class, set properties such as countryCode, areaCode and number, and then create a method that formats the number based on the countryCode.
Here's a great example: http://the-lost-beauty.blogspot.com/2010/01/locale-sensitive-phone-number.html
As an aside: a friend told me about a gigantic regular expression he had to maintain that could pick telephone numbers out of intercepted communications from hundreds of countries around the world. It was very non-trivial.
Thankfully your problem is easier, as you can just have a table with the per-country formats:
format[usa] = "+d (ddd) ddd-dddd";
format[hk] = "+ddd ddd-ddd-dd";
format[china_mobile] = "+dd ddd-dddd-dddd";
...
Then when you're printing, you simply output one digit from the phone number string in each d spot as needed. This assumes you know the country, which is a safe enough assumption for telephone devices -- pick "default" formats for the few surrounding countries.
Since some countries have different formats with different lengths you might need to store your table with additional information:
format[germany][10] = "..."
format[germany][11] = "....."