@ Override public void visit ( SequentialTemporalPatternDefinition def ) throws ProtempaException { LOGGER . log ( Level . FINER , "Creating rule for {0}" , def ) ; try { TemporalExtendedPropositionDefinition lhs = def . getFirstTemporalExtendedPropositionDefinition ( ) ; if ( lhs != null ) { Rule rule = new Rule ( "SEQ_TP_" + def . getId ( ) ) ; Pattern sourceP = new Pattern ( 2 , TEMP_PROP_OT ) ; GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression ( lhs , this . cache ) ; sourceP . addConstraint ( new PredicateConstraint ( matchesPredicateExpression ) ) ; SubsequentTemporalExtendedPropositionDefinition [ ] relatedTemporalExtendedPropositionDefinitions = def . getSubsequentTemporalExtendedPropositionDefinitions ( ) ; for ( int i = 0 ; i < relatedTemporalExtendedPropositionDefinitions . length ; i ++ ) { SubsequentTemporalExtendedPropositionDefinition rtepd = relatedTemporalExtendedPropositionDefinitions [ i ] ; GetMatchesPredicateExpression matchesPredicateExpression1 = new GetMatchesPredicateExpression ( rtepd . getRelatedTemporalExtendedPropositionDefinition ( ) , this . cache ) ; Constraint c = new PredicateConstraint ( matchesPredicateExpression1 ) ; sourceP . addConstraint ( c ) ; } Pattern resultP = new Pattern ( 1 , 1 , ARRAY_LIST_OT , "result" ) ; resultP . setSource ( new Collect ( sourceP , new Pattern ( 1 , 1 , ARRAY_LIST_OT , "result" ) ) ) ; resultP . addConstraint ( new PredicateConstraint ( new CollectionSizeExpression ( 1 ) ) ) ; rule . addPattern ( resultP ) ; rule . setConsequence ( new SequentialTemporalPatternConsequence ( def , this . derivationsBuilder ) ) ; rule . setSalience ( MINUS_TWO_SALIENCE ) ; this . ruleToAbstractionDefinition . put ( rule , def ) ; rules . add ( rule ) ; ABSTRACTION_COMBINER . toRules ( def , rules , this . derivationsBuilder ) ; } } catch ( InvalidRuleException e ) { throw new AssertionError ( e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } }
Translates a sequential temporal pattern definition into rules .