From d9d72e06db07087aa54401fae8b259f0c4ccd649 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Wed, 29 Jan 2014 19:22:56 +0100 Subject: first usable version, name change => nlp_ruby --- lib/nlp_ruby/ttable.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/nlp_ruby/ttable.rb (limited to 'lib/nlp_ruby/ttable.rb') diff --git a/lib/nlp_ruby/ttable.rb b/lib/nlp_ruby/ttable.rb new file mode 100644 index 0000000..20b1412 --- /dev/null +++ b/lib/nlp_ruby/ttable.rb @@ -0,0 +1,17 @@ +# table['some French string'] = [Array of English strings] +def read_phrase_table fn + table = {} + f = ReadFile.new fn + while raw_rule = f.gets + french, english, features = splitpipe(raw_rule) + feature_map = read_feature_string(features) + if table.has_key? french + table[french] << [english, feature_map ] + else + table[french] = [[english, feature_map]] + end + end + f.close + return table +end + -- cgit v1.2.3