addAlignedFIle

This commit is contained in:
rjawor 2015-12-31 00:12:12 +01:00
parent 05d99168ed
commit 129f154d5e

View File

@ -24,8 +24,7 @@ def file_len(fname):
def add_data(data): def add_data(data):
req = urllib2.Request(address) req = urllib2.Request(address)
req.add_header('Content-Type', 'application/json') req.add_header('Content-Type', 'application/json')
response = json.loads(urllib2.urlopen(req, json.dumps(data)).read()) json.loads(urllib2.urlopen(req, json.dumps(data)).read())
#print response
sourceFile = sys.argv[1] sourceFile = sys.argv[1]
sourceLangId = int(sys.argv[2]) sourceLangId = int(sys.argv[2])
@ -71,7 +70,8 @@ with open(sourceFile) as sourceLines:
data['sentences'] = sentences data['sentences'] = sentences
add_data(data) add_data(data)
mark = time.time() mark = time.time()
print "Added %d of %d sentences. Time elapsed: %.4f s, current speed: %.4f sentences/second" % ( (lineNumber+1)/3, totalLines/3, mark-start, (lineNumber+1)/3*(mark-start)) print "Added %d of %d sentences. Time elapsed: %.4f s, current speed: %.4f sentences/second" % ( (lineNumber+1)/3, totalLines/3, mark-start, (lineNumber+1)/(3*(mark-start)))
sentences = []
lineNumber += 1 lineNumber += 1