Blame view

webtagger.py 1.05 KB
ffd3b3723   Killian   idem
1
2
3
4
5
  # -*- coding: utf-8 -*- 
  import subprocess
  import os
  import json
  from flask import Flask, request, render_template
e0e492698   Killian   Passage au proces...
6
  from processor.LiaTools import *
ffd3b3723   Killian   idem
7
8
9
10
11
12
13
14
  app = Flask(__name__)
  
  @app.route("/")
  def docs():
      return render_template('index.html')
  
  @app.route("/tagger",methods=['POST'])
  def cleaner():
e0e492698   Killian   Passage au proces...
15
      tagger = Tagger()
673721ec0   Killian   ajout phon il ma...
16
17
18
19
20
      tagger.isReady()
      phoner = Phoner()
      phoner.isReady()
      stoplist = StopWord()
      stoplist.isReady()
ffd3b3723   Killian   idem
21
22
      # Receive String from post parametre Raw text ( Json )
      dirtyString= request.json[u'string']
e0e492698   Killian   Passage au proces...
23
      # send the String throught LIA_TAGG script  thank's to pip
ffd3b3723   Killian   idem
24
      # lia_clean split a word by line et markup the sentences
673721ec0   Killian   ajout phon il ma...
25
26
27
28
29
30
31
32
      dirtyString = stoplist.RemoveStopList(dirtyString)
      print " stop list " + dirtyString
      lemm = tagger.lemm(tagger.clean(dirtyString))
      print 'les lemm '+ lemm
      dirtyString = dirtyString+" "+ lemm
      cleanString= phoner.clean(dirtyString)
      taggedString= phoner.phon(cleanString)
      print taggedString
e0e492698   Killian   Passage au proces...
33
      return taggedString
ffd3b3723   Killian   idem
34
35
36
  if __name__ == '__main__':
      app.debug = True
      app.run(host='0.0.0.0')