ushahidi / geograpy

Extract countries, regions and cities from a URL or text
219 stars 133 forks source link

NotImplementedError: Use label() to access a node label. #12

Open awhan opened 8 years ago

awhan commented 8 years ago

pip installed geograpy on archlinux box and tried out this simple program

import geoprapy
t = 'India is a country'
p = geoprapy.get_place_context(text=t)

I got the following error

In [3]: p = geograpy.get_place_context(text=txt)
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-3-ae088bc75e75> in <module>()
----> 1 p = geograpy.get_place_context(text=txt)

/home/m/.local/lib/python2.7/site-packages/geograpy/__init__.pyc in get_place_context(url, text)
      4 def get_place_context(url=None, text=None):
      5     e = Extractor(url=url, text=text)
----> 6     e.find_entities()
      7
      8     pc = PlaceContext(e.places)

/home/m/.local/lib/python2.7/site-packages/geograpy/extraction.pyc in find_entities(self)
     29         for ne in nes:
     30             if len(ne) == 1:
---> 31                 if (ne.node == 'GPE' or ne.node == 'PERSON') and ne[0][1] == 'NNP':
     32                     self.places.append(ne[0][0])

/usr/lib/python2.7/site-packages/nltk/tree.pyc in _get_node(self)
    196     def _get_node(self):
    197         """Outdated method to access the node value; use the label() method instead."""
--> 198         raise NotImplementedError("Use label() to access a node label.")
    199     def _set_node(self, value):
    200         """Outdated method to set the node value; use the set_label() method instead."""

NotImplementedError: Use label() to access a node label.
Python version 2.7.11
Linux zero 4.5.4-1-ARCH #1 SMP PREEMPT Wed May 11 22:21:28 CEST 2016 x86_64 GNU/Linux
botsplash commented 7 years ago

Reffer this https://stackoverflow.com/questions/27341311/notimplementederror-use-label-to-access-a-node-label

WolfgangFahl commented 3 years ago

you might want to use the more recent https://github.com/somnathrakshit/geograpy3