Skip to content

An efficient python tool to search keywords in texts.

License

Notifications You must be signed in to change notification settings

thomasperrot/speed-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpeedFinder

Build Status

An efficient python tool to search keywords in texts.

It currently runs in O(n x log(m)), where n is the length of the text and m is the number of keywords.

Usage

>>> keywords = ['jam', 'ham', 'chicken']
>>> speed_finder = SpeedFinder(keywords)
>>> text = "I love donuts, jam, ham, bananas, chicken and beer."
>>> list(speed_finder.find_iter(text))
[(15, 'jam'), (20, 'ham'), (34, 'chicken')]
>>> list(speed_finder.find_iter(text, limit=2))
[(15, 'jam'), (20, 'ham')]
>>> text = "I love donuts, jams, ham, bananas, chickens and beer."
>>> list(speed_finder.find_iter(text, match_words=True))
[(21, 'ham')]
>>> speed_finder.add('bananas')
>>> list(speed_finder.find_iter(text, match_words=True))
[(21, 'ham'), (26, 'bananas')]

About

An efficient python tool to search keywords in texts.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages