vi3k6i5 / flashtext

Extract Keywords from sentence or Replace keywords in sentences.
MIT License
5.58k stars 598 forks source link

Fails to replace adjacent keywords with empty non-word boundaries #135

Open jamespicone opened 2 years ago

jamespicone commented 2 years ago

In this example:

test_replacer = KeywordProcessor(case_sensitive=True)
test_replacer.add_keyword("aa", "b")
test_replacer.add_keyword("cc", "d")
test_replacer.set_non_word_boundaries("")

teststring = "aacc"
replacedstring = test_replacer.replace_keywords(teststring)

print("Teststring:\n" + teststring)
print("Replacedstring:\n" + replacedstring)

I get this output:

Teststring:
aacc
Replacedstring:
bcc

I expect to get bd. Am I misunderstanding the intended behaviour, or is this a bug?