Skip to content

Commit

Permalink
Adding a path argument for the service
Browse files Browse the repository at this point in the history
  • Loading branch information
lechatpito committed Nov 24, 2015
1 parent 330f535 commit 71b331a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions word2vec-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ def pageNotFound(error):
def raiseError(error):
return error

api.add_resource(N_Similarity, '/word2vec/n_similarity')
api.add_resource(Similarity, '/word2vec/similarity')
api.add_resource(MostSimilar, '/word2vec/most_similar')
api.add_resource(Model, '/word2vec/model')

if __name__ == '__main__':
global model

Expand All @@ -103,13 +98,20 @@ def raiseError(error):
p.add_argument("--binary", help="Specifies the loaded model is binary")
p.add_argument("--host", help="Host name (default: localhost)")
p.add_argument("--port", help="Port (default: 5000)")
p.add_argument("--path", help="Path (default: /word2vec)")
args = p.parse_args()

model_path = args.model if args.model else "./model.bin.gz"
binary = True if args.binary else False
host = args.host if args.host else "localhost"
path = args.path if args.path else "/word2vec"
port = int(args.port) if args.port else 5000
if not args.model:
print "Usage: word2vec-apy.py --model path/to/the/model [--host host --port 1234]"
print "Usage: word2vec-apy.py --model path/to/the/model [--host host --path /path --port 1234]"
model = w.load_word2vec_format(model_path, binary=binary)
api.add_resource(N_Similarity, path+'/n_similarity')
api.add_resource(Similarity, path+'/similarity')
api.add_resource(MostSimilar, path+'/most_similar')
api.add_resource(Model, path+'/model')

app.run(host=host, port=port)

0 comments on commit 71b331a

Please sign in to comment.