Commit a7a36add authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

changement module checkWord >word2freq

parent 8b4cdb73
......@@ -81,7 +81,7 @@ def getLenDic(lang):
##### MISE EN MÉMOIRE DES DICTIONNAIRES (seulement les transcriptions+regions)
def makeWord2trans(alemDic):
query = alemDic.find()#.limit(1000)
query = alemDic.find()#.limit(100000)
word2trans = {}
cpt = 0
for q in query:
......@@ -423,13 +423,12 @@ def getEntryByWord(m,mc,t,tc,lang):
def checkIfWordExists(w,t,lang='fr'):
# Pour le Phonographe, renvoie objet : 'w':True si mot existe, 't':True si transcription existe, 'wt':True si ce mot avec cette trans existe
if lang == "fr":
w = w.replace("'",'’')
dico = dicoFr
dico = word2transFr
elif lang == "en":
w = w.replace('’',"'")
dico = dicoEn
dico = word2transEn
elif lang == "zh":
dico = dicoZh
dico = word2transZh
w = w.lower()
res= {
......@@ -438,21 +437,32 @@ def checkIfWordExists(w,t,lang='fr'):
'wt':False
}
searchW = dico.find({'w': w})
if len(w)>0:
if searchW.count()>0: res['w']=True;
if len(w)>0 and len(t)>0:
for x in searchW:
for y in x['t']:
if t == y['tt']:
res['wt']=True
for mot,transs in dico.items():
if mot == w:
res['w']=True;
for trans in transs['t']:
if trans['tt'].replace(".","") == t:
res['wt']=True
res['t']=True
break
for trans in transs['t']:
if trans['tt'].replace(".","") == t:
res['t']=True
if res['w']: break
if len(w)==0 and len(t)>0:
for mot,transs in dico.items():
for trans in transs['t']:
if trans['tt'].replace(".","") == t:
res['t']=True
break
if not res['wt'] and len(t)>0:
searchT = dico.find({'t.tt':t})
if searchT.count()>0: res['t']=True;
if len(w)>0 and len(t)==0:
for mot,transs in dico.items():
if mot == w:
res['w']=True;
break
return res
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment