diff options
author | Patrick Simianer <p@simianer.de> | 2015-05-12 17:46:56 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2015-05-12 17:46:56 +0200 |
commit | 6c0fcee726662285e7c4cb3857ca28296f5c525c (patch) | |
tree | 77de036e546e79b60db0b60e7e273eb2e8b50e3f /python/cdec/sa | |
parent | e0bb79a01ed07cce540e5ebb757e03d801ca287e (diff) |
integrated updating grammars
Diffstat (limited to 'python/cdec/sa')
-rw-r--r-- | python/cdec/sa/extract.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/python/cdec/sa/extract.py b/python/cdec/sa/extract.py index a9dcd25a..0f1f2246 100644 --- a/python/cdec/sa/extract.py +++ b/python/cdec/sa/extract.py @@ -97,12 +97,13 @@ def stream_extract(): sys.stdout.write('Error: see README.md for stream mode usage. Skipping line: {}\n'.format(line.strip())) sys.stdout.flush() -def stream_extract2(): +def stream_extract2(url): global extractor, online, compress import nanomsg from nanomsg import Socket, PAIR, PUB socket = nanomsg.Socket(nanomsg.PAIR) - socket.bind('tcp://127.0.0.1:8888') + socket.bind(url) + socket.send("hello") while True: line = socket.recv() if line.strip() == "shutdown": @@ -134,6 +135,7 @@ def stream_extract2(): socket.send('learn {}\n'.format(context)) else: socket.send('Error: see README.md for stream mode usage. Skipping line: {}\n'.format(line.strip())) + socket.send("off") socket.close() def main(): @@ -158,6 +160,8 @@ def main(): help='stream mode (see README.md)') parser.add_argument('-u', '--stream2', action='store_true', help='stream2 mode') + parser.add_argument('-S', '--sock_url', default='tcp://127.0.0.1:8888', + help='socket url') args = parser.parse_args() if not (args.grammars or (args.stream or args.stream2)): @@ -175,6 +179,8 @@ def main(): online = args.online stream = args.stream stream2 = args.stream2 + if stream2: + online = True start_time = monitor_cpu() if args.jobs > 1: @@ -193,7 +199,7 @@ def main(): if stream: stream_extract() if stream2: - stream_extract2() + stream_extract2(args.sock_url) else: for output in map(extract, enumerate(sys.stdin)): print(output) |