-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimiliar.py
More file actions
53 lines (41 loc) · 1.01 KB
/
similiar.py
File metadata and controls
53 lines (41 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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"]
"""
color yellow
asjdhaj askfjkas fsfkajfk
\n
"""
word, accuracy = find_similar("nitrte", dataset)
print("Given word -> ", "nitrte")
print("result ->")
print(word, accuracy)