642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
|
# File 'lib/activefacts/vocabulary/verbaliser.rb', line 642
def elided_objectification(next_step, fact_type, last_is_contractable, next_node)
if last_is_contractable
reading = fact_type.all_reading_by_ordinal.
detect do |reading|
(!next_step.is_disallowed || !reading.is_negative == !next_step.is_disallowed) and
reading_starts_with_node(reading, next_node)
end
end
last_is_contractable = false unless reading
reading ||= fact_type.preferred_reading(next_step.is_disallowed) || fact_type.preferred_reading
reading.text =~ /\{(\d)\}[^{]*\Z/
last_role_ref = reading.role_sequence.all_role_ref_in_order[$1.to_i]
exit_node = @variables.detect{|jn| jn.all_play.detect{|jr| jr.role == last_role_ref.role}}
exit_step = nil
debug :query, "Stepping over an objectification to #{exit_node.object_type.name} requires eliding the other implied steps" do
count = 0
while other_step =
@steps.
detect{|js|
debug :query, "Considering step '#{js.fact_type.default_reading}'"
next unless js.is_objectification_step
next unless js.input_play.variable.object_type == fact_type.entity_type || js.output_play.variable.object_type == fact_type.entity_type
exit_step = js if js.output_play.variable == exit_node
true
}
debug :query, "Emitting objectified FT allows deleting #{other_step.describe}"
step_completed(other_step)
end
end
[ reading, exit_step ? exit_step.input_play.variable : exit_node, exit_step, last_is_contractable]
end
|