Issue with google geocode API : Getting "partial_match" in response - api

I am using google Geocode API to get the lat long of particular address.
when I am searching for "364 S Side Square, Carlinville, IL 62626, USA" in google search or google maps it gives the accurate pin point on google search result or maps result.
but same time when i am searching the same address using Geocode API using below request call, it gives "partial_match" : true
http://maps.googleapis.com/maps/api/geocode/json?address=364 S Side Square, Carlinville, IL 62626, USA&sensor=false
any one knows why it gives "partial_match" : true in response ?
what changes i have to do in the API request so that i won't get "partial_match" ?

To understand the nature of the partial match flag for the '364 S Side Square, Carlinville, IL 62626, USA' let's have a look at this address in geocoder tool:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D364%2520S%2520Side%2520Square%252C%2520Carlinville%252C%2520IL%252062626%252C%2520USA
Indeed, the search string and formatted address in the result are exactly the same, however, we have to pay attention to other values like location_type and place_id
As you can see the location type is RANGE_INTERPOLATED and the place ID has a long value Ei0zNjQgUyBTaWRlIFNxdWFyZSwgQ2FybGludmlsbGUsIElMIDYyNjI2LCBVU0E. This means Google doesn't have an exact address feature in their database and tries to interpolate where this address might be located. In case if address exists in the Google database, you will see a location type ROOFTOP and a shorter place ID (something similar to ChIJrTLr-GyuEmsRBfy61i59si0).
Resuming aforementioned, the partial match flag in your example indicates that exact street address feature doesn't exist in the Google database.
This also can be confirmed by the following sentence in the documentation:
Partial matches most often occur for street addresses that do not exist within the locality you pass in the request.
https://developers.google.com/maps/documentation/geocoding/intro#GeocodingResponses
You also have an option to report a missing address to Google following the help center:
https://support.google.com/maps/answer/6320846
I hope my answer addresses your doubt!

partial_match indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the requested address. You may wish to examine the original request for misspellings and/or an incomplete address.
Partial matches most often occur for street addresses that do not exist within the locality you pass in the request. Partial matches may also be returned when a request matches two or more locations in the same locality. For example, "21 Henr St, Bristol, UK" will return a partial match for both Henry Street and Henrietta Street. Note that if a request includes a misspelled address component, the geocoding service may suggest an alternative address. Suggestions triggered in this way will also be marked as a partial match.
try place_id which is unique identifier

Related

how to get table info and summary of page using Wikipedia api?

