I think Balakrishnan Prasath wrote: > hello all, > > Is it possible to do a wild card search in Jess. If so how..
I had to think a bit to figure out what you meant. I'm guessing you want to rewrite the query below so that "?word" can be something like "th*" to match all the words that start with "th". Jess 6 doesn't have any kind of regular expression matching built in, although Jess 7 will. For the time being, you could write a Userfunction which used the java.lang.regexp package to do regular expression matching, and then use it in your query. Here's a simple version of such a Userfunction (requires JDK 1.4:) class RegexpMatch implements Userfunction { private static HashMap s_patterns = new HashMap(); public String getName() { return "regexp"; } public Value call(ValueVector vv, Context context) throws JessException { String expression = vv.get(1).stringValue(context); String trial = vv.get(2).stringValue(context); Pattern regex = getPattern(expression); boolean match = regex.matcher(trial).matches(); return match ? Funcall.TRUE : Funcall.FALSE; } private Pattern getPattern(String expression) { Pattern p = (Pattern) s_patterns.get(expression); if (p == null) p = Pattern.compile(expression); return p; } } It could be used like this: (defquery q_wn_hyp (declare (variables ?expr)) (wn_sense (syn_id ?hypid) (word ?o&:(regexp ?expr ?o))) (wn_hyp (hypo_id ?hypid) (hyper_id ?hyperid)) ) This would let you use Java's full regexp language for matching. --------------------------------------------------------- Ernest Friedman-Hill Science and Engineering PSEs Phone: (925) 294-2154 Sandia National Labs FAX: (925) 294-2234 PO Box 969, MS 9012 [EMAIL PROTECTED] Livermore, CA 94550 http://herzberg.ca.sandia.gov -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------