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():
    # Charging Processor et check if they are okay ( aim is to dynamic charge later ) 
    tagger = Tagger()
    tagger.isReady()
    phoner = Phoner()
    phoner.isReady()
    stoplist = StopWord()
    stoplist.isReady()
    # Receive String from post parametre Raw text
    dirtyString= request.values[u'string']
    # Processing 
    dirtyString = stoplist.RemoveStopList(dirtyString)
    lemm = tagger.lemm(tagger.clean(dirtyString))
    # Adding lemm of each words cause we went ther phonem too
    dirtyString = dirtyString+" "+ lemm
    cleanString= phoner.clean(dirtyString)
    taggedString= phoner.phon(cleanString)
    # Returning a row text to be parse client side
    return taggedString
if __name__ == '__main__':
    app.debug = True
    app.run(host='0.0.0.0')