Created
September 15, 2017 18:31
-
-
Save vi3k6i5/eebf91c643adfb1b38ae04a6c5d01e77 to your computer and use it in GitHub Desktop.
FlashText replace keyword example
This file contains 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
from flashtext.keyword import KeywordProcessor | |
keyword_processor = KeywordProcessor() | |
keyword_processor.add_keyword('Big Apple', 'New York') | |
keyword_processor.add_keyword('New Delhi', 'NCR region') | |
new_sentence = keyword_processor.replace_keywords('I love Big Apple and new delhi.') | |
new_sentence | |
# 'I love New York and NCR region.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment