From 6c0fcee726662285e7c4cb3857ca28296f5c525c Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Tue, 12 May 2015 17:46:56 +0200
Subject: integrated updating grammars
---
net_test/run.rb | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
create mode 100755 net_test/run.rb
(limited to 'net_test/run.rb')
diff --git a/net_test/run.rb b/net_test/run.rb
new file mode 100755
index 00000000..7cf01c7a
--- /dev/null
+++ b/net_test/run.rb
@@ -0,0 +1,87 @@
+#!/usr/bin/env ruby
+
+require 'nanomsg'
+require 'zipf'
+
+work_dir = "work"
+`mkdir -p #{work_dir}`
+
+# start daemons
+# extractor
+extractor_url = 'tcp://127.0.0.1:60000'
+extractor_sock = NanoMsg::PairSocket.new
+puts "starting extractor .."
+extractor = fork do
+ exec "python -m cdec.sa.extract -c extract.ini --online -u -S '#{extractor_url}' &>#{work_dir}/extractor.out"
+end
+Process.detach extractor
+extractor_sock.connect extractor_url
+puts "> got #{extractor_sock.recv} from extractor"
+`mkdir -p #{work_dir}/g`
+
+# aligner
+aligner_url = 'tcp://127.0.0.1:60001'
+aligner_sock = NanoMsg::PairSocket.new
+puts "starting aligner .."
+aligner = fork do
+ exec "../word-aligner/net_fa --sock_url '#{aligner_url}' -f a/ef &>#{work_dir}/net_fa.out"
+end
+Process.detach aligner
+aligner_sock.connect aligner_url
+puts "> got #{aligner_sock.recv} from aligner"
+
+# dtrain
+dtrain_url = 'tcp://127.0.0.1:60002'
+dtrain_sock = NanoMsg::PairSocket.new
+puts "starting dtrain .."
+dtrain = fork do
+ exec "../training/dtrain/dtrain_net_interface -c dtrain.ini -o #{work_dir}/weights.final -a '#{dtrain_url}' &>#{work_dir}/dtrain.out"
+end
+Process.detach dtrain
+dtrain_sock.connect dtrain_url
+puts "> got #{dtrain_sock.recv} from dtrain"
+
+puts ">>> all daemons ready\n\n"
+
+i = 0
+while line = STDIN.gets
+ source, reference = splitpipe(line.strip)
+ source.strip!; reference.strip!
+ puts "source: '#{source}'"
+ puts "reference: '#{reference}'"
+ generate_grammar = "TEST ||| #{source} ||| #{work_dir}/g/#{i}.grammar"
+ puts "[extractor] generate grammar: '#{generate_grammar}'"
+ extractor_sock.send generate_grammar
+ grammar = extractor_sock.recv.strip
+ annotated_source = "