Re: [rules-users] wordnet in drools

2008-07-09 Thread Mark Proctor
I would imagine that the performance issues are due to emulating 
backward chaining/query like behaviour in a forward chaining engine. I 
imagine this is also true with regards to the email one question about 
Transitive Closures. We need to build in support for proper backward 
chaining querries to get an equal comparison on performance.


Mark
Paul Fodor wrote:

I am new to Drools and I wonder if anyone used WordNet from Drools.
Basically, I want to make some simple joins, such as, find words that
are in the same synset, all hypernyms of a word, hyponyms, meronyms of
verbs, adjectives, etc.
  


  

I haven't heard of it being applied with Drools. Do let me know your
findings if you produce anything interesting.



Hi Mark,
We couldn't find any implementation for WordNet from Drools, so we
wrote an implementation. Anyone, please feel free to use it (attached
below). If you want some additional functions, feel free to let me
know. It is an interface to WordNet for Drools using a SQL database
(MySQL). The computation times are pretty good compared with other
Java based rule engines, but an order of magnitude slower than C-based
Prolog systems. I wonder if this is not an indexing problem for Java
objects (we create about 300,000 instances of the same class to store
the WordNet ontology). We can also consult the database directly
(without putting the WordNet ontology in JVM), but that is slower than
having all objects in main memory (beside the same tests for the
Prolog systems had the whole ontology in the main memory, so we want
to do the same for Drools).
Regards,
Paul Fodor

WordNetInterface_rules.drl:

package drools

import drools.WordNetInterface.S;
import drools.WordNetInterface.G;
import drools.WordNetInterface.Hyp;
import drools.WordNetInterface.Mm;
import drools.WordNetInterface.Ent;
import drools.WordNetInterface.Sim;
import drools.WordNetInterface.Ant;
import drools.WordNetInterface.Reach;

