Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Pédagogies Multimodales
wikicolor
Commits
a7a36add
Commit
a7a36add
authored
Aug 01, 2022
by
Sylvain Coulange
🌼
Browse files
changement module checkWord >word2freq
parent
8b4cdb73
Changes
1
Hide whitespace changes
Inline
Side-by-side
colorapp/textPhonographer.py
View file @
a7a36add
...
...
@@ -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(1000
00
)
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
=
dico
En
dico
=
word2trans
En
elif
lang
==
"zh"
:
dico
=
dico
Zh
dico
=
word2trans
Zh
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment