Created
September 15, 2017 18:38
-
-
Save vi3k6i5/eabca9de9853e523d142beed46654d4e to your computer and use it in GitHub Desktop.
FlashText extract keywords from sentence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install flashtext | |
from flashtext.keyword import KeywordProcessor | |
keyword_processor = KeywordProcessor() | |
keyword_processor.add_keyword('Big Apple', 'New York') | |
keyword_processor.add_keyword('Bay Area') | |
keywords_found = keyword_processor.extract_keywords('I love Big Apple and Bay Area.') | |
keywords_found | |
# ['New York', 'Bay Area'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please correct me If I'm wrong, Here is my doubt:
The program outputs ['New York', 'Bay Area'] where New York is not in the given string.
keyword_processor.add_keywords_from_list(['Big Apple', 'New York']) results in correct output.