WordFinder is a Python package designed to find words in a sentence with a given similarity threshold.
pip install word-finder- Python 3.x
- fuzzywuzzy
from word_finder import WordFinder
# Create an instance of WordFinder
word_finder = WordFinder("This is a sample sentence.")
# Find words in the sentence
result = word_finder.find_words(["example", "word"])
print(result) # Output: {'example'}Initializes a new instance of the WordFinder class.
sentence(str): The input sentence to be processed.
Cleans the input sentence by removing non-alphabetic characters and converting to lowercase.
Returns:
str: Cleaned sentence.
Finds words in the cleaned sentence that match the target words based on a similarity threshold.
Args:
target_words(list): List of target words to search for.similarity_threshold(int): Minimum similarity threshold (default is 80).
Returns:
set: Set of found words.
word_finder = WordFinder("This is a sample sentence.")
result = word_finder.find_words(["example", "word"])
print(result) # Output: {'example'}This project is licensed under the MIT License - see the LICENSE file for details.