Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #4 from reynoldsm88/master
Browse files Browse the repository at this point in the history
First pass at porting the learner code to 7.x
  • Loading branch information
mariofusco committed Mar 29, 2017
2 parents a4187a5 + a06812a commit 7b8f195
Show file tree
Hide file tree
Showing 92 changed files with 10,020 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/target
/local

# Eclipse, Netbeans and IntelliJ files
/.*
!.gitignore
/nbproject
/*.ipr
/*.iws
/*.iml

# Repository wide ignore mac DS_Store files
.DS_Store

# generated files
dependency-reduced-pom.xml

# these modules don't exist anymore on master
/drools-clips/
Binary file not shown.
32 changes: 32 additions & 0 deletions machinelearning/7.0.x/drools-learner/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions machinelearning/7.0.x/drools-learner/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
23 changes: 23 additions & 0 deletions machinelearning/7.0.x/drools-learner/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>drools-learner</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//target/generated-sources/annotations=UTF-8
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
96 changes: 96 additions & 0 deletions machinelearning/7.0.x/drools-learner/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.drools</groupId>
<artifactId>drools</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>

<artifactId>drools-learner</artifactId>

<name>Drools :: Learner</name>

<properties>
<surefire.forkCount>2</surefire.forkCount>
</properties>

<dependencies>
<!-- Internal dependencies -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-internal</artifactId>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency><!-- For unit test logging: configure in src/test/resources/logback-test.xml -->
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>

<!-- test: byteman -->
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman-submit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman-install</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.byteman</groupId>
<artifactId>byteman-bmunit</artifactId>
<scope>test</scope>
</dependency>

<!-- Required for TestListener in maven-surefire-plugin. -->
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-test-util</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<pluginManagement>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<properties>
<property>
<name>listener</name>
<value>org.kie.test.util.TestStatusListener</value>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.drools.learner;

public class Attribute {

private String name;
private Object value;

//final ClassFieldExtractor extractor = cache.getExtractor( class_obj, f_name, getClass().getClassLoader() );

public String getName() {
return name;
}

public void setName( String name ) {
this.name = name;
}

public Object getValue() {
return value;
}

public void setValue( Object value ) {
this.value = value;
}

/* we assume that "another" points to the same attribute type as this */
public int compareValue( Attribute another ) {
/* Boolean, Double, Integer, String... */
return AttributeValueComparator.instance.compare( getValue(), another.getValue() );
}

public int hashCode() {
return this.value.hashCode();
}

public String toString() {
return value.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.drools.learner;

import java.util.Comparator;

public class AttributeValueComparator implements Comparator<Object> {

/* we assume that "another" points to the same attribute type as this */
public int compare( Object value1, Object value2 ) {
if ( value1 instanceof Comparable ) {
return ( (Comparable) value1 ).compareTo( value2 ); // Boolean, Double, Integer, String...
}
return value1.hashCode() - value2.hashCode();
}

// singleton wannabe
public static AttributeValueComparator instance = new AttributeValueComparator();
}
Loading

0 comments on commit 7b8f195

Please sign in to comment.