vi3k6i5 / flashtext

Extract Keywords from sentence or Replace keywords in sentences.
MIT License
5.58k stars 598 forks source link

FeatureRequest : get the nearby context #100

Closed pcakhilnadh closed 4 years ago

pcakhilnadh commented 4 years ago

Hi,

I would like to request for a simple handy feature that will extract the nearby context of the word extracted .

Suppose,

keyword_processor.add_keyword('Python')
keyword_processor.extract_keywords(" Respected sir, My Name is Akhil and I love doing python programming. I am from India completed my masters degree in CSE")
>>  [Akhil , Python]  or [My Name is Akhil and I love doing python programming]
thakur-nandan commented 4 years ago

Hi @itzpc,

Unfortunately, due to the trie structure of the implementation of flashtext, It can extract the keyword Python from the text and replace it with metadata provided for Python. It does not extract the nearby context of the word. It merely searches over the text character by character to gives out the list of keywords extracted if found in the trie dictionary.

For extracting the nearby context of the word, I would suggest you find some other python-packages/algorithms which solve your use-case.

Many Regards, Nandan Thakur