flashtext icon indicating copy to clipboard operation
flashtext copied to clipboard

Incorrect Output in a specific scenario

Open ankurphutela opened this issue 5 years ago • 1 comments

Scenario -

Use Dictionary for multiple keywords and one keyword is present in more than one class/category, then, output is incorrect and shows only one class/category.

Below mentioned is example code for detailed explanation.

#Import library
from flashtext import KeywordProcessor

#Define Dictionary
dict_keywords={}

#'Russia' is present in both classes/categories - Europe and Asia 
dict_keywords["Europe"]=['France','Germany','Russia']
dict_keywords["Asia"]=['India','Russia','China']

keyword_processor = KeywordProcessor()
keyword_processor.add_keywords_from_dict(dict_keywords)

#Content has 'Russia' keyword
content="Russia is a federal semi-presidential republic"
flashtext_out=keyword_processor.extract_keywords(content)

print(flashtext_out)
#Output - ['Asia'] 
#Output should consist of both classes/categories - Asia and Europe

ankurphutela avatar Jan 10 '19 20:01 ankurphutela

@biswajitpatra - If the commit which you have done in your forked instance working fine, could you please create a pull request to this main repo so that this could be the part of release package which we can use

@vi3k6i5 - Could you please confirm if this can be merged into this primary repo?

Santhosh0505 avatar Nov 19 '20 06:11 Santhosh0505