Drools as Lexer / Parser (sequential data processing)
by André Thieme
Hello group, I recently had the idea:
"A rule system (like Drools) is ideal for making programs with complex
rules simpler. Writing a lexer or parser can be non-trivial. So, is it
possible and also meaningful to express such a task with rules?"
Anyone here who maybe tried that already?
The two big questions for me are:
1) how easy is it to express a lexer with rules?
2) how bad (good?) will it perform?
If you happen to have a good idea of how to do it, could you please give
me an example for a simple lexer?
Let's say it will get natural language (a string, such as this email) as
input and should return a sequence (say, ArrayList) of Tokens, which may
look like this:
public class Token {
public String value;
public String category;
Token(String value, String category) {
this.value = value;
this.category = category;
}
}
We could have three categories:
"word", "numeric" and "whitespace".
An input String could be:
"We can see 500 cars"
And it should produce an ArrayList with the contents:
[
Token("We", "word"),
Token(" ", "whitespace"),
Token("can", "word"),
Token(" ", "whitespace"),
Token("see", "word"),
Token(" ", "whitespace"),
Token("500", "numeric"),
Token(" ", "whitespace"),
Token("cars", "word")
]
At the moment I have difficulties to see if/how this could be achieved.
If you find this easy, please post a solution.
I am aware that JavaCC is really good for such tasks and will also
perform extremly well.
Greetings,
André
16 years, 8 months
retrieving streams/entry points from java api
by Chris Richmond
Hello,
I am trying to determine, iterate the working memory streams within my rule
by doing the following:
for(WorkingMemoryEntryPoint entry :
session.getWorkingMemoryEntryPoints()){
System.err.println("entry point stream:
" + entry.toString());
}
But I can find no method/way to finid the actual text name of the entry
point(what is written in the rule as from entry-point "xxxx").
Is there a way to do this? To list the readable names of the entry points
from your session? I would like to list those entry points in a drop down
as application profiles, so if they have one selected, one entry point of
rules will be inserted to and so on..
Thanks,
Chris
16 years, 8 months
Re: [rules-users] unable to determine value type class *** URGENT***
by Corneil du Plessis
Srithu wrote:
>
> I have a wired behavior..
>
> I have a set of rules and i have used drools-guvnor to packaging them...
> It is working in windows machines where i have jboss which is running on
> IBM java 5 and 6..
>
> When i connect the same from jboss Which is running on 64 bit IBM java 6
> on linux is not working...
> The same is working If i used 64 bit IBM java 5 on linux.....
>
>
> I getting following exception...
>
>
>
> Please help....
>
>>> [2009-02-11 12:30:29,697] [705980] [http-0.0.0.0-8080-12] [ERROR]
>>> [STDERR ] - org.drools.RuntimeDroolsException: unable to determine
>>> ValueType for Class [class java.lang.Object]
>
>>> [2009-02-11 12:30:29,698] [705981] [http-0.0.0.0-8080-12] [ERROR]
>>> [STDERR ] - at
>>> org.drools.base.ValueType.determineValueType(ValueType.java:193)
>
>>> [2009-02-11 12:30:29,698] [705981] [http-0.0.0.0-8080-12] [ERROR]
>>> [STDERR ] - at
>>> org.drools.base.ValueType.readResolve(ValueType.java:125)
>
>>> [2009-02-11 12:30:29,698] [705981] [http-0.0.0.0-8080-12] [ERROR]
>>> [STDERR ] - at
>>> sun.reflect.GeneratedMethodAccessor121.invoke(Unknown Source)
>
>>> [2009 -02-11 12:30:29,698] [705981] [http-0.0.0.0-8080-12]
>>> [ERROR] [STDERR ] - at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>
>>> [2009-02-11 12:30:29,698] [705981] [http-0.0.0.0-8080-12] [ERROR]
>>> [STDERR ] - at java.lang.reflect.Method.invoke(Method.java:599)
>
> [deleted stacktrace]
>
>
We are experiencing same issue on WebSphere 6.1 FP 23 on Linux and AIX.
Has anyone found a resolution?
Regards
Corneil
--
View this message in context: http://www.nabble.com/unable-to-determine-value-type-class--***-URGENT***...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 8 months
Conversion from Normal Decision Tables to Web-Based Tables and vice-versa
by Vikrant Yagnick
Hi All,
I am wondering if anyone has had a requirement where they would need to convert their normal decision tables into web-based decision tables(or vice-versa).
If someone has already done this, can they share either some code or pointers to how this can be done? (I guess it will involving parsing the Excel and creating the XML for the decision table).
Will this be a useful feature to have?
Cheers,
Vikrant
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 years, 8 months
Problem in accessing change-set.xml for decision table entry
by Nikhil S. Kulkarni
Hi,
I am using Drools 5
I am facing following issue :-
While trying to access change-set.xml with decision table entry, I am getting NULLPOINTEREXCEPTION
Following code is change-set.xml :-
e.g.
<?xml version="1.0" encoding="UTF-8"?>
<change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set.xsd'>
<add>
<resource source='classpath:data/abc.xls' type="DTABLE">
<decisiontable-conf input-type="XLS" worksheet-name="Tables" />
</resource>
</add>
</change-set>
Please Reply If anybody is able to access decision table in this way.
Waiting for Reply.
Thanks & Regards,
Nikhil S. Kulkarni
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 years, 8 months
Argument truncation in decision table
by Robert Morse
Hello,
I have a Seam (2.2.0.GA) application running under JBoss 5.1.0.GA.
This release of Seam uses the Drools 5.0.1.GA build. I'm implementing
a Decision Table for the first time and importing it into Guvnor (also
from the same distribution). One of the consequences of several
rules is to call a method that had eight arguments: (String, String,
Boolean, Boolean, Integer, String, String, String). When I attempted
to compile the rule set, the method was truncated after the fifth
(Integer) argument which obviously caused some compile issues. My
work around was to break this single method in to two methods, and it
works just fine.
The original method worked just fine when used in a DRL. Don't know
if there's a limit to function arguments within Decision Tables or if
this might be a bug.
-robert.
The human mind is an iterative processor, it never does anything right
the first time. What it does well is to make improvements on every
iteration (deMarco)
16 years, 8 months
Process variables in split/action nodes
by Renato Herebia
Hi!
How can I access process variables inside split nodes, in fact, in split
contraints?
I accessed a process variable named "count" in an action node like that:
Integer c = (Integer) kcontext.getVariable("count");
kcontext.setVariable("count", ++c);
But, in a split constraint doesn't work. So, my doubts are:
- How is the way in split constraints?
- Is there a simpler way to access process variables in action node?
Thanks!
--
Renato Herebia
16 years, 8 months
Drools Flow: waiting for process to complete without polling
by Alexandros Karypidis
Hello,
I'm not very experienced in the Drools Flow API so I'm looking into the
best way to code a simple thing: wait for all processes in a session to
complete without polling.
The only way I could thing of from the javadoc reference I read, is to
synchronize and do a wait()/notify() using a ProcessEventListener. It
seems a lot of work for a use-case that is too basic. I set up a
listener like this:
pel = new ProcessEventListener() {
// ...
public void afterProcessCompleted(ProcessCompletedEvent pce) {
synchronized (this) {
notifyAll();
}
}
}
ksession.addEventListener(pel);
...then wait for processes (one in this simplified case) to complete
like this:
synchronized (pel) {
new Thread(new Runnable() {
public void run() {
ksession.fireUntilHalt();
}
}).start();
ksession.startProcess("some.process");
pel.wait(); // the notifyAll() resumes this
}
Is there a better way to do this?
16 years, 8 months
(no subject)
by Steve Ronderos
Hello Drools Users,
I've been looking into why Drools 5 is logging debug and info messages to
System.out in my app and trying to figure out how to make it stop. It
looks like the SystemEventListener that the SystemEventListenerFactory
returns is a DelegatingSystemEventListener that delegates to a
PrintStreamSystemEventListener. This, by default, uses System.out as the
print stream target. I looked into the Factory and it looks like I can
provide a different SystemEventListener or SystemEventListenerProvider,
but it also mentions that it did not find anything in the properties, so
it fails over to the default SystemEventListenerProvider. Is there a way
to configure a custom SystemEventListener or SystemEventListenerProvider
so that you don't have to call
SystemEventListenerFactory.setSystemEventListenerProvider() at startup?
Thanks,
Steve Ronderos
16 years, 8 months
Null-safe traversal of nested sparse maps?
by Dave Schweisguth
Dear fellow Droolers,
[Sorry to repeat myself, but I thought this question might have gotten
missed at the bottom of my other one.]
One of my facts' properties, "attributes", is a Map of Map of String.
Unfortunately the second level of keys is sparse. If the attribute I want is
present,
Fact(attributes.KeyOne.KeyTwo == 42)
looks and works great. If KeyTwo is absent, however, I get
org.drools.RuntimeDroolsException: Exception executing predicate attributes.KeyOne.KeyTwo == 42 [...] Caused by: [Error: unable to resolve method: java.util.HashMap.KeyTwo() [arglength=0]] [Near : {... Unknown ....}]
The best syntax I've found which is null-safe is
Fact(attributes.KeyOne["KeyTwo"] == 42)
which works but hurts the eyes somewhat. I'm not clear whether MVEL-style
null-safe traversal should work here; my experiments suggest it does not.
Any suggestions?
Thanks,
--
| Dave Schweisguth http://schweisguth.org/~dave/ |
| Home: dave at schweisguth.org Work: http://www.nileguide.com/ |
| For compliance with the NJ Right to Know Act: Contents partially unknown |
16 years, 9 months