Open SamShowalter opened 5 years ago
EDIT: The system appears to do this already. I just want to verify this is the case.
`from flashtext import KeywordProcessor keyword_processor = KeywordProcessor() keyword_processor.add_keyword('I Love New York', 'ILNY') keyword_processor.add_keyword("New York", "NYC") keyword_processor.add_keyword("I Love", "ILY")
keyword_processor.replace_keywords("This is true, I Love I Love New York New York and everything else")`
Output: 'This is true, ILY ILNY NYC and everything else'
Yes so longest match is preferred.
On Mon, Mar 18, 2019, 10:02 PM Sam Showalter notifications@github.com wrote:
EDIT: The system appears to do this already. I just want to verify this is the case.
`from flashtext import KeywordProcessor keyword_processor = KeywordProcessor() keyword_processor.add_keyword('I Love New York', 'ILNY') keyword_processor.add_keyword("New York", "NYC") keyword_processor.add_keyword("I Love", "ILY")
keyword_processor.replace_keywords("This is true, I Love I Love New York New York and everything else")`
Output: 'This is true, ILY ILNY NYC and everything else'
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vi3k6i5/flashtext/issues/76#issuecomment-473992484, or mute the thread https://github.com/notifications/unsubscribe-auth/AC-Nwsb47H4utmDgmY2ZOpq9I2e5JMBIks5vX79_gaJpZM4b6Ox- .
Is there a way to set the priority of string replacements? Could I do something that could preference longer replacements (e.g. "I Love New York" -> "ILNY" v. "New York" -> "NYC") over shorter ones? How can I incorporate this flexibility?