summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2015-05-27 19:20:29 +0200
committerPatrick Simianer <p@simianer.de>2015-05-27 19:20:29 +0200
commit629d84151f1288f8de11fc866c3960cfcf3ff0fd (patch)
tree89522409f52a5db7530710241e64a1c52eeac496
parent5b000aa1d539a4c31449c4ccaf15e8ca91bf90ba (diff)
net: python extractor output
-rw-r--r--python/cdec/sa/extract.py11
-rw-r--r--training/dtrain/dtrain_net.h3
-rw-r--r--training/dtrain/dtrain_net_interface.cc2
3 files changed, 9 insertions, 7 deletions
diff --git a/python/cdec/sa/extract.py b/python/cdec/sa/extract.py
index 0f1f2246..cf87ff77 100644
--- a/python/cdec/sa/extract.py
+++ b/python/cdec/sa/extract.py
@@ -103,6 +103,7 @@ def stream_extract2(url):
from nanomsg import Socket, PAIR, PUB
socket = nanomsg.Socket(nanomsg.PAIR)
socket.bind(url)
+ sys.stderr.write("sending hello ...\n")
socket.send("hello")
while True:
line = socket.recv()
@@ -118,23 +119,23 @@ def stream_extract2(url):
if cmd.lower() == 'drop':
if online:
extractor.drop_ctx(context)
- sock.send('drop {}\n'.format(context))
+ sock.send('drop {}'.format(context))
else:
- sock.send('Error: online mode not set. Skipping line: {}\n'.format(line.strip()))
+ sock.send('Error: online mode not set. Skipping line: {}'.format(line.strip()))
# context ||| sentence ||| grammar_file
elif len(fields) == 3:
(context, sentence, grammar_file) = fields
with (gzip.open if compress else open)(grammar_file, 'w') as output:
for rule in extractor.grammar(sentence, context):
output.write(str(rule)+'\n')
- socket.send('{}\n'.format(grammar_file))
+ socket.send('{}'.format(grammar_file))
# context ||| sentence ||| reference ||| alignment
elif len(fields) == 4:
(context, sentence, reference, alignment) = fields
extractor.add_instance(sentence, reference, alignment, context)
- socket.send('learn {}\n'.format(context))
+ socket.send('learn {}'.format(context))
else:
- socket.send('Error: see README.md for stream mode usage. Skipping line: {}\n'.format(line.strip()))
+ socket.send('Error: see README.md for stream mode usage. Skipping line: {}'.format(line.strip()))
socket.send("off")
socket.close()
diff --git a/training/dtrain/dtrain_net.h b/training/dtrain/dtrain_net.h
index f6aa08b2..cbf171d6 100644
--- a/training/dtrain/dtrain_net.h
+++ b/training/dtrain/dtrain_net.h
@@ -43,7 +43,8 @@ dtrain_net_init(int argc, char** argv, po::variables_map* conf)
("k", po::value<size_t>()->default_value(100), "size of kbest list")
("N", po::value<size_t>()->default_value(4), "N for BLEU approximation")
("margin,m", po::value<weight_t>()->default_value(0.), "margin for margin perceptron")
- ("output,o", po::value<string>()->default_value(""), "final weights file");
+ ("output,o", po::value<string>()->default_value(""), "final weights file")
+ ("input_weights,w", po::value<string>(), "input weights file");
po::options_description cl("Command Line Options");
cl.add_options()
("conf,c", po::value<string>(), "dtrain configuration file")
diff --git a/training/dtrain/dtrain_net_interface.cc b/training/dtrain/dtrain_net_interface.cc
index 6c603040..d126ed27 100644
--- a/training/dtrain/dtrain_net_interface.cc
+++ b/training/dtrain/dtrain_net_interface.cc
@@ -117,7 +117,7 @@ main(int argc, char** argv)
CollectUpdates(samples, updates, margin);
cerr << "updates size " << updates.size() << endl;
cerr << "lambdas before " << lambdas << endl;
- lambdas.plus_eq_v_times_s(updates, 1.0); // FIXME: learning rate?
+ //lambdas.plus_eq_v_times_s(updates, 1.0); // FIXME: learning rate?
cerr << "lambdas after " << lambdas << endl;
i++;