Created
March 10, 2021 16:54
-
-
Save amireshoon/3d15e8942953bc8ad6988cd7f0804271 to your computer and use it in GitHub Desktop.
Get similar word from a given word
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rapidfuzz import fuzz | |
import operator | |
""" | |
this function return similar value for given string with given dataset | |
first returned value will be similar word | |
seccond value is accuracy | |
""" | |
def find_similar(search_for, dataset): | |
res = [] | |
for data in dataset: | |
res.append(fuzz.ratio(search_for, data)) | |
i, v = max(enumerate(res), key=operator.itemgetter(1)) | |
yield dataset[i] | |
yield v | |
dataset = [ "Appereance", | |
"color", | |
"Specifie Gravity", | |
"PH", | |
"Protein", | |
"Glucose", | |
"Keton", | |
"Blood", | |
"Bilirubin", | |
"Urobilinogen", | |
"Nitrite", | |
"RBC/hpf", | |
"WBC/hpf", | |
"Epithelial cells/Lpf", | |
"EC/Lpf", | |
"Bacteria", | |
"Casts", | |
"Mucous"] | |
word, accuracy = find_similar("colr", dataset) | |
print(word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment