[Javamatch-cvs] javamatch/src/net/sourceforge/javamatch/engine MatchEngine.java,1.3,1.4 MatchResult.
Status: Pre-Alpha
Brought to you by:
iterson
From: Walter v. I. <it...@us...> - 2004-09-13 09:14:22
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5800/javamatch/engine Modified Files: MatchEngine.java MatchResult.java Log Message: Added threshold value, minimum match value for objects to be included Index: MatchEngine.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/MatchEngine.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MatchEngine.java 10 Sep 2004 14:22:17 -0000 1.3 --- MatchEngine.java 13 Sep 2004 09:14:11 -0000 1.4 *************** *** 36,39 **** --- 36,43 ---- private int maxNumResultItems = 10; + /** The threshold value, the minimum value that each sub-query shoud have, + to be included in the match result */ + private float threshold = 0f; + /** * Executes the specified match query on all objects in the given List. *************** *** 94,97 **** --- 98,102 ---- MatchResult result = new MatchResult(this); result.setMaxNumResultItems(maxNumResultItems); + result.setThreshold(threshold); while (dataIterator1.hasNext()) { Object curItem = dataIterator1.next(); *************** *** 107,110 **** --- 112,125 ---- } + /** + * Sets the threshold value, the minimum value that each sub-query shoud have, + * to be included in the match result + * @param threshold the threshold, the minimum query result value before an + * object is included in the MatchResult + */ + public void setThreshold(float threshold) { + this.threshold = threshold; + } + /** * Retrieves and returns the object or object with the given identifier from Index: MatchResult.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/MatchResult.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MatchResult.java 9 Sep 2004 14:18:58 -0000 1.3 --- MatchResult.java 13 Sep 2004 09:14:11 -0000 1.4 *************** *** 37,40 **** --- 37,44 ---- private MatchEngine matchEngine; + /** The threshold, the minimum match value before an object is included in + this MatchResult */ + private float threshold; + /** * Creates a new MatchResult *************** *** 58,61 **** --- 62,69 ---- throw new NullPointerException("Can't add null matched object"); } + if (matchValue < threshold) { + matchEngine.discardObject(matchedObject); + return; + } int numItems = resultItems.size(); // don't search when list is already full, and the match value is lower *************** *** 92,95 **** --- 100,120 ---- } + /** + * Sets the threshold value, the minimum value that each sub-query shoud have, + * to be included in the match result. This method is only valid when no + * ResultItems have been added. + * @param threshold the threshold, the minimum query result value before an + * object is included in the MatchResult + * @throws IllegalStateException when ResultItems have been added before + * this method is called + */ + public void setThreshold(float threshold) { + if (resultItems.size() > 0) { + throw new IllegalStateException("Can't set size of MatchResult " + + "after items have been added"); + } + this.threshold = threshold; + } + /** * Sets the maximum number of result items in this MatchResult. This method |