flashtext
flashtext copied to clipboard
Unable to use flashtext to remove keywords
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?
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
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'
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'.