Commit 4894a612 authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

sauts de ligne, points et virgules

parent 6686e82a
......@@ -18,6 +18,7 @@ class Entree:
result: list
nb: int
message: str
update: str
class commitData:
update: str
......
......@@ -3,6 +3,7 @@ from static.scripts import textPhonographer as txtphono
from .models import Phonograph, Data, Entree, commitData
import spacy
import subprocess
import re
nlp = spacy.load('fr')
def redirApp(request):
......@@ -17,21 +18,32 @@ def main(request):
data.update = updateTime()
data.pphh = []
punctuation = [',','.'] # ')',']','}','%','>',"'",'(','[','{'
for token in nlpText:
print("Mot en entrée :",token.text)
result = txtphono.mimi(token.text)
print(result)
phonographieList = []
for r in result:
phonographie = []
for i in r:
ph = Phonograph()
ph.phon = i[0]
ph.graph = i[1]
phonographie.append(ph)
phonographieList.append(phonographie)
data.pphh.append(phonographieList)
sdl = re.findall(r'\r\n',token.text)
print("sdl =",sdl)
if len(sdl) > 0:
for s in sdl:
print("Saut de ligne.")
data.pphh.append('§')
elif token.text in punctuation:
data.pphh.append(token.text)
else:
print("Mot en entrée :",token.text)
result = txtphono.mimi(token.text)
print(result)
phonographieList = []
for r in result:
phonographie = []
for i in r:
ph = Phonograph()
ph.phon = i[0]
ph.graph = i[1]
phonographie.append(ph)
phonographieList.append(phonographie)
data.pphh.append(phonographieList)
else:
data = Data()
data.text = ''
......@@ -54,6 +66,7 @@ def main0(request):
def dicoView(request):
data = Entree()
data.update = updateTime()
if request.POST.get('inMot') or request.POST.get('inTrans'):
data.mot = request.POST['inMot'] if request.POST.get('inMot') else ''
data.motcond = request.POST['condition-mot'] if request.POST.get('condition-mot') else 'contient'
......@@ -85,6 +98,7 @@ def editEntry(request,Type):
message = txtphono.delEntry(mot,trans)
data = Entree()
data.update = updateTime()
data.mot = searchMot
data.trans = searchTrans
data.motcond = condition_mot
......
......@@ -134,7 +134,7 @@ def mimi(mot):
r[k] = (tupl[0],cased)
return result
'''
def getEntryByWord(m,mc,t,tc):
m = m.replace("'",'’')
result = []
......@@ -152,14 +152,15 @@ def getEntryByWord(m,mc,t,tc):
if tc == 'finit par' or tc == 'est égal à':
tc2 = r'$'
for entree,trans in word2trans.items():
if re.match(mc1+m+mc2,entree) and re.match(tc1+t+tc2,trans):
yeah = Entree()
yeah.mot = entree
yeah.trans = word2trans[entree]
result.append(yeah)
for entree,transList in word2trans.items():
for i,trans in enumerate(transList):
if re.match(mc1+m+mc2,entree) and re.match(tc1+t+tc2,trans):
yeah = Entree()
yeah.mot = entree
yeah.trans = word2trans[entree][i]
result.append(yeah)
return result
'''
def modifEntry(motOrigin,mot,trans):
mot = mot.replace("'",'’')
if motOrigin != mot:
......
......@@ -27,11 +27,9 @@
<div class="win-black outputMainDiv">
<h2>Résultat :</h2>
<div class="output">
{% for token in data.pphh %}
<span class="tokens" id='tok{{ forloop.counter }}' onclick="changeAlign(this.id)"></span><span> </span>
{% endfor %}
</div>
<p class="output">
{% for token in data.pphh %}{% if token == "§" %}<br/>{% elif token in ",.)]}%>"|make_list %}<span class="phon_neutre">{{ token }}</span>{% else %} <span class="tokens" id='tok{{ forloop.counter }}' onclick="changeAlign(this.id)"></span>{% endif %}{% endfor %}
</p>
</div>
<div>
......@@ -45,13 +43,17 @@
<script type="text/javascript">
var dicoTok = {
{% for token in data.pphh %}
{% if token != "§" %}
'tok{{ forloop.counter }}' : [{% for trans in token %}'{% for entree in trans %}<span class="{{entree.phon}}">{{entree.graph}}</span>{% endfor %}',{% endfor %}],
{% endif %}
{% endfor %}
};
var dicoId = {
{% for token in data.pphh %}
{% if token != "§" %}
'tok{{ forloop.counter }}' : 0,
{% endif %}
{% endfor %}
}
......
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