@Override
    public void visit(SliceDefinition def) throws ProtempaException {
        LOGGER.log(Level.FINER, "Creating rule for {0}", def);
        try {
            Set<TemporalExtendedPropositionDefinition> epdsC = def
                    .getTemporalExtendedPropositionDefinitions();
            if (!epdsC.isEmpty()) {
                TemporalExtendedPropositionDefinition[] epds = epdsC
                        .toArray(new TemporalExtendedPropositionDefinition[epdsC.size()]);
                Rule rule = new Rule("SLICE_" + def.getId());

                Pattern sourceP = new Pattern(2, 1, TEMP_PROP_OT, "");
                for (int i = 0; i < epds.length; i++) {
                    GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression(epds[i], this.cache);
                    Constraint c = new PredicateConstraint(
                            matchesPredicateExpression);
                    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")));
                int len;
                int minInd = def.getMinIndex();
                int maxInd = def.getMaxIndex();
                if (maxInd < 0) {
                    len = Math.abs(minInd);
                } else {
                    len = maxInd;
                }
                resultP.addConstraint(new PredicateConstraint(
                        new CollectionSizeExpression(len)));
                rule.addPattern(resultP);
                rule.setConsequence(new SliceConsequence(def,
                        this.derivationsBuilder));
                rule.setSalience(MINUS_TWO_SALIENCE);
                this.ruleToAbstractionDefinition.put(rule, def);
                rules.add(rule);
            }
        } catch (InvalidRuleException e) {
            throw new AssertionError(e.getClass().getName() + ": "
                    + e.getMessage());
        }
    }
@ Override public void visit ( SliceDefinition def ) throws ProtempaException { LOGGER . log ( Level . FINER , "Creating rule for {0}" , def ) ; try { Set < TemporalExtendedPropositionDefinition > epdsC = def . getTemporalExtendedPropositionDefinitions ( ) ; if ( ! epdsC . isEmpty ( ) ) { TemporalExtendedPropositionDefinition [ ] epds = epdsC . toArray ( new TemporalExtendedPropositionDefinition [ epdsC . size ( ) ] ) ; Rule rule = new Rule ( "SLICE_" + def . getId ( ) ) ; Pattern sourceP = new Pattern ( 2 , 1 , TEMP_PROP_OT , "" ) ; for ( int i = 0 ; i < epds . length ; i ++ ) { GetMatchesPredicateExpression matchesPredicateExpression = new GetMatchesPredicateExpression ( epds [ i ] , this . cache ) ; Constraint c = new PredicateConstraint ( matchesPredicateExpression ) ; 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" ) ) ) ; int len ; int minInd = def . getMinIndex ( ) ; int maxInd = def . getMaxIndex ( ) ; if ( maxInd < 0 ) { len = Math . abs ( minInd ) ; } else { len = maxInd ; } resultP . addConstraint ( new PredicateConstraint ( new CollectionSizeExpression ( len ) ) ) ; rule . addPattern ( resultP ) ; rule . setConsequence ( new SliceConsequence ( def , this . derivationsBuilder ) ) ; rule . setSalience ( MINUS_TWO_SALIENCE ) ; this . ruleToAbstractionDefinition . put ( rule , def ) ; rules . add ( rule ) ; } } catch ( InvalidRuleException e ) { throw new AssertionError ( e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } }
Translates a slice definition into rules.

@param def a {@link SliceDefinition}. Cannot be <code>null</code>.
@throws KnowledgeSourceReadException if an error occurs accessing the
knowledge source during rule creation.