Ejemplo n.º 1
0
import os
import sys
import json
from socketIO_client import SocketIO

with SocketIO('localhost', 8000) as socketIO:
    # socketIO.emit('aaa')
    # socketIO.wait(seconds=1)

    # Phase 0
    # os.write(3, '{"dt" : "This is a test"}')

    socketIO.emit('test', '{"dt" : "This is a test"}')

    # Initialize on run
    rnn = Wordly()
    rnn.initialize_model(json='Word_Model/Model/model.json',
                         weights='Word_Model/Model/weights.hdf5',
                         embed_path='Word_Model/Model/embeddings.hdf5',
                         verbose=False)

    output = rnn.look_up(sys.argv[1])

    # output = [("Silurian", 0.80866586826121223), ("Paleozoic", 0.84940722613702724), ("Palaeolithic", 0.95937944007114762), ("Cenozoic", 0.96295106505316119), ("Mesolithic", 1.0181287210346959)]

    result = {}
    best = output.pop()
    result["best"] = best[0]
    result["score"] = best[1]
    result["others"] = output