Commit 5194abdd authored by Sylvain Coulange's avatar Sylvain Coulange

amélioration sauts de ligne consécutifs, passage modèle md

parent 6c609627
......@@ -2,8 +2,8 @@ from django.shortcuts import render
from django.http import JsonResponse
import re, json, spacy
nlpFr = spacy.load('fr_core_news_lg')
nlpZh = spacy.load('zh_core_web_lg')
nlpFr = spacy.load('fr_core_news_md')
nlpZh = spacy.load('zh_core_web_md')
def home(request):
return render(request, 'coloriser.html')
......@@ -20,34 +20,27 @@ def runSpacy(request):
outText = []
for token in nlpText:
sdl = re.findall(r'\r\n',token.text)
for token in nlpText:
tokenInfo = {
"text": token.text,
"lemma": token.lemma_,
"pos": token.pos_,
"tag": token.tag_,
"dep": token.dep_,
"shape": token.shape_
}
print(tokenInfo)
outText.append(tokenInfo)
if len(sdl) > 0:
for s in sdl:
outText.append('§')
else:
tokenInfo = {
"text": token.text,
"lemma": token.lemma_,
"pos": token.pos_,
"tag": token.tag_,
"dep": token.dep_,
"shape": token.shape_
}
print(tokenInfo)
outText.append(tokenInfo)
if token.whitespace_:
outText.append({
"text": token.whitespace_,
"lemma": "",
"pos": "SPACE",
"tag": "SPACE",
"dep": "",
"shape": ""
})
if token.whitespace_:
outText.append({
"text": token.whitespace_,
"lemma": "",
"pos": "SPACE",
"tag": "SPACE",
"dep": "",
"shape": ""
})
rep = {
'outText': outText
......
......@@ -46,7 +46,13 @@ async function runSpacy() {
else col = pos[data.outText[i].pos].color;
// saut de ligne
if (data.outText[i].text == "\n") result = result + "<br>";
sdl = data.outText[i].text.split('\n');
if (sdl.length>1){
for (s in sdl) {
result = result + "<br>";
}
}
// if (data.outText[i].text == "\n") result = result + "<br>";
// espace
else if (data.outText[i].text == " ") result = result + "<span style='"+ stylesCommuns +"'> </span>";
......
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