summaryrefslogtreecommitdiff
path: root/lib/nlp_ruby/ttable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nlp_ruby/ttable.rb')
-rw-r--r--lib/nlp_ruby/ttable.rb17
1 files changed, 17 insertions, 0 deletions
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
+