diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-12 11:22:44 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-12 11:22:44 +0200 |
commit | a981df066484f799637c8a0b88209110038e3148 (patch) | |
tree | ee9d14e1e99d0aad06854ea8967587aca22e6936 /grammar.rb | |
parent | 719a996f9acfefa5ff3dc49d36e0ef6e57e74fe3 (diff) |
feature vectors
Diffstat (limited to 'grammar.rb')
-rw-r--r-- | grammar.rb | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -39,13 +39,14 @@ class NT end class Rule - attr_accessor :lhs, :rhs, :target, :map + attr_accessor :lhs, :rhs, :target, :map, :f - def initialize lhs=nil, rhs=nil, target=nil, map=nil + def initialize lhs=nil, rhs=nil, target=nil, map=nil, f=SparseVector.new @lhs = lhs @rhs = rhs @target = target @map = (map ? map : []) + @f = f @arity_ = nil end @@ -73,10 +74,11 @@ class Rule end def from_s s - lhs, rhs, target = splitpipe s, 3 + lhs, rhs, target, f = splitpipe s, 3 @lhs = NT.from_s lhs @rhs = read_right_ rhs @target = read_right_ target, true + @f = (f ? SparseVector.from_kv(f) : nil) end def self.from_s_x s |