webtagger.py 1.05 KB
# -*- coding: utf-8 -*- 
import subprocess
import os
import json
from flask import Flask, request, render_template
from processor.LiaTools import *
app = Flask(__name__)

@app.route("/")
def docs():
    return render_template('index.html')

@app.route("/tagger",methods=['POST'])
def cleaner():
    tagger = Tagger()
    tagger.isReady()
    phoner = Phoner()
    phoner.isReady()
    stoplist = StopWord()
    stoplist.isReady()
    # Receive String from post parametre Raw text ( Json )
    dirtyString= request.json[u'string']
    # send the String throught LIA_TAGG script  thank's to pip
    # lia_clean split a word by line et markup the sentences
    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
    return taggedString
if __name__ == '__main__':
    app.debug = True
    app.run(host='0.0.0.0')