Search code examples
python-3.xgeograpy

Getting wrong results for country names using geograpy3


I tried running the example code as given in the readme file for geograpy3. However, I am getting answers like this. What can be done about it?

enter image description here


Solution

  • Your question raises a similar issue as https://github.com/somnathrakshit/geograpy3/issues/3

    There is now a get_geoPlace_context function that will limit the search to the GPE label of NLTK thus ignoring PERSON and ORGANIZATION entries as the orginal function get_place_context would do:

    see also test_extractor.py

     def testGetGeoPlace(self):
        '''
        test geo place handling
        '''
        url='http://www.bbc.com/news/world-europe-26919928'
        places=geograpy.get_geoPlace_context(url=url)
        if self.debug:
            print(places)
        self.assertEqual(['Moscow', 'Donetsk', 'Brussels', 'Kharkiv', 'Russia'],places.cities)