Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

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

ajout api getPhonoOf pour PhonoGraphe

parent 819ed066
......@@ -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"]))
......
......@@ -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"
]
......
......@@ -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)
]
Markdown is supported
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