[Developers] Freebase newbie: simple question
R. Pito Salas
rps at salas.com
Thu Feb 26 01:00:39 UTC 2009
Shawn
Great, you're da man!
Thanks,
Pito
On Feb 25, 2009, at 7:32 PM, Shawn Simister wrote:
> Vishal Talwar wrote:
>>
>> According to Wikipedia:
>> "The postal abbreviation is same as ISO 3166-2 subdivision code for
>> all fifty states."
>>
>> We hold the ISO 3166-2 subdivision code on the property /location/
>> administrative_division/iso_3166_2_code. Values should be of the
>> form "US-[state code]" for all US states, so the transformation
>> seems pretty straightforward from there.
>>
>> Hope that helps,
>> Vishal
> In MQL that would look like this:
>
> {
> "country" : {
> "id" : "/en/united_states"
> },
> "iso_3166_2_code" : null,
> "name" : "Massachusetts",
> "type" : "/location/administrative_division"
> }
>
> You can try this query out in the Query Editor Tool. Or you can
> fetch the data directly from your rails apps with the following code:
>
> require 'net/http'
>
> query_string = '{"query":{"country":{"id":"/en/
> united_states
> "},"iso_3166_2_code":null,"name":"Massachusetts","type":"/location/
> administrative_division"}}'
> query_uri = URI.parse('http://www.freebase.com/api/service/mqlread?query='
> + URI.escape(query_string))
> result = Net::HTTP.get(query_uri)
>
> Then it's just a matter of parsing the JSON, getting the value of
> iso_3166_2_code and removing the "US-" from the beginning.
>
> Shawn
>
> _______________________________________________
> Developers mailing list
> Developers at freebase.com
> http://lists.freebase.com/mailman/listinfo/developers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freebase.com/pipermail/developers/attachments/20090225/aa1c22a9/attachment.htm
More information about the Developers
mailing list