Commit b65eb4cd1193644c6acccd43944e3d64c7737022
1 parent
9ffd72ac16
Exists in
soap
ajout des port Orkis + modification Crade UTF-8 Orkis a reparer
Showing 4 changed files with 33 additions and 26 deletions Side-by-side Diff
bower.json
liaRest.py
... | ... | @@ -27,12 +27,7 @@ |
27 | 27 | # Returning a row text to be parse client side |
28 | 28 | return unicode(taggedTable) |
29 | 29 | |
30 | -class OrkisService(enterprise.SOAPService): | |
31 | - @enterprise.soap(returns=enterprise._sp.String) | |
32 | - def get_phon(self): | |
33 | - return ctime() | |
34 | - | |
35 | 30 | if __name__ == '__main__': |
36 | 31 | app.debug = True |
37 | - app.run(host='0.0.0.0') | |
32 | + app.run(host='192.168.75.140',port=9001) |
liaSoap.py
... | ... | @@ -5,15 +5,18 @@ |
5 | 5 | from spyne.model.primitive import Unicode |
6 | 6 | from spyne.model.complex import Iterable |
7 | 7 | from spyne.protocol.soap import Soap11 |
8 | +from spyne.protocol.http import HttpRpc | |
9 | +from spyne.protocol.xml import XmlDocument | |
8 | 10 | from spyne.server.wsgi import WsgiApplication |
9 | 11 | from processor.Orkis import Orkis |
10 | - | |
12 | +import logging | |
13 | +logging.basicConfig() | |
11 | 14 | class getPhonService(ServiceBase): |
12 | 15 | @srpc(Unicode, _returns=Unicode) |
13 | 16 | def get_phon(string): |
14 | 17 | orkis=Orkis(string) |
15 | 18 | orkis.getDico() |
16 | - return str(orkis) | |
19 | + return unicode(orkis) | |
17 | 20 | |
18 | 21 | application = Application([getPhonService], |
19 | 22 | tns='lia.tools.phon', |
... | ... | @@ -27,6 +30,6 @@ |
27 | 30 | # supposed to use it in production. |
28 | 31 | from wsgiref.simple_server import make_server |
29 | 32 | |
30 | - server = make_server('0.0.0.0', 8000, wsgi_app) | |
33 | + server = make_server('192.168.75.140', 9000, wsgi_app) | |
31 | 34 | server.serve_forever() |
processor/Orkis.py
1 | +# -*- coding: utf-8 -*- | |
1 | 2 | from BaseProcessor import baseProcessor |
2 | 3 | import nltk |
4 | +import re | |
3 | 5 | from LiaTools import * |
4 | 6 | class Orkis(baseProcessor): |
5 | 7 | """ Processor for Orkis """ |
6 | 8 | |
7 | 9 | |
8 | 10 | |
9 | 11 | |
... | ... | @@ -8,20 +10,24 @@ |
8 | 10 | self.phoner=Phoner() |
9 | 11 | self.dico ={} |
10 | 12 | self.string=dirtyString |
13 | + print self.string | |
11 | 14 | def isReady(self): |
12 | 15 | self.phoner.isReady() |
13 | 16 | self.tagger.isReady() |
14 | - def __str__(self): | |
15 | - string="" | |
17 | + def __unicode__(self): | |
18 | + string = u"" | |
16 | 19 | for word in self.dico: |
17 | - string += (word+';') | |
20 | + print(isinstance(string, unicode)) | |
21 | + print(isinstance(unicode(word.decode("utf-8")),unicode)) | |
22 | + print(word) | |
23 | + print(string) | |
24 | + string += ( unicode(word.decode("utf-8"))) | |
18 | 25 | for lemWord in self.dico[word][0]: |
19 | - string += (lemWord+" ") | |
20 | - string +=";" | |
26 | + string += (unicode(lemWord.decode("utf-8"))) #+ unicode(u" ")) | |
27 | + string +=u";" | |
21 | 28 | for phonWord in self.dico[word][1]: |
22 | - string += (phonWord+" ") | |
23 | - string += ';' | |
24 | - string+='\n' | |
29 | + string += (unicode(phonWord.decode("utf-8"))) #+ unicode(u" ")) | |
30 | + string+=u"\n" | |
25 | 31 | return string |
26 | 32 | def clean(self): |
27 | 33 | stopword=StopWord() |
28 | 34 | |
29 | 35 | |
... | ... | @@ -31,24 +37,26 @@ |
31 | 37 | taggedString=self.tagger.tagg(self.cleanString) |
32 | 38 | self.tableLem = taggedString.rstrip().split("\n") |
33 | 39 | for line in taggedString.rstrip().split("\n"): |
34 | - table = line.rstrip().split(" ") | |
35 | - if not table[0] in self.dico : | |
36 | - self.dico[table[0]]=[set(),set()] | |
37 | - self.dico[table[0]][0].add(table[2]) | |
40 | + if not re.match(r's>',line): | |
41 | + table = line.rstrip().split(" ") | |
42 | + if not table[0] in self.dico : | |
43 | + self.dico[table[0]]=[set(),set()] | |
44 | + self.dico[table[0]][0].add(table[2]) | |
38 | 45 | def insertPhon(self): |
39 | 46 | phonedString=self.phoner.phon(self.cleanString) |
40 | 47 | self.tablephon= phonedString.rstrip().split("\n") |
41 | 48 | for line in phonedString.rstrip().split("\n"): |
42 | - table = line.rstrip().split(" ") | |
43 | - if table[0] in self.dico: | |
44 | - self.dico[table[0]][1].add(table[1]) | |
49 | + if not re.match(r's>',line): | |
50 | + table = line.rstrip().split(" ") | |
51 | + if table[0] in self.dico: | |
52 | + self.dico[table[0]][1].add(table[1]) | |
45 | 53 | def getDico(self): |
46 | 54 | self.clean() |
47 | 55 | self.insertLem() |
48 | 56 | self.insertPhon() |
49 | 57 | table=[] |
50 | 58 | for i in self.dico: |
51 | - if not i == "<s>": | |
59 | + if not re.match(r"<s>",i): | |
52 | 60 | list=[] |
53 | 61 | list.append(i) |
54 | 62 | for indice in self.dico[i][0]: |
... | ... | @@ -56,6 +64,7 @@ |
56 | 64 | for indice in self.dico[i][1]: |
57 | 65 | list.append(indice) |
58 | 66 | ligne= " ".join(list) |
67 | + | |
59 | 68 | table.append(ligne) |
60 | 69 | return "\n".join(table) |