Skip to content
GitLab
Menu
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
d90b92a6
Commit
d90b92a6
authored
Nov 08, 2020
by
Sylvain Coulange
Browse files
ajout api getPhonoOf pour PhonoGraphe
parent
819ed066
Changes
3
Hide whitespace changes
Inline
Side-by-side
colorapp/views.py
View file @
d90b92a6
...
...
@@ -59,6 +59,58 @@ def colorize(request):
}
return
JsonResponse
(
rep
)
def
getPhonoOf
(
request
):
# Renvoie une liste(texte) de listes(phonographiesPossibles) de listes(phonographie) de phonèmes à partir d'un mot ou d'une expression
# ex. input="chat" → output=[[[phon_s_maj, phon_a], [phon_ts_maj, phon_a, phon_t]]]
# ex. input="le chat" → output= [
# [
# [phon_l,phon_2],
# [phon_e_maj,phon_l,phon_2]
# ],
# [
# [phon_s_maj, phon_a],
# [phon_ts_maj, phon_a, phon_t]
# ]
# ]
colis
=
json
.
loads
(
request
.
body
)
text
=
colis
[
'inText'
]
lang
=
colis
[
'lang'
]
if
lang
==
"fr"
:
nlpText
=
nlpFr
(
text
)
elif
lang
==
"en"
:
nlpText
=
nlpEn
(
text
)
outPhono
=
[]
for
token
in
nlpText
:
sdl
=
re
.
findall
(
r
'\r\n'
,
token
.
text
)
print
(
"sdl ="
,
sdl
)
if
len
(
sdl
)
>
0
:
for
s
in
sdl
:
print
(
"Saut de ligne."
)
outText
.
append
(
'§'
)
else
:
print
(
"Mot en entrée :"
,
token
.
text
)
if
lang
==
"en"
:
result
=
txtphono
.
mimi
(
token
.
text
,
lang
)
else
:
result
=
txtphono
.
mimi
(
token
.
text
,
lang
)
print
(
result
)
phonographieList
=
[]
for
r
in
result
:
phonoliste
=
[]
for
i
in
r
[
0
]:
phonoliste
.
append
(
i
[
0
])
phonographieList
.
append
(
phonoliste
)
outPhono
.
append
(
phonographieList
)
rep
=
{
'outText'
:
outPhono
}
return
JsonResponse
(
rep
)
def
updateTime
():
upd
=
str
(
subprocess
.
check_output
([
"git"
,
"log"
,
"-1"
,
"--format=%cd"
,
"--date=short"
]))
#ver = str(subprocess.check_output(["git", "rev-list", "--all", "--count"]))
...
...
coloriseur/settings.py
View file @
d90b92a6
...
...
@@ -31,11 +31,13 @@ ALLOWED_HOSTS = ['127.0.0.1','wikicolor-preprod.alem-app.fr','wikicolor.alem-app
CORS_ORIGIN_ALLOW_ALL
=
False
CORS_ALLOWED_ORIGINS
=
[
"http://127.0.0.1:7000"
,
"http://82.64.20.170:8000"
,
"http://127.0.0.1:8000"
,
"http://phonographe.alem-app.fr"
]
CSRF_TRUSTED_ORIGINS
=
[
"http://127.0.0.1:7000"
,
"http://82.64.20.170:8000"
,
"http://127.0.0.1:8000"
,
"http://phonographe.alem-app.fr"
]
...
...
coloriseur/urls.py
View file @
d90b92a6
...
...
@@ -15,20 +15,22 @@ Including another URLconf
"""
from
django.contrib
import
admin
from
django.urls
import
path
from
colorapp
.views
import
main
,
colorize
,
redirApp
,
dicoView
,
editEntry
,
newEntry
,
supprEntry
,
dicoReq
,
getLog
from
colorapp
import
views
as
colorapp_views
from
django.views.decorators.csrf
import
csrf_exempt
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'app/'
,
redirApp
),
path
(
''
,
main
),
path
(
'en/'
,
main
),
path
(
'fr/'
,
main
),
path
(
'colorize/'
,
csrf_exempt
(
colorize
)),
path
(
'app/dico/'
,
dicoView
),
path
(
'dicoSearch/'
,
dicoReq
),
path
(
'modifEntry/'
,
editEntry
),
path
(
'addEntry/'
,
newEntry
),
path
(
'delEntry/'
,
supprEntry
),
path
(
'getLog/'
,
getLog
)
path
(
'app/'
,
colorapp_views
.
redirApp
),
path
(
''
,
colorapp_views
.
main
),
path
(
'en/'
,
colorapp_views
.
main
),
path
(
'fr/'
,
colorapp_views
.
main
),
path
(
'colorize/'
,
csrf_exempt
(
colorapp_views
.
colorize
)),
path
(
'getPhonoOf/'
,
csrf_exempt
(
colorapp_views
.
getPhonoOf
)),
#path('getAllPhonographiesOf/', csrf_exempt(colorapp_views.getAllPhonographiesOf)),
path
(
'app/dico/'
,
colorapp_views
.
dicoView
),
path
(
'dicoSearch/'
,
colorapp_views
.
dicoReq
),
path
(
'modifEntry/'
,
colorapp_views
.
editEntry
),
path
(
'addEntry/'
,
colorapp_views
.
newEntry
),
path
(
'delEntry/'
,
colorapp_views
.
supprEntry
),
path
(
'getLog/'
,
colorapp_views
.
getLog
)
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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