Open gabyx opened 4 years ago
Hello @gabyx,
I can't think of a direct solution to your problem, but here is one solution which I can think of immediately and would help to solve your issue -
>>> from flashtext import KeywordProcessor
>>> keyword_processor = KeywordProcessor()
>>> keyword_dict = {'New York' : 'Big Apple', 'Trump' : 'Bay Area'}
>>> keyword_processor.add_keyword('Big Apple', 'New York')
>>> keyword_processor.add_keyword('Bay Area', 'Trump')
>>> keywords_found = keyword_processor.extract_keywords('I love big Apple and Bay Area.', span_info=True)
>>> [(keyword_dict.get(key[0]), key[1], key[2]) for key in keywords_found]
[('Big Apple', 7, 16), ('Bay Area', 21, 29)]
Kind Regards, Nandan Thakur
Its desirable to have a clue what was replaced and where, and also if any replacement happend at all.