flashtext icon indicating copy to clipboard operation
flashtext copied to clipboard

Unable to use flashtext to remove keywords

Open illuminatio opened this issue 5 years ago • 3 comments

kwp = KeywordProcessor()
kwp.add_keyword('<br>', '')
kwp.replace('one<br>two')

As a result I get an unchanged string. Is there a way to use flashtext to remove keywords from the text?

illuminatio avatar Oct 08 '18 08:10 illuminatio

in the doc you can find something like this:

Characters that will determine if the word is continuing. Defaults to set([A-Za-z0-9_])

special character is not supported at the moment

JusticeN avatar Dec 04 '18 10:12 JusticeN

you can also use the add_non_boundary method to add you special chars like this. also make sur to give a not empty clean name. instead of kwp.add_keyword('<br>', '') give somthing else as clean name like kwp.add_keyword('<br>', 'test') this work for me see the example below

kwp = KeywordProcessor()
kwp.add_non_word_boundary('<')
kwp.add_non_word_boundary('>')
kwp.add_keyword('<br>', 'test')
kwp.replace('one<br>two')

results: 'one test two'

JusticeN avatar Dec 04 '18 10:12 JusticeN

also make sur to give a not empty clean name

But that's not what I want. I want to have result 'onetwo', not 'one something two'. Or at least 'one two'.

illuminatio avatar Dec 12 '18 15:12 illuminatio