From 14f7bbab028d781cd2057a348862f911324338fd Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Tue, 23 Jun 2015 16:03:23 +0200 Subject: overhaul --- util/truecase.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 util/truecase.rb (limited to 'util/truecase.rb') diff --git a/util/truecase.rb b/util/truecase.rb new file mode 100755 index 0000000..3e97bd5 --- /dev/null +++ b/util/truecase.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby + +require 'nanomsg' +require 'open3' +require 'trollop' + +conf = Trollop::options do + opt :addr, "socket address", :short => "-S", :type => :string, :required => true + opt :moses, "path to moses directory", :short => "-m", :type => :string, :required => true + opt :model, "model file", :short => "-n", :type => :string, :required => true +end + +sock = NanoMsg::PairSocket.new +sock.bind conf[:addr] +sock.send "hello" + +cmd = "#{conf[:moses]}/scripts/recaser/truecase.perl -b --model #{conf[:model]}" +while true + inp = sock.recv + " " # FIXME? + break if !inp||inp=="shutdown" + Open3.popen3(cmd) do |pin, pout, perr| + pin.write inp + pin.close + s = pout.gets.strip + sock.send s #pout.gets.strip + end +end + +sock.send "off" + -- cgit v1.2.3