Skip to content

Instantly share code, notes, and snippets.

@vi3k6i5
Created September 15, 2017 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vi3k6i5/eebf91c643adfb1b38ae04a6c5d01e77 to your computer and use it in GitHub Desktop.
Save vi3k6i5/eebf91c643adfb1b38ae04a6c5d01e77 to your computer and use it in GitHub Desktop.
FlashText replace keyword example
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