merge-gui #4
|
@ -1,45 +0,0 @@
|
||||||
import jaro
|
|
||||||
import json
|
|
||||||
|
|
||||||
# Load database
|
|
||||||
print("Loading database ...")
|
|
||||||
with open("Code/data.json", "r") as file:
|
|
||||||
database = json.loads(file.read())
|
|
||||||
|
|
||||||
|
|
||||||
prompt = input("name > ")
|
|
||||||
tokens = prompt.split()
|
|
||||||
|
|
||||||
# Finding possible words index
|
|
||||||
possible_words = []
|
|
||||||
|
|
||||||
for t in tokens:
|
|
||||||
found_words = []
|
|
||||||
for w in database["lexique"]["index"].keys():
|
|
||||||
if jaro.jaro_winkler_metric(w, t) > 0.93:
|
|
||||||
index = database["lexique"]["index"][w]
|
|
||||||
if index not in found_words:
|
|
||||||
found_words.append(index)
|
|
||||||
if found_words:
|
|
||||||
possible_words.append(found_words)
|
|
||||||
|
|
||||||
print(possible_words)
|
|
||||||
|
|
||||||
# Test every formation
|
|
||||||
to_test = []
|
|
||||||
test_passed = []
|
|
||||||
|
|
||||||
for f in database["formations"].keys():
|
|
||||||
checked_count = 0
|
|
||||||
for ti in database["formations"][f]["recW"].keys():
|
|
||||||
for found_index in possible_words:
|
|
||||||
if int(ti) in found_index:
|
|
||||||
checked_count += 1
|
|
||||||
break
|
|
||||||
if checked_count == len(possible_words):
|
|
||||||
test_passed.append(f)
|
|
||||||
|
|
||||||
|
|
||||||
# Print the result
|
|
||||||
for f in test_passed:
|
|
||||||
print(database["formations"][f]["nm"], "at :", list(database["formations"][f]["recS"].keys())[1])
|
|
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 8.1 KiB |
Loading…
Reference in a new issue