webtagger.py 1.08 KB
# -*- coding: utf-8 -*- 
import subprocess
import os
import json
from flask import Flask, request, render_template
from processor.LiaTools import *
from processor.Orkis import Orkis
from flaskext.enterprise import Enterprise

app = Flask(__name__)
enterprise = Enterprise(app)

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

@app.route("/tagger",methods=['POST'])
def cleaner():
    # Receive String from post parametre Raw text
    dirtyString= request.values[u'string']
    # Charging Processor et check if they are okay ( aim is to dynamic charge later ) 
    orkisProc = Orkis(dirtyString)
    # Processing 
    # Adding lemm of each words cause we went ther phonem too
    taggedTable= orkisProc.getDico()
    # Returning a row text to be parse client side
    return unicode(taggedTable)

class OrkisService(enterprise.SOAPService):
    @enterprise.soap(enterprise.String,_returns=enterprise._sp.String)
    def get_phon(self,string):
        orkisProc=Orkis(string)
        return orkisProc.getDico()


if __name__ == '__main__':
    app.debug = True
    app.run(host='0.0.0.0')