Exemplo n.º 1
0
def run_server(port_num=8080):
    models.load_models()

    debug(True)

    @route('/<text>')
    def index(text):
        if not text:
            return ''

        print('GET: ', text)

        try:
            splitted = text.split()
            if len(splitted) < 2:
                return ''
            else:
                splitted = splitted[-2:]
                p = predict(splitted[0], splitted[1])
        except:
            return ''

        print('PREDICTED: ', p)
        return '\n'.join([w for w, _ in p])

    run(host='localhost', port=port_num)
Exemplo n.º 2
0
def load():
    """load the classic Norvig big.txt corpus"""
    print("training!")

    models.load_models()

    print("done training!")

    return True
Exemplo n.º 3
0
def load():
    """load the classic Norvig big.txt corpus"""
    print("training!")

    models.load_models()

    print("done training!")

    return True
Exemplo n.º 4
0
def run_server(port_num=8080):
    """little demo server for demo'ing sake"""
    models.load_models()

    debug(True)

    @route('/<first_word>/<second_word>')
    def index(first_word, second_word):
        return dict(predict(first_word, second_word))

    run(host='localhost', port=port_num)
Exemplo n.º 5
0
def run_server(port_num=8080):
    """little demo server for demo'ing sake"""
    models.load_models()

    debug(True)

    @route('/<first_word>/<second_word>')
    def index(first_word, second_word):
        return dict(predict(first_word, second_word))

    run(host='localhost', port=port_num)
Exemplo n.º 6
0
def run_server(port_num=8080):
    """little demo server for demo'ing sake"""
    models.load_models()

    debug(True)

    @route('/<first_word>/<second_word>/<n>')
    def p2(first_word, second_word, n):
        if (n != ""):
            n = int(n)
        else:
            n = 10 
        return dict(predict(first_word, second_word, n))

    @route('/<partial_word>/<n>')
    def partialPredict(partial_word, n ):
        if (n != ""):
            n = int(n)
        else:
            n = 10
        return dict(predict(partial_word, False, n))
    
    run(host='localhost', port=port_num)
Exemplo n.º 7
0
def loadGOT():
    models.load_models("pklFiles\gameOfthrones.pkl")
Exemplo n.º 8
0
def loadAlice():
    models.load_models("pklFiles\wonderland.pkl")
Exemplo n.º 9
0
def loadHarry():
    models.load_models("pklFiles\harryPorter.pkl")
Exemplo n.º 10
0
import bottle
from bottle import route, run, debug
import autocomplete
from autocomplete import models, predict
models.load_models()
#autocomplete.load()
#autocomplete.run_server()


app = bottle.default_app()

@route('/')
def hello_world():
    #autocomplete.load()
    #autocomplete.run_server()
    return "Hello, world! Simple test to make sure if Docker is running fine"

@route('/<first_word>/<last_word>')
def hello_ml(first_word, last_word):
     return dict(predict(first_word,last_word))

if __name__ == "__main__":
    autocomplete.load()
    run(host="0.0.0.0", port=8000, debug=True, reloader=True)