rule CoordinateTerms
salience 10
when
s1 : S( si : synset_id, w1 : word)
s2 : S( synset_id == si, word != w1, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllGlosses
salience 10
when
s : S( si : synset_id, w : word)
g : G( synset_id == si, gl : gloss)
then
insert( new Reach(w,gl) );
//System.out.println( Reach  + w + , + gl );
end

rule testAllHypernyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
h : Hyp( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllHyponyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
h : Hyp( synset_id2 == si1, si2 : synset_id1)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllMeronyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
m : Mm( synset_id2 == si1, si2 : synset_id1)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllHolonyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
m : Mm( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllTroponyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
en : Ent( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
// System.out.println( Reach  + w1 + , + w2 );
end

rule testAllSimilars
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
sim1 : Sim( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllAntonyms
salience 10
when
s1 : S( si1 : synset_id, w_n1 : w_num, w1 : word)
a : Ant( synset_id1 == si1, w_num1 == w_n1, si2 : synset_id2,
w_n2 : w_num2)
s2 : S( synset_id == si2, w_num == w_n2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

WordNetInterface.java:

package drools;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.base.RuleNameEqualsAgendaFilter;
import org.drools.compiler.PackageBuilder;
import 

Re: [rules-users] wordnet in drools

2008-07-08 Thread Paul Fodor
 I am new to Drools and I wonder if anyone used WordNet from Drools.
 Basically, I want to make some simple joins, such as, find words that
 are in the same synset, all hypernyms of a word, hyponyms, meronyms of
 verbs, adjectives, etc.

 I haven't heard of it being applied with Drools. Do let me know your
 findings if you produce anything interesting.

Hi Mark,
We couldn't find any implementation for WordNet from Drools, so we
wrote an implementation. Anyone, please feel free to use it (attached
below). If you want some additional functions, feel free to let me
know. It is an interface to WordNet for Drools using a SQL database
(MySQL). The computation times are pretty good compared with other
Java based rule engines, but an order of magnitude slower than C-based
Prolog systems. I wonder if this is not an indexing problem for Java
objects (we create about 300,000 instances of the same class to store
the WordNet ontology). We can also consult the database directly
(without putting the WordNet ontology in JVM), but that is slower than
having all objects in main memory (beside the same tests for the
Prolog systems had the whole ontology in the main memory, so we want
to do the same for Drools).
Regards,
Paul Fodor

WordNetInterface_rules.drl:

package drools

import drools.WordNetInterface.S;
import drools.WordNetInterface.G;
import drools.WordNetInterface.Hyp;
import drools.WordNetInterface.Mm;
import drools.WordNetInterface.Ent;
import drools.WordNetInterface.Sim;
import drools.WordNetInterface.Ant;
import drools.WordNetInterface.Reach;

rule CoordinateTerms
salience 10
when
s1 : S( si : synset_id, w1 : word)
s2 : S( synset_id == si, word != w1, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllGlosses
salience 10
when
s : S( si : synset_id, w : word)
g : G( synset_id == si, gl : gloss)
then
insert( new Reach(w,gl) );
//System.out.println( Reach  + w + , + gl );
end

rule testAllHypernyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
h : Hyp( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllHyponyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
h : Hyp( synset_id2 == si1, si2 : synset_id1)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllMeronyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
m : Mm( synset_id2 == si1, si2 : synset_id1)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllHolonyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
m : Mm( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllTroponyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
en : Ent( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
// System.out.println( Reach  + w1 + , + w2 );
end

rule testAllSimilars
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
sim1 : Sim( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllAntonyms
salience 10
when
s1 : S( si1 : synset_id, w_n1 : w_num, w1 : word)
a : Ant( synset_id1 == si1, w_num1 == w_n1, si2 : synset_id2,
w_n2 : w_num2)
s2 : S( synset_id == si2, w_num == w_n2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

WordNetInterface.java:

package drools;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.base.RuleNameEqualsAgendaFilter;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.spi.AgendaFilter;

public class WordNetInterface {
public static void main(final String[] args) throws Exception {
int test = 1; // 1-CoordinateTerms, 2-testAllGlosses,
3-testAllHypernyms, 4-testAllHyponyms, 5-testAllMeronyms,
6-testAllHolonyms, 7-testAllTroponyms, 8-testAllSimilars,
9-testAllAntonyms
String 

Re: [rules-users] wordnet in drools

2008-07-08 Thread Mark Proctor
When I get the chance I'll look over it and see how we can improve 
performance.


Would you like to write a blog for this work and we'll put it up at 
http://blog.athico.com


Mark
Paul Fodor wrote:

I am new to Drools and I wonder if anyone used WordNet from Drools.
Basically, I want to make some simple joins, such as, find words that
are in the same synset, all hypernyms of a word, hyponyms, meronyms of
verbs, adjectives, etc.
  


  

I haven't heard of it being applied with Drools. Do let me know your
findings if you produce anything interesting.



Hi Mark,
We couldn't find any implementation for WordNet from Drools, so we
wrote an implementation. Anyone, please feel free to use it (attached
below). If you want some additional functions, feel free to let me
know. It is an interface to WordNet for Drools using a SQL database
(MySQL). The computation times are pretty good compared with other
Java based rule engines, but an order of magnitude slower than C-based
Prolog systems. I wonder if this is not an indexing problem for Java
objects (we create about 300,000 instances of the same class to store
the WordNet ontology). We can also consult the database directly
(without putting the WordNet ontology in JVM), but that is slower than
having all objects in main memory (beside the same tests for the
Prolog systems had the whole ontology in the main memory, so we want
to do the same for Drools).
Regards,
Paul Fodor

WordNetInterface_rules.drl:

package drools

import drools.WordNetInterface.S;
import drools.WordNetInterface.G;
import drools.WordNetInterface.Hyp;
import drools.WordNetInterface.Mm;
import drools.WordNetInterface.Ent;
import drools.WordNetInterface.Sim;
import drools.WordNetInterface.Ant;
import drools.WordNetInterface.Reach;

rule CoordinateTerms
salience 10
when
s1 : S( si : synset_id, w1 : word)
s2 : S( synset_id == si, word != w1, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllGlosses
salience 10
when
s : S( si : synset_id, w : word)
g : G( synset_id == si, gl : gloss)
then
insert( new Reach(w,gl) );
//System.out.println( Reach  + w + , + gl );
end

rule testAllHypernyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
h : Hyp( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllHyponyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
h : Hyp( synset_id2 == si1, si2 : synset_id1)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllMeronyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
m : Mm( synset_id2 == si1, si2 : synset_id1)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllHolonyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
m : Mm( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllTroponyms
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
en : Ent( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
// System.out.println( Reach  + w1 + , + w2 );
end

rule testAllSimilars
salience 10
when
s1 : S( si1 : synset_id, w1 : word)
sim1 : Sim( synset_id1 == si1, si2 : synset_id2)
s2 : S( synset_id == si2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

rule testAllAntonyms
salience 10
when
s1 : S( si1 : synset_id, w_n1 : w_num, w1 : word)
a : Ant( synset_id1 == si1, w_num1 == w_n1, si2 : synset_id2,
w_n2 : w_num2)
s2 : S( synset_id == si2, w_num == w_n2, w2 : word)
then
insert( new Reach(w1,w2) );
//System.out.println( Reach  + w1 + , + w2 );
end

WordNetInterface.java:

package drools;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.base.RuleNameEqualsAgendaFilter;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.spi.AgendaFilter;

public class WordNetInterface {
public static void main(final String[] args) throws Exception {
   

Re: [rules-users] wordnet in drools

2008-07-02 Thread Mark Proctor

Paul Fodor wrote:

Dear Sir,

I am new to Drools and I wonder if anyone used WordNet from Drools.
Basically, I want to make some simple joins, such as, find words that
are in the same synset, all hypernyms of a word, hyponyms, meronyms of
verbs, adjectives, etc.
  
I haven't heard of it being applied with Drools. Do let me know your 
findings if you produce anything interesting.

 Regards,
  Paul Fodor
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

  


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users