diff --git a/processor/Orkis.py b/processor/Orkis.py new file mode 100644 index 0000000..bd5131d --- /dev/null +++ b/processor/Orkis.py @@ -0,0 +1,37 @@ +from BaseProcessor import baseProcessor +import nltk +from LiaTools import * +class Orkis(baseProcessor): + """ Processor for Orkis """ + def __init__(self,dirtyString): + self.tagger=Tagger() + self.phoner=Phoner() + self.dico ={} + self.string=dirtyString + def isReady(self): + self.phoner.isReady() + self.tagger.isReady() + def clean(self): + stopword=StopWord() + self.string=stopword.RemoveStopList(self.string) + def insertLem(self): + self.cleanString=self.tagger.clean(self.string) + taggedString=self.tagger.tagg(self.cleanString) + self.tableLem = taggedString.rstrip().split("\n") + for line in taggedString.rstrip().split("\n"): + table = line.rstrip().split(" ") + if not table[0] in self.dico : + self.dico[table[0]]=[set(),set()] + self.dico[table[0]][0].add(table[2]) + def insertPhon(self): + phonedString=self.phoner.phon(self.cleanString) + self.tablephon= phonedString.rstrip().split("\n") + for line in phonedString.rstrip().split("\n"): + table = line.rstrip().split(" ") + if table[0] in self.dico: + self.dico[table[0]][1].add(table[1]) + def getDico(self): + self.clean() + self.insertLem() + self.insertPhon() + return self.dico diff --git a/static/js/application.js b/static/js/application.js index 0b7fbdb..b165cca 100644 --- a/static/js/application.js +++ b/static/js/application.js @@ -15,7 +15,7 @@ $('#go').click(function(){ data: data, success: function(data){ result=$('#result'); - result.append(_.escape(data)); + result.html(_.escape(data)); console.log(_.escape(data)); console.log("resultat"); }, diff --git a/webtagger.py b/webtagger.py index 9483a51..ffc085e 100644 --- a/webtagger.py +++ b/webtagger.py @@ -4,6 +4,7 @@ import os import json from flask import Flask, request, render_template from processor.LiaTools import * +from processor.Orkis import Orkis app = Flask(__name__) @app.route("/") @@ -12,24 +13,15 @@ def docs(): @app.route("/tagger",methods=['POST']) def cleaner(): - # Charging Processor et check if they are okay ( aim is to dynamic charge later ) - tagger = Tagger() - tagger.isReady() - phoner = Phoner() - phoner.isReady() - stoplist = StopWord() - stoplist.isReady() # Receive String from post parametre Raw text dirtyString= request.values[u'string'] + # Charging Processor et check if they are okay ( aim is to dynamic charge later ) + orkisProc = Orkis(dirtyString) # Processing - dirtyString = stoplist.RemoveStopList(dirtyString) - lemm = tagger.lemm(tagger.clean(dirtyString)) # Adding lemm of each words cause we went ther phonem too - dirtyString = dirtyString+" "+ lemm - cleanString= phoner.clean(dirtyString) - taggedString= phoner.phon(cleanString) + taggedTable= orkisProc.getDico() # Returning a row text to be parse client side - return taggedString + return unicode(taggedTable) if __name__ == '__main__': app.debug = True app.run(host='0.0.0.0')