Find similarities
The LESP library provides a method called get_similar()
that can be used to find similar words to a specified word. The method takes three parameters:
word
: The word to find similar words for.similarity_rate
: The minimum similarity score that a word must have to be considered similar. The similarity rate is a float between 0 and 1, where 0 means no similarity and 1 means perfect similarity.upto
: The maximum number of similar words to return.use_cache
: The switch for using cache before running the scan algorithm.set_cache
: The switch for adding the correction to cache after finding similarities.
The method returns a list of similar words, or None
if no similar words were found.
Example Usage
This code will print the following output:
Using the Cache
The LESP library can also use a cache to improve performance. The cache is a file that stores the results of previous calls to the get_similar()
method. This can save time, especially if you are calling the method frequently.
To use the cache, you need to set the use_cache
parameter to True
when calling the get_similar()
method. You can also set the set_cache
parameter to True
to save the results of the current call to the cache.
Example Usage
This code will print the following output:
Clearing the Cache
The cache can be cleared using the clear_cache()
method. This can be useful if you want to ensure that the results of the get_similar()
method are up-to-date.
Last updated