Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> from calais import Calais
- >>> CALAIS_API_KEY = "bunzc65wwn2axesvqfabz4dt"
- >>> cal = Calais(CALAIS_API_KEY)
- >>> res = cal.analyze("I live in Berlin")
- >>> res.entities
- [{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'}]}]
- >>> from prettyprint import prettyprint as pp
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- ImportError: No module named prettyprint
- >>> from pretyprint import pretyprint as pp
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- ImportError: No module named pretyprint
- >>> from pprint import pprint as pp
- >>> pp( res.entities )
- [{'__reference': u'http://d.opencalais.com/genericHasher-1/b61ec243-89c8-3a43-bf33-226e27c2384e',
- u'_type': u'City',
- u'_typeReference': u'http://s.opencalais.com/1/type/em/e/City',
- u'instances': [{u'detection': u'[I live in ]Berlin[]',
- u'exact': u'Berlin',
- u'length': 6,
- u'offset': 10,
- u'prefix': u'I live in '}],
- u'name': u'Berlin',
- u'relevance': 0.85699999999999998,
- u'resolutions': [{u'containedbycountry': u'Germany',
- u'id': u'http://d.opencalais.com/er/geo/city/ralg-geo1/88153e7c-717e-9100-f403-c25ceef5354e',
- u'latitude': u'52.523337',
- u'longitude': u'13.412687',
- u'name': u'Berlin,Germany',
- u'shortname': u'Berlin'}]}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement