Module: Validate
- Included in:
- GuardedAsync, MetaMods
- Defined in:
- lib/bud/labeling/labeling.rb
Instance Method Summary collapse
- #collapse(left, right) ⇒ Object
- #do_collapse(left, right) ⇒ Object
- #labelof(op, nm) ⇒ Object
- #validate ⇒ Object
Instance Method Details
#collapse(left, right) ⇒ Object
128 129 130 131 132 133 134 135 136 137 |
# File 'lib/bud/labeling/labeling.rb', line 128 def collapse(left, right) return [right] if left == 'Bot' return [left] if right == 'Bot' return [left] if left == right return ['D'] if left == 'D' or right == 'D' # CALM return ['D'] if left == 'A' and right =~ /N/ # sometimes we cannot reduce return [left, right] end |
#do_collapse(left, right) ⇒ Object
112 113 114 115 116 |
# File 'lib/bud/labeling/labeling.rb', line 112 def do_collapse(left, right) l = left.pop r = right.shift left + collapse(l, r) + right end |
#labelof(op, nm) ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/bud/labeling/labeling.rb', line 118 def labelof(op, nm) if op == "<~" "A" elsif nm "N" else "Bot" end end |
#validate ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/bud/labeling/labeling.rb', line 87 def validate dp = Set.new divergent_preds.each do |p| dp.add(p.coll) end report = [] full_path.to_a.each do |p| state = ["Bot"] start_a = -1 p.label.each_with_index do |lbl, i| if lbl == "A" start_a = i + 1 end os = state.first state = do_collapse(state, [lbl]) end if dp.include? p.head report << (p.to_a + [:unguarded, ["D"]]) else report << (p.to_a + [:path, state]) end end return report end |