Advertisement
vojtarek

Calais / coordinates

Sep 8th, 2011
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.94 KB | None | 0 0
  1. >>> from calais import Calais
  2. >>> CALAIS_API_KEY   = "bunzc65wwn2axesvqfabz4dt"
  3. >>> cal = Calais(CALAIS_API_KEY)
  4. >>> res = cal.analyze("I live in Berlin")
  5. >>> res.entities
  6. [{u'_typeReference': u'http://s.opencalais.com/1/type/em/e/City', u'_type': u'City', u'name': u'Berlin', '__reference': u'http://d.opencalais.com/genericHasher-1/b61ec243-89c8-3a43-bf33-226e27c2384e', u'instances': [{u'detection': u'[I live in ]Berlin[]', u'prefix': u'I live in ', u'exact': u'Berlin', u'length': 6, u'offset': 10}], u'relevance': 0.85699999999999998, u'resolutions': [{u'name': u'Berlin,Germany', u'longitude': u'13.412687', u'latitude': u'52.523337', u'shortname': u'Berlin', u'containedbycountry': u'Germany', u'id': u'http://d.opencalais.com/er/geo/city/ralg-geo1/88153e7c-717e-9100-f403-c25ceef5354e'}]}]
  7. >>> from prettyprint import prettyprint as pp
  8. Traceback (most recent call last):
  9.   File "<stdin>", line 1, in <module>
  10. ImportError: No module named prettyprint
  11. >>> from pretyprint import pretyprint as pp
  12. Traceback (most recent call last):
  13.   File "<stdin>", line 1, in <module>
  14. ImportError: No module named pretyprint
  15. >>> from pprint import pprint as pp
  16. >>> pp( res.entities )
  17. [{'__reference': u'http://d.opencalais.com/genericHasher-1/b61ec243-89c8-3a43-bf33-226e27c2384e',
  18.   u'_type': u'City',
  19.   u'_typeReference': u'http://s.opencalais.com/1/type/em/e/City',
  20.   u'instances': [{u'detection': u'[I live in ]Berlin[]',
  21.                   u'exact': u'Berlin',
  22.                   u'length': 6,
  23.                   u'offset': 10,
  24.                   u'prefix': u'I live in '}],
  25.   u'name': u'Berlin',
  26.   u'relevance': 0.85699999999999998,
  27.   u'resolutions': [{u'containedbycountry': u'Germany',
  28.                     u'id': u'http://d.opencalais.com/er/geo/city/ralg-geo1/88153e7c-717e-9100-f403-c25ceef5354e',
  29.                     u'latitude': u'52.523337',
  30.                     u'longitude': u'13.412687',
  31.                     u'name': u'Berlin,Germany',
  32.                     u'shortname': u'Berlin'}]}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement