Commit 0683b5e5 authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

enregistrement automatique des bugs alignement

parent 60989fea
......@@ -85,7 +85,7 @@ function bugMark() {
for (i = 0; i < bugs.length; i++) {
var newMark = document.createElement('span');
newMark.classList = 'glyphicon glyphicon-flash bugMark';
newMark.title = "Colorisation impossible !";
newMark.title = "Colorisation impossible ! L'erreur a été signalée.";
bugs[i].parentNode.insertBefore(newMark,bugs[i].nextSibling);
};
}
......
......@@ -32,6 +32,7 @@ phonColFile = "../phon2graph/data/class2api.json"
phonGraphFile = "../phon2graph/data/fidel_wikicolor.scsv" # "../phon2graph/data/phoneme-graphies_fr.scsv"
dicFile = "../wikiphon/dico_frwiktionary-20200301_v2.json"
logFile = "../logs/dico_frwiktionary-20200301_v2.log"
logBugFile = "../logs/wikicolor-bug.log"
# LECTURE DU CODE PHONEME-COULEUR
with open(phonColFile,"r") as phonFile:
......@@ -73,11 +74,20 @@ with open(dicFile, 'r') as f:
word2trans = json.load(f)
print('len frwiki :',len(word2trans))
# LECTURE DU LOG
# LECTURE DES LOG
logDic = {}
with open(logFile, 'r') as logf:
logDic = json.load(logf)
cptEdit = 0
for i,j in logDic.items():
for k in j:
cptEdit+=1
print("Nombre de modifications du dictionnaire :",cptEdit)
logBug = {}
with open(logBugFile, 'r') as logf:
logBug = json.load(logf)
print("Nombre de bug d'alignement enregistrés :",len(logBug))
def mimi(mot):
# Enregistrement de la casse
......@@ -100,7 +110,11 @@ def mimi(mot):
transList = word2trans[mot]
result = []
for trans in transList:
result.append(decoupage(mot,trans,phon2graph,phon2class))
res = decoupage(mot,trans,phon2graph,phon2class)
result.append(res)
for graphie in res:
if re.match(r'phon\_echec',graphie[0]):
writeLogBugs(mot)
else:
print("'", mot, "' non trouvé !")
result = [[('phon_inconnu',mot)]]
......@@ -208,6 +222,17 @@ def writeLog(Type,user,mot,oldTransList,newTransList):
os.replace(tmp.name, logFile)
print("Log file updated.")
def writeLogBugs(mot):
now = datetime.datetime.now()
date = "{}-{}-{} {}:{}:{}".format(now.year, now.month, now.day, now.hour, now.minute, now.second)
logBug[mot] = date
with tempfile.NamedTemporaryFile(dir='.', delete=False, mode="w") as tmp:
json.dump(logBug, tmp, ensure_ascii=False, indent=4)
os.replace(tmp.name, logBugFile)
print("Log file updated.")
'''
......
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