Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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.')
# '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