diff --git a/bower.json b/bower.json index 69ace19..c097c8b 100644 --- a/bower.json +++ b/bower.json @@ -9,6 +9,6 @@ ], "dependencies": { "underscore": "*", - "flatui":"*" + "flatui":"v1.1" } } diff --git a/liaRest.py b/liaRest.py index 0bb4b52..bcc6b25 100644 --- a/liaRest.py +++ b/liaRest.py @@ -27,11 +27,6 @@ def cleaner(): # Returning a row text to be parse client side return unicode(taggedTable) -class OrkisService(enterprise.SOAPService): - @enterprise.soap(returns=enterprise._sp.String) - def get_phon(self): - return ctime() - if __name__ == '__main__': app.debug = True - app.run(host='0.0.0.0') + app.run(host='192.168.75.140',port=9001) diff --git a/liaSoap.py b/liaSoap.py index aa02eb6..8bfccc3 100644 --- a/liaSoap.py +++ b/liaSoap.py @@ -5,15 +5,18 @@ from spyne.model.primitive import Integer from spyne.model.primitive import Unicode from spyne.model.complex import Iterable from spyne.protocol.soap import Soap11 +from spyne.protocol.http import HttpRpc +from spyne.protocol.xml import XmlDocument from spyne.server.wsgi import WsgiApplication from processor.Orkis import Orkis - +import logging +logging.basicConfig() class getPhonService(ServiceBase): @srpc(Unicode, _returns=Unicode) def get_phon(string): orkis=Orkis(string) orkis.getDico() - return str(orkis) + return unicode(orkis) application = Application([getPhonService], tns='lia.tools.phon', @@ -27,5 +30,5 @@ if __name__ == '__main__': # supposed to use it in production. from wsgiref.simple_server import make_server - server = make_server('0.0.0.0', 8000, wsgi_app) + server = make_server('192.168.75.140', 9000, wsgi_app) server.serve_forever() diff --git a/processor/Orkis.py b/processor/Orkis.py index 3efb025..b59efbf 100644 --- a/processor/Orkis.py +++ b/processor/Orkis.py @@ -1,5 +1,7 @@ +# -*- coding: utf-8 -*- from BaseProcessor import baseProcessor import nltk +import re from LiaTools import * class Orkis(baseProcessor): """ Processor for Orkis """ @@ -8,20 +10,24 @@ class Orkis(baseProcessor): self.phoner=Phoner() self.dico ={} self.string=dirtyString + print self.string def isReady(self): self.phoner.isReady() self.tagger.isReady() - def __str__(self): - string="" + def __unicode__(self): + string = u"" for word in self.dico: - string += (word+';') + print(isinstance(string, unicode)) + print(isinstance(unicode(word.decode("utf-8")),unicode)) + print(word) + print(string) + string += ( unicode(word.decode("utf-8"))) for lemWord in self.dico[word][0]: - string += (lemWord+" ") - string +=";" + string += (unicode(lemWord.decode("utf-8"))) #+ unicode(u" ")) + string +=u";" for phonWord in self.dico[word][1]: - string += (phonWord+" ") - string += ';' - string+='\n' + string += (unicode(phonWord.decode("utf-8"))) #+ unicode(u" ")) + string+=u"\n" return string def clean(self): stopword=StopWord() @@ -31,24 +37,26 @@ class Orkis(baseProcessor): 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]) + if not re.match(r's>',line): + 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]) + if not re.match(r's>',line): + 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() table=[] for i in self.dico: - if not i == "": + if not re.match(r"",i): list=[] list.append(i) for indice in self.dico[i][0]: @@ -56,5 +64,6 @@ class Orkis(baseProcessor): for indice in self.dico[i][1]: list.append(indice) ligne= " ".join(list) + table.append(ligne) return "\n".join(table)