summaryrefslogtreecommitdiff
path: root/lib/nlp_ruby/ttable.rb
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-01-29 19:22:56 +0100
committerPatrick Simianer <p@simianer.de>2014-01-29 19:22:56 +0100
commitd9d72e06db07087aa54401fae8b259f0c4ccd649 (patch)
tree97f0444314c40d2894ac0892d5559101eda01acf /lib/nlp_ruby/ttable.rb
parent22644ed1365e566c8bf806bfff4ecd43c46ce089 (diff)
first usable version, name change => nlp_ruby
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
+