-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_names.py
173 lines (140 loc) · 5.15 KB
/
all_names.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
from libindic.soundex import Soundex
import fuzzy
import jellyfish
import csv
import itertools
from fuzzywuzzy import fuzz
names = [line.strip() for line in open("names.txt", 'r')]
fieldnames = ['Name1', 'Name2', 'Output']
libindic_results_csv = open('libindic_results.csv', 'w', newline='')
libindic_writer = csv.DictWriter(libindic_results_csv, fieldnames=fieldnames)
libindic_writer.writeheader()
jellyfish_match_rating_results_csv = open('jellyfish_match_rating_results.csv', 'w', newline='')
jellyfish_match_rating_writer = csv.DictWriter(jellyfish_match_rating_results_csv, fieldnames=fieldnames)
jellyfish_match_rating_writer.writeheader()
jellyfish_soundex_results_csv = open('jellyfish_soundex_results.csv', 'w', newline='')
jellyfish_soundex_writer = csv.DictWriter(jellyfish_soundex_results_csv, fieldnames=fieldnames)
jellyfish_soundex_writer.writeheader()
fuzzy_nysiis_results_csv = open('fuzzy_nysiis_results.csv', 'w', newline='')
fuzzy_nysiis_writer = csv.DictWriter(fuzzy_nysiis_results_csv, fieldnames=fieldnames)
fuzzy_nysiis_writer.writeheader()
fuzzy_dmeta_results_csv = open('fuzzy_dmeta_results.csv', 'w', newline='')
fuzzy_dmeta_writer = csv.DictWriter(fuzzy_dmeta_results_csv, fieldnames=fieldnames)
fuzzy_dmeta_writer.writeheader()
levenshtine_results_csv = open('levenshtine_results.csv', 'w', newline='')
levenshtine_writer = csv.DictWriter(levenshtine_results_csv, fieldnames=fieldnames)
levenshtine_writer.writeheader()
def libindic_isEqual(name1, name2):
instance = Soundex()
if instance.soundex(name1) == instance.soundex(name2):
return 1
else:
return 0
def jellyfish_match_rating_isEqual(name1, name2):
if jellyfish.match_rating_codex(name1) == jellyfish.match_rating_codex(name2):
return 1
else:
return 0
def jellyfish_soundex_isEqual(name1, name2):
if jellyfish.soundex(name1) == jellyfish.soundex(name2):
return 1
else:
return 0
def fuzzy_nysiis_isEqual(name1, name2):
if fuzzy.nysiis(name1) == fuzzy.nysiis(name2):
return 1
else:
return 0
def fuzzy_dmeta_isEqual(name1, name2):
dmeta = fuzzy.DMetaphone()
if dmeta(name1)[0] == dmeta(name2)[0] or dmeta(name1)[0] == dmeta(name2)[1] or dmeta(name1)[1] == dmeta(name2)[0]:
return 1
else:
return 0
def levenshtine_isEqual(str1, str2):
ratio = fuzz.ratio(str1.lower(),str2.lower())
if ratio >= 75:
return 1
else:
return 0
for name1, name2 in itertools.combinations(names, 2):
if name1 != name2:
libindic_writer.writerow({'Name1': name1, 'Name2': name2, 'Output': libindic_isEqual(name1, name2)})
jellyfish_match_rating_writer.writerow({'Name1': name1, 'Name2': name2, 'Output': jellyfish_match_rating_isEqual(name1, name2)})
jellyfish_soundex_writer.writerow({'Name1': name1, 'Name2': name2, 'Output': jellyfish_soundex_isEqual(name1, name2)})
fuzzy_nysiis_writer.writerow({'Name1': name1, 'Name2': name2, 'Output': fuzzy_nysiis_isEqual(name1, name2)})
fuzzy_dmeta_writer.writerow({'Name1': name1, 'Name2': name2, 'Output': fuzzy_dmeta_isEqual(name1, name2)})
levenshtine_writer.writerow({'Name1': name1, 'Name2': name2, 'Output': levenshtine_isEqual(name1, name2)})
libindic_results_csv.close()
jellyfish_match_rating_results_csv.close()
jellyfish_soundex_results_csv.close()
fuzzy_nysiis_results_csv.close()
fuzzy_dmeta_results_csv.close()
levenshtine_results_csv.close()
print("dmeta")
dmeta = fuzzy.DMetaphone()
print(dmeta('Amin'))
print(dmeta('Joumana'))
'''
print(jellyfish.soundex("nasah"))
print(jellyfish.soundex("ynsuoh"))
print(jellyfish.soundex("massuh"))
print(jellyfish.soundex("neisuoh"))
print(jellyfish.soundex("nassah"))
print(jellyfish.soundex("ayensuoh"))
print(jellyfish.soundex("anuossah"))
print(jellyfish.match_rating_codex("Hussam"))
print(jellyfish.match_rating_codex("Hussam Hallak"))
print(jellyfish.match_rating_codex("HussamHallak"))
print(jellyfish.match_rating_codex("Hussam Aldeen"))
print(jellyfish.match_rating_codex("Hussam Aldeen Hallak"))
print(jellyfish.match_rating_codex("Ahmed"))
print(jellyfish.match_rating_codex("Sami"))
print(compareNames("Hussam", "Hasan"))
print(compareNames("Hasan", "Housny"))
print(compareNames("Hasan", "Housien"))
print(compareNames("Hassan", "Housneya"))
print(compareNames("Hasan", "Hassan"))
print("nysiis")
print(fuzzy.nysiis('nasah'))
print(fuzzy.nysiis('ynsuoh'))
print(fuzzy.nysiis('massuh'))
print(fuzzy.nysiis('neisuoh'))
print(fuzzy.nysiis('nassah'))
print(fuzzy.nysiis('ayensuoh'))
print(fuzzy.nysiis('anuossah'))
print("dmeta")
dmeta = fuzzy.DMetaphone(8)
print(dmeta('Hasan'))
print(dmeta('Housny'))
print(dmeta('Hussam'))
print(dmeta('Housien'))
print(dmeta('Hassan'))
print(dmeta('Housneya'))
print(dmeta('Hassouna'))
print("dmeta")
dmeta = fuzzy.DMetaphone(5)
print(dmeta('nasah'))
print(dmeta('ynsuoh'))
print(dmeta('massuh'))
print(dmeta('neisuoh'))
print(dmeta('nassah'))
print(dmeta('ayensuoh'))
print(dmeta('anuossah'))
print("soundex")
soundex = fuzzy.Soundex(4)
print(soundex('Hasan'))
print(soundex('Hassan'))
print("dmeta")
dmeta = fuzzy.DMetaphone()
print(dmeta('Hasan'))
print(dmeta('Hassan'))
print(jellyfish.soundex(u'Jellyfish'))
def libindic_compareNames(name1, name2):
instance = Soundex()
if instance.compare(name1, name2) in [0,1, 2]:
return 1
else:
return 0
print("dmeta")
'''