Skip to content

Commit

Permalink
more cowwwbell
Browse files Browse the repository at this point in the history
  • Loading branch information
lechatpito committed Oct 3, 2014
1 parent f665c4d commit ff69909
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions word2vec-api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from numpy import exp, dot, zeros, outer, random, dtype, get_include, float32 as REAL,\
uint32, seterr, array, uint8, vstack, argsort, fromstring, sqrt, newaxis, ndarray, empty, sum as np_sum
import argparse
import base64
import sys

parser = reqparse.RequestParser()

Expand Down Expand Up @@ -62,9 +64,11 @@ def get(self):
args = parser.parse_args()
try:
res = model[args['word']]
return res.tostring()
str = base64.b64encode(res)
return str
except:
return
sys.exc_info()[0]
return

app = Flask(__name__)
api = Api(app)
Expand Down Expand Up @@ -100,5 +104,4 @@ def raiseError(error):
if not args.model:
print "Usage: wor2vec-apy.py --model path/to/the/model [--host host --port 1234]"
model = w.load_word2vec_format(model_path, binary=binary)
app.run(host=host, port=port)

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

0 comments on commit ff69909

Please sign in to comment.