I want to get minimal information of a Wikipedia page using MediaWiki API like DuckDuckGo. For example for Steve Carell: https://duckduckgo.com/?q=steve+carell&t=hp&ia=news&iax=about
How can I get this information with a Wikipedia url (eg https://en.wikipedia.org/wiki/Steve_Carell) in HTML format?
You can use the MediaWiki API for that. There's an extension, TextExtracts, which is exactly for that (and it is installed on Wikipedia).
In your case, e.g.:
https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exsentences=1&titles=Steve%20Carell
will return something like:
<p class=\"mw-empty-elt\">\n</p>\n\n<p class=\"mw-empty-elt\">\n \n</p>\n<p><b>Steven John Carell</b> (<span></span>; born August 16, 1962) is an American actor, comedian, producer, writer and director.</p>
You can customize how many sentences (or characters) the API returns, as well, please consult the API documentation for that.
There's also the way to retrieve the short description, which is saved at Wikidata (and visible in the mobile view of Wikipedia). This call would be:
https://en.wikipedia.org/w/api.php?action=query&prop=pageprops&titles=Steve_Carell
This returns the following property in the pageprops of the page:
"wikibase-shortdesc": "American actor"
This may fit better depending on your use case.
You can even get both of the results with a single, combined, request:
https://en.wikipedia.org/w/api.php?action=query&prop=extracts|pageprops&exsentences=1&titles=Steve_Carell

Xpath to match case sensitive of multiple strings

I need to input field value in application and no unique attribute for that field. Due to that I am using text() function and it worked. This application changes slightly between vendors.
In application, for vendor1, field name is:
Physical street address
for other vendor, it is
Physical Street Address
Streed and Address are case sensitive between two vendors and due to this my script is failing.
My xPath which is working for second vendor but failing for first vendor:
//tr[td[contains(text(),'Physical Street Address')]]/td//input[contains(#id, 'part1')]
I checked with translate but it is not working.
Not sure why translate() didn't work at your end. Perhaps your code trials may have helped us to debug the issue. You can use the following solution:
//tr[td[translate('Physical Street Address','abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')]]/td//input[contains(#id, 'part1')]
I'm sure there is a more elegant solution, but I think it should work too
//tr[td[contains(text(),'Physical Street Address') or contains(text(),'Physical street Address')]]/td//input[contains(#id, 'part1')]

What are the foursquare API rules about returning the "facebook" field for venues?

This page -- https://developer.foursquare.com/docs/responses/venue -- specifies the fields returned by a venue query, and lists whether or not they are always returned or only sometimes returned.
This venue has a facebook URL specified:
https://foursquare.com/v/specialty-produce/4ab5b07df964a520d57520e3
But when I get the venue data from a venue search, it does not include that field (see below) and it is not listed in the document for the Venue endpoint located at
https://developer.foursquare.com/docs/responses/venue
I therefore can't tell if it should be expected in the contact object (which is where the twitter page is) or up one level (which is where the venue URL is located) and whether or not it is in either the compact or complete object some/none/all of the time.
Note that I am sometimes seeing a "facebook" field, such as this venue:
https://foursquare.com/v/somewhere-loud/5179ef7fe4b076127bf04922
which returns the following "contact" dictionary
"contact":{"twitter":"somewhereloud","facebook":"461351130570902"},
Here's an example of a response with no facebook field, even though the venue has one shown on their page on foursquare.
{"venues":[{"id":"4ab5b07df964a520d57520e3","name":"Specialty Produce",
"contact":{"phone":"6192953172","formattedPhone":"(619) 295-3172","twitter":"specialtyprod"},
"location":{"address":"1929 Hancock St, #150","crossStreet":"Noell Street",
How do I determine when and where to find this field for any particular venue?
Facebook URLs aren't always returned in the contact object in a venues response; only the fields currently documented are guaranteed to be returned.
On Foursquare's own venue pages, if the venue has a page associated with it, the Facebook URL may be pulled from the user object within the page object. For the example you gave, you can see that the Facebook ID (which translates to the URL) comes from response.venue.page.user.contact.facebook: https://developer.foursquare.com/docs/explore#req=venues/4ab5b07df964a520d57520e3

Google Maps API Geocode Postal Code and set Country code?

I'm using this API call to Google Maps to get the latitude and longitude of a postal code
http://maps.googleapis.com/maps/api/geocode/json?address=2340&sensor=false
The postal code is in Australia. This API call returns locations all around the world with partial matching postal codes in the address.
Is there a parameter I can use to set the country to Australia?
Thanks
The correct way to do this is not via region biasing but rather using component filtering:
https://maps.google.com/maps/api/geocode/json
?components=country:AU|postal_code:2340
&sensor=false
Some demonstrations:
2340
93274
Please note that if you use the components parameter, you don't need to specify the address parameter.
The documentation says that Region Biasing is based on CcTLDs, which would make Australia au (haven't tried it myself).
Although it also states this:
Note that biasing only prefers results for a specific domain; if more relevant results exist outside of this domain, they may be included.

Twitter API: How to search only for geotagged tweets

How can I use Twitter Search API (or other) to get a list of tweets which have the "geo" param?
--EDIT--
By example: I wont get list of geotagged tweets, by #apple tag. Without location filter, worldwide.
Looks like the latest API supports that; simply use a large enough geo region for your query:
-180,-90,180,90
See more from the API link for filter and location
The streaming API allowed you to filter by a location and the search API allows you to search by geocode. You can find more information on these services on our developer resources site.
Streaming API: http://dev.twitter.com/pages/streaming_api
Example: Create a file called ‘locations’ that
contains, excluding the quotation
marks, the phrase:
“locations=-122.75,36.8,-121.75,37.8,-74,40,-73,41” then execute:
curl -d #locations
http://stream.twitter.com/1/statuses/filter.json
-uAnyTwitterUser:Password.
You will receive all geo tagged tweets
from the San Francisco and New York
City area.
Search API: http://dev.twitter.com/doc/get/search
Example: http://search.twitter.com/search.json?geocode=37.781157,-122.398720,1mi
From the Twitter API Documentation, this should be the format of your search query:
http://search.twitter.com/search.json?geocode=37.781157,-122.398720,1mi
Where 37.781157 is the latitude, -122.398720 is the longitude and 1mi is the radius to search within.
You can look for every tweet but save only the geotaged ones.
I know it dont make a lot of sense, but works quite well.
if you call you search results, you can state
for result in results:
if result.geo != None:
print result.text.encode('utf-8', errors='ignore') # or do anything you want with the tweets
Use -180,-90,180,90 to get any geotagged tweet.