Commit e0e4926982dec15818a6981a291e5e34e0c6e423

Authored by Killian
1 parent ac1275835c
Exists in master and in 1 other branch soap

Passage au processor Step 1

Showing 2 changed files with 14 additions and 26 deletions Side-by-side Diff

static/js/application.js
... ... @@ -14,15 +14,16 @@
14 14 url: "tagger",
15 15 data: data,
16 16 success: function(data){
17   - data = JSON.parse(data);
  17 + //data = JSON.parse(data);
18 18 result=$('#result');
19 19  
20   - _.each(data, function(element, index, list){
21   - console.log(element);
22   - result.append(_.escape(element["word"])+" ");
23   - result.append(_.escape(element["markup"]+" "));
24   - result.append(_.escape(element["lemm"]+"\n"));
25   - });
  20 + //_.each(data, function(element, index, list){
  21 + // console.log(element);
  22 + // result.append(_.escape(element["word"])+" ");
  23 + // result.append(_.escape(element["markup"]+" "));
  24 + // result.append(_.escape(element["lemm"]+"\n"));
  25 + //});
  26 + result.append(_.escape(data));
26 27 console.log(_.escape(data));
27 28 console.log("resultat");
28 29 },
... ... @@ -3,6 +3,7 @@
3 3 import os
4 4 import json
5 5 from flask import Flask, request, render_template
  6 +from processor.LiaTools import *
6 7 app = Flask(__name__)
7 8  
8 9 @app.route("/")
9 10  
10 11  
... ... @@ -11,28 +12,14 @@
11 12  
12 13 @app.route("/tagger",methods=['POST'])
13 14 def cleaner():
  15 + tagger = Tagger()
14 16 # Receive String from post parametre Raw text ( Json )
15 17 dirtyString= request.json[u'string']
16   - # send the String throught LIA_TAGG script thank's to pipe
  18 + # send the String throught LIA_TAGG script thank's to pip
17 19 # lia_clean split a word by line et markup the sentences
18   - p=subprocess.Popen([os.environ["LIA_TAGG"]+'/script/lia_clean'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
19   - (cleanString, err) = p.communicate(input=dirtyString.encode('iso8859-1','backslashreplace'))
20   - #lia_tagg+lemm tagg words with function and give the lemm for each word
21   - p2=subprocess.Popen([os.environ["LIA_TAGG"]+'/script/lia_tagg+lemm','-guess'],stdin=subprocess.PIPE,stdout=subprocess.PIPE)
22   - (taggedString,err) =p2.communicate(input=cleanString)
23   - # This is used beceause lia_tagg deal with iso8859 only
24   - taggedString = taggedString.decode('iso8859').encode("utf8")
25   - textTable = taggedString.split('\n')
26   - # Creating a dictionary in order to encode it into Json
27   - textDictionary = list()
28   - for line in textTable :
29   - lineTable =line.split()
30   - #print lineTable
31   - if lineTable:
32   - wordDict=dict([('word',lineTable[0]),('markup',lineTable[1]),('lemm',lineTable[2])])
33   - textDictionary.append(wordDict)
34   - textJson = json.JSONEncoder().encode(textDictionary)
35   - return textJson
  20 + cleanString= tagger.clean(dirtyString)
  21 + taggedString= tagger.tagg(cleanString)
  22 + return taggedString
36 23 if __name__ == '__main__':
37 24 app.debug = True
38 25 app.run(host='0.0.0.0')