2015-08-20 20:12:18 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
import json
|
|
|
|
import urllib2
|
|
|
|
import sys
|
|
|
|
import time
|
2015-10-20 20:16:00 +02:00
|
|
|
import host
|
|
|
|
|
|
|
|
address = 'http://'+host.concordia_host
|
|
|
|
if len(host.concordia_port) > 0:
|
|
|
|
address += ':'+host.concordia_port
|
|
|
|
|
2015-08-20 20:12:18 +02:00
|
|
|
|
|
|
|
data = {
|
|
|
|
'operation': 'addSentence',
|
|
|
|
'sourceSentence':sys.argv[1],
|
|
|
|
'targetSentence':sys.argv[2],
|
2015-10-20 20:16:00 +02:00
|
|
|
'tmId':int(sys.argv[3])
|
2015-08-20 20:12:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
start = time.time()
|
2015-10-20 20:16:00 +02:00
|
|
|
req = urllib2.Request(address)
|
2015-08-20 20:12:18 +02:00
|
|
|
req.add_header('Content-Type', 'application/json')
|
|
|
|
response = json.loads(urllib2.urlopen(req, json.dumps(data)).read())
|
|
|
|
end = time.time()
|
|
|
|
|
|
|
|
print "Execution time: %.4f seconds." % (end-start)
|
|
|
|
print "Result: "
|
|
|
|
print response
|
|
|
|
|
|
|
|
|