Skip to content
Browse files

[PMML] Prevent duplicate rules

  • Loading branch information...
1 parent ad8948e commit 4d78b0a9b838bc3411fe9e8674a645cf6df18213 @sotty sotty committed
View
2 ...-pmml/src/main/resources/org/drools/pmml/pmml_4_1/templates/informer/modelRevalidate.drlt
@@ -32,7 +32,7 @@ salience 50
when
question : Question(questionId : id, answerType != null, answer : answer != null ) @watch(*)
association : DomainModelAssociation(questionId == questionId, object : object, property : property, lastAnswer == answer )
- $bean : DataField( this == object, valid == false )
+ $bean : DataField( this == object, valid == false, context == "@{name}" )
then
// System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>> REVAL : " + $bean + " on " + association + " sue to " + question );
View
2 ...c/main/resources/org/drools/pmml/pmml_4_1/templates/models/neural/neuralLinkSynapses.drlt
@@ -24,7 +24,7 @@
rule "LinkSynapses_@{name}"
when
- Stym( $ctx : context, $index : index, $val : value )
+ Stym( $ctx : context == "@{name}", $index : index, $val : value )
Synapse( context == $ctx, source == $index, $target : target, $w : weight )
then
Charge c = new Charge();
View
5 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/DroolsAbstractPMMLTest.java
@@ -18,6 +18,7 @@
import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.RuleBaseConfiguration;
import org.drools.builder.*;
@@ -104,8 +105,8 @@ protected StatefulKnowledgeSession getModelSession(String[] pmmlSources, boolean
if ( errors.size() > 0 ) {
throw new IllegalArgumentException( "Could not parse knowledge : " + errors.toString() );
}
- RuleBaseConfiguration conf = new RuleBaseConfiguration();
- conf.setEventProcessingMode( EventProcessingOption.STREAM );
+ KnowledgeBaseConfiguration conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
+ conf.setOption( EventProcessingOption.STREAM );
//conf.setConflictResolver(LifoConflictResolver.getInstance());
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( conf );
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
View
21 drools-pmml/src/test/java/org/drools/pmml/pmml_4_1/informer/QuestionnaireTest.java
@@ -353,14 +353,14 @@ public void testInvalidValues() throws Exception {
getKSession().fireAllRules();
- getKSession().getWorkingMemoryEntryPoint( "in_Feat2" ).insert( 5 );
+ getKSession().getWorkingMemoryEntryPoint( "in_PetalNum" ).insert( 5 );
getKSession().fireAllRules();
System.err.println( reportWMObjects( getKSession() ) );
- FactType type = getKbase().getFactType( packageName, "Feat2" );
+ FactType type = getKbase().getFactType( packageName, "PetalNum" );
checkFirstDataFieldOfTypeStatus( type, false, false, "Neuiris", 5 );
assertEquals( 4, getKSession().getObjects(new ClassObjectFilter( InvalidAnswer.class ) ).size() );
@@ -397,15 +397,14 @@ private String getQId( String model, String field ) {
public void testMultipleModels() throws Exception {
setKSession( getModelSession( new String[] { source, source2 }, true ) );
setKbase(getKSession().getKnowledgeBase());
- FactType petalNumType = getKbase().getFactType( packageName, "Feat2" );
+ FactType petalNumType = getKbase().getFactType( packageName, "PetalNum" );
FactType out = getKbase().getFactType( packageName, "OutSepLen" );
FactType sepalType = getKbase().getFactType( packageName, "SepalLen" );
-
-
getKSession().fireAllRules();
getKSession().getWorkingMemoryEntryPoint( "in_Feat2" ).insert( 4 );
+ getKSession().getWorkingMemoryEntryPoint( "in_PetalNum" ).insert( 4 );
getKSession().getWorkingMemoryEntryPoint( "in_PetalWid" ).insert( 1 );
getKSession().getWorkingMemoryEntryPoint( "in_SepalWid" ).insert( 30 );
@@ -414,9 +413,6 @@ public void testMultipleModels() throws Exception {
// one question for each model is not answered
getKSession().fireAllRules();
- System.err.println(reportWMObjects(getKSession()));
-
-
checkFirstDataFieldOfTypeStatus( petalNumType, false, false, "Neuiris", 4 );
assertEquals( 2, getKSession().getObjects( new ClassObjectFilter( InvalidAnswer.class ) ).size() );
@@ -427,13 +423,12 @@ public void testMultipleModels() throws Exception {
System.out.println("\n\n\n\n\n\n\n\n Before 2 \n");
- Answer ans1 = new Answer(getQId("Neuiris","Feat2"),"40");
+ Answer ans1 = new Answer(getQId("Neuiris","PetalNum"),"40");
getKSession().insert(ans1);
getKSession().fireAllRules();
-// System.err.println(reportWMObjects(getKSession()));
-
+ System.err.println(reportWMObjects(getKSession()));
checkFirstDataFieldOfTypeStatus(petalNumType,true,false,"Neuiris",40);
@@ -450,7 +445,7 @@ public void testMultipleModels() throws Exception {
System.out.println("\n\n\n\n\n\n\n\n Before 3 \n");
- Answer ans2 = new Answer(getQId("Neuiris","Feat2"),"-7");
+ Answer ans2 = new Answer(getQId("Neuiris","PetalNum"),"-7");
getKSession().insert(ans2);
getKSession().fireAllRules();
@@ -477,7 +472,7 @@ public void testMultipleModels() throws Exception {
//
//
//
- Answer ans3 = new Answer(getQId("Neuiris","Feat2"),"101");
+ Answer ans3 = new Answer(getQId("Neuiris","PetalNum"),"101");
getKSession().insert(ans3);
getKSession().fireAllRules();
View
6 drools-pmml/src/test/resources/org/drools/pmml/pmml_4_1/test_ann_iris_prediction.xml
@@ -1,7 +1,7 @@
<PMML version="4.1" xsi:schemaLocation="http://www.dmg.org/PMML-4_1 http://www.dmg.org/v4-1/pmml-4-1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.dmg.org/PMML-4_1">
<Header copyright="JBoss"/>
<DataDictionary numberOfFields="5">
- <DataField dataType="integer" displayName="Number of Petals" name="Feat2" optype="continuous">
+ <DataField dataType="integer" displayName="Number of Petals" name="petal num" optype="continuous">
<Value value="101"/>
<Value value="102"/>
<Value value="103"/>
@@ -39,7 +39,7 @@
<Surveyable/>
</Extension>
<MiningSchema>
- <MiningField name="Feat2"/>
+ <MiningField name="petal num"/>
<MiningField name="petal wid"/>
<MiningField name="sepal wid"/>
<MiningField name="species"/>
@@ -51,7 +51,7 @@
<NeuralInputs>
<NeuralInput id="0">
<DerivedField dataType="double" optype="continuous">
- <NormContinuous field="Feat2">
+ <NormContinuous field="petal num">
<LinearNorm norm="0" orig="100"/>
<LinearNorm norm="0.5" orig="101"/>
<LinearNorm norm="1" orig="102"/>

0 comments on commit 4d78b0a

Please sign in to comment.
Something went wrong with that request. Please try again.