Ejemplo n.º 1
0
# Wordly_Access.py
# For initiating/calling the model

from Wordly import Wordly
import os

# Initialize on run
rnn = Wordly()

print rnn.look_up("being one more than one")

# Receive queries


# Return results
os.write(3, '{"dt" : "This is a test"}' + "\n", "utf8")


# http://stackoverflow.com/questions/23804434/python-process-forked-by-nodejs-alternative-to-process-send-for-python?rq=1

# var child = child_process.spawn('python', ['hello.py'], {
#   stdio:[null, null, null, 'ipc']
# });

# child.on('message', function(message) {
#   console.log('Received message...');
#   console.log(message);
# });
Ejemplo n.º 2
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

	# print sys.argv[1]
Ejemplo n.º 3
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
Ejemplo n.º 4
0
# Wordly_Access.py
# For initiating/calling the model

from Wordly import Wordly
import os

# Initialize on run
rnn = Wordly()

print rnn.look_up("being one more than one")

# Receive queries

# Return results
os.write(3, '{"dt" : "This is a test"}' + "\n", "utf8")

# http://stackoverflow.com/questions/23804434/python-process-forked-by-nodejs-alternative-to-process-send-for-python?rq=1

# var child = child_process.spawn('python', ['hello.py'], {
#   stdio:[null, null, null, 'ipc']
# });

# child.on('message', function(message) {
#   console.log('Received message...');
#   console.log(message);
# });