taleinat / fuzzysearch

Find parts of long text or data, allowing for some changes/typos.
MIT License
301 stars 26 forks source link

Return matched string #16

Closed spooknik closed 4 years ago

spooknik commented 4 years ago

Hello!

Thank you very much for the software. However I have one suggestion if I may:

I'm using fuzzysearch for finding text substrings inside of strings so I can find and replace things fuzzy. For example:

term = "Colors"
text = "There are seven colours in a rainbow."
(find_near_matches(term, text, max_l_dist=2))
print(find_near_matches(term, text, max_l_dist=2))

[Match(start=17, end=23, dist=2)]

I understand this maybe isn't the use case you had in mind, but It would be really handy if the function could just return the matched string, in this case 'colours ' Then replacement of the substring in the string would be easy via the replace function.

taleinat commented 4 years ago

Hi @spooknik! I'm happy fuzzysearch is useful for you.

Indeed, I've been meaning to add the matched sub-sequence to Match objects, just as you suggest. I hope to get to this soon.

spooknik commented 4 years ago

Thanks for the reply.

That sounds good, look forward to trying it out 👍

taleinat commented 4 years ago

Added in v0.7.0.