Method: #read_phrase_table
- Defined in:
- lib/zipf/misc.rb
#read_phrase_table(fn) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/zipf/misc.rb', line 73 def read_phrase_table fn table = {} f = ReadFile.new fn while raw_rule = f.gets french, english, features = splitpipe(raw_rule) feature_map = SparseVector.from_kv features if table.has_key? french table[french] << [english, feature_map ] else table[french] = [[english, feature_map]] end end f.close return table end |