#6 BooleanEvaluator needed

pending
nobody
boolean (1)
FeatureRequest
Rejected
2014-05-27
2013-12-09
Anonymous
No

The double evaluator is great!
It would be nice to have a Boolean one too. I'm using the dynamic java class compiler suggested by http://www.beyondlinux.com/2011/07/20/3-steps-to-dynamically-compile-instantiate-and-run-a-java-class/ and it works, but I was hoping from something more direct and elegant.
For example:

String text = "I am a java programmer.\n"+ // BTW, String.contains() IS case sensitive!
"Read about hadoop.\n"+
"Doing big data right now.";

String booleanString = "(\"java\"\n"
+"AND \"hadoop\"\n"
+"AND (\"big data\"\n"
+"OR \"analytic\")\n"
+"AND NOT \"cobol\")";

Which translates to:

booleanCode=(text.contains("java")
&& text.contains("hadoop")
&& (text.contains("big data")
|| text.contains("analytic"))
&& !text.contains("recruiting"))

Then I magically (i.e. indirectly) turn the above into the following code string and data into:

public class BooleanEvaluator {
public static String text = "I am a Java programmer.\n"+
"Read about hadoop.\n"+
"Doing big data right now.";
;
public boolean booleanEval() {
System.out.println("text="+text);
return (text.contains("java")
&& text.contains("hadoop")
&& (text.contains("big data")
|| text.contains("analytic"))
&& !text.contains("recruiting"));
}
public static void main(String[] args) {
BooleanEvaluator cal = new BooleanEvaluator();
cal.booleanEval();
}
}

Which I automagically compile and run to get:
runIt: packageDotClassName=recruit.g2.com.BooleanEvaluator methodName=booleanEval

Result = true

Whew!!!

Discussion

  • Fathzer

    Fathzer - 2013-12-12

    I'm not sure to understand the need.

    It seems like you're looking for a class that evaluates expressions like: "contains(x,'java') && contains(x,'hadoop') && contains(x,'big data') || contains(x,'analytic') && !contains(x,'recruiting'). Where x is a variable (see http://javaluator.soft.fathzer.com/en/doc/tutorial.php?chapter=variables) containing a text like "I am a java programmer.\nRead about hadoop.\nDoing big data right now."

    You can implement such a thing using a custom evaluator (see http://javaluator.soft.fathzer.com/en/doc/tutorial.php?chapter=creatingSimple). It should implements a 'contains' function (see http://javaluator.soft.fathzer.com/en/doc/tutorial.php?chapter=extending to see how to implement functions). It should work not only on boolean, but also on strings ('recruiting', 'analytics', etc... are not booleans).

    After thinking about it:
    - If you're trying to evaluate a text ranking, probably a boolean function is not the best solution (usually this kind of functionnalities works with probabilities).
    - If someone is interested in writing a 'excel like' evaluator, dealing with boolean, string, numbers, date, etc... I would be very happy to publish that class in a separate jar (to keep core javaluator small).

     
    Last edit: Fathzer 2014-05-27
  • Fathzer

    Fathzer - 2014-05-27
    • status: open --> pending
    • Reply: None --> Rejected
     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks