我正在尝试从文本中提取城市名称,因此我使用的是带有Python的Geograpy库,但在输出中,提取了其他一些名称。这是我的代码:
from geograpy.extraction import Extractor
text6 = u"""Some text..."""
e6 = Extractor(text=text6)
e6.find_entities()
print(e6.places)
输入文本: -
反对党领袖Mahinda Rajapaksa说整个公众 由于宪法委员会的 任意行动。反对党领袖对 查询在举行会议之后提出的日记期...
输出
['Opposition', 'Leader Mahinda Rajapaksa', 'Opposition Leader']
此文本中没有任何城市名称,因此输出shold为空
作为geograpy的参数3 https://github.com/somnathrakshit/geograpy/geograpy3/blob/master/master/tests/test_extractor.py.py.py.py.py.py.py3 https://github.com/somnathrakshit/gy.py.py.py3 https://github.com/somnathrakshit/test_extractor.py.py.py.py.py.pecrapy3。:并添加了问题:
https://github.com/somnathrakshit/geograpy3/issues/3用:这个提交
现在结果是:
[]
要求
def testStackoverflow54712198(self):
'''
see https://stackoverflow.com/questions/54712198/not-only-extracting-places-from-a-text-but-also-other-names-in-geograpypython
'''
text='''Opposition Leader Mahinda Rajapaksa says that the whole public administration has collapsed due to the constitution council’s arbitrary actions. The Opposition Leader said so in response to a query a journalised raised after a meeting held...'''
e=Extractor(text)
places=e.find_geoEntities()
if self.debug:
print(places)
self.assertEqual([],places)