summaryrefslogtreecommitdiff
path: root/grammar.rb
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-12 11:22:44 +0200
committerPatrick Simianer <p@simianer.de>2014-06-12 11:22:44 +0200
commita981df066484f799637c8a0b88209110038e3148 (patch)
treeee9d14e1e99d0aad06854ea8967587aca22e6936 /grammar.rb
parent719a996f9acfefa5ff3dc49d36e0ef6e57e74fe3 (diff)
feature vectors
Diffstat (limited to 'grammar.rb')
-rw-r--r--grammar.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/grammar.rb b/grammar.rb
index 0b2bc61..2506d61 100644
--- a/grammar.rb
+++ b/grammar.rb
@@ -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