javamatch-cvs Mailing List for JavaMatch match engine (Page 2)
Status: Pre-Alpha
Brought to you by:
iterson
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(70) |
Oct
(4) |
Nov
|
Dec
|
---|
From: Walter v. I. <it...@us...> - 2004-09-13 13:39:33
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22101/src/net/sourceforge/javamatch/query/test Modified Files: QuerySetTest.java Log Message: Remove "Query" from addRequired and addPreferred Index: QuerySetTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/QuerySetTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QuerySetTest.java 13 Sep 2004 11:32:19 -0000 1.1 --- QuerySetTest.java 13 Sep 2004 13:39:24 -0000 1.2 *************** *** 33,37 **** QuerySet curQuery = new QuerySet(); try { ! curQuery.addRequiredQuery(null); fail("Shouldn't be able to add null required Query"); } catch (NullPointerException npe) { --- 33,37 ---- QuerySet curQuery = new QuerySet(); try { ! curQuery.addRequired(null); fail("Shouldn't be able to add null required Query"); } catch (NullPointerException npe) { *************** *** 44,50 **** MatchMock match = new MatchMock(); match.setTwoPass(true); ! curQuery.addRequiredQuery(match); ! curQuery.addRequiredQuery(new ConstantMatch(0.4f)); ! curQuery.addRequiredQuery(new ConstantMatch(0.3f)); assertTrue(curQuery.isTwoPass()); } --- 44,50 ---- MatchMock match = new MatchMock(); match.setTwoPass(true); ! curQuery.addRequired(match); ! curQuery.addRequired(new ConstantMatch(0.4f)); ! curQuery.addRequired(new ConstantMatch(0.3f)); assertTrue(curQuery.isTwoPass()); } *************** *** 52,57 **** public void testNoTwoPassRequired() { QuerySet curQuery = new QuerySet(); ! curQuery.addRequiredQuery(new ConstantMatch(0.4f)); ! curQuery.addRequiredQuery(new ConstantMatch(0.3f)); assertFalse(curQuery.isTwoPass()); } --- 52,57 ---- public void testNoTwoPassRequired() { QuerySet curQuery = new QuerySet(); ! curQuery.addRequired(new ConstantMatch(0.4f)); ! curQuery.addRequired(new ConstantMatch(0.3f)); assertFalse(curQuery.isTwoPass()); } *************** *** 61,65 **** QuerySet curQuery = new QuerySet(); try { ! curQuery.addPreferredQuery(null); fail("Shouldn't be able to add null preferred Query"); } catch (NullPointerException npe) { --- 61,65 ---- QuerySet curQuery = new QuerySet(); try { ! curQuery.addPreferred(null); fail("Shouldn't be able to add null preferred Query"); } catch (NullPointerException npe) { *************** *** 71,75 **** QuerySet curQuery = new QuerySet(); try { ! curQuery.addPreferredQuery(null, 1f); fail("Shouldn't be able to add null preferred Query"); } catch (NullPointerException npe) { --- 71,75 ---- QuerySet curQuery = new QuerySet(); try { ! curQuery.addPreferred(null, 1f); fail("Shouldn't be able to add null preferred Query"); } catch (NullPointerException npe) { *************** *** 82,88 **** MatchMock match = new MatchMock(); match.setTwoPass(true); ! curQuery.addPreferredQuery(match); ! curQuery.addPreferredQuery(new ConstantMatch(0.4f)); ! curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertTrue(curQuery.isTwoPass()); } --- 82,88 ---- MatchMock match = new MatchMock(); match.setTwoPass(true); ! curQuery.addPreferred(match); ! curQuery.addPreferred(new ConstantMatch(0.4f)); ! curQuery.addPreferred(new ConstantMatch(0.3f)); assertTrue(curQuery.isTwoPass()); } *************** *** 90,95 **** public void testNoTwoPassPreferred() { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferredQuery(new ConstantMatch(0.4f)); ! curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertFalse(curQuery.isTwoPass()); } --- 90,95 ---- public void testNoTwoPassPreferred() { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferred(new ConstantMatch(0.4f)); ! curQuery.addPreferred(new ConstantMatch(0.3f)); assertFalse(curQuery.isTwoPass()); } *************** *** 98,103 **** try { QuerySet curQuery = new QuerySet(); ! curQuery.addRequiredQuery(new ConstantMatch(1.0f)); ! curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { --- 98,103 ---- try { QuerySet curQuery = new QuerySet(); ! curQuery.addRequired(new ConstantMatch(1.0f)); ! curQuery.addPreferred(new ConstantMatch(0.3f)); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { *************** *** 109,114 **** try { QuerySet curQuery = new QuerySet(); ! curQuery.addRequiredQuery(new ConstantMatch(0.9f)); ! curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertEquals(0.0f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { --- 109,114 ---- try { QuerySet curQuery = new QuerySet(); ! curQuery.addRequired(new ConstantMatch(0.9f)); ! curQuery.addPreferred(new ConstantMatch(0.3f)); assertEquals(0.0f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { *************** *** 120,124 **** try { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { --- 120,124 ---- try { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferred(new ConstantMatch(0.3f)); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { *************** *** 130,134 **** try { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferredQuery(new ConstantMatch(0.3f), 0.1f); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { --- 130,134 ---- try { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferred(new ConstantMatch(0.3f), 0.1f); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { *************** *** 140,145 **** try { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferredQuery(new ConstantMatch(0.3f)); ! curQuery.addPreferredQuery(new ConstantMatch(0.2f)); assertEquals(0.25f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { --- 140,145 ---- try { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferred(new ConstantMatch(0.3f)); ! curQuery.addPreferred(new ConstantMatch(0.2f)); assertEquals(0.25f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { *************** *** 151,156 **** try { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferredQuery(new ConstantMatch(0.5f)); ! curQuery.addPreferredQuery(new ConstantMatch(0.2f), 2f); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { --- 151,156 ---- try { QuerySet curQuery = new QuerySet(); ! curQuery.addPreferred(new ConstantMatch(0.5f)); ! curQuery.addPreferred(new ConstantMatch(0.2f), 2f); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { |
From: Walter v. I. <it...@us...> - 2004-09-13 13:39:33
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22101/src/net/sourceforge/javamatch/query Modified Files: QuerySet.java Log Message: Remove "Query" from addRequired and addPreferred Index: QuerySet.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/QuerySet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QuerySet.java 13 Sep 2004 11:32:19 -0000 1.1 --- QuerySet.java 13 Sep 2004 13:39:23 -0000 1.2 *************** *** 46,51 **** * @param query the subquery that is added to the list of preferred queries */ ! public void addPreferredQuery(MatchQuery query) { ! addPreferredQuery(query, 1f); } --- 46,51 ---- * @param query the subquery that is added to the list of preferred queries */ ! public void addPreferred(MatchQuery query) { ! addPreferred(query, 1f); } *************** *** 56,60 **** * @param weight the relative weight of this subquery */ ! public void addPreferredQuery(MatchQuery query, float weight) { if (query == null) { throw new NullPointerException("Can't add a null query"); --- 56,60 ---- * @param weight the relative weight of this subquery */ ! public void addPreferred(MatchQuery query, float weight) { if (query == null) { throw new NullPointerException("Can't add a null query"); *************** *** 67,71 **** * @param query the subquery that is added to the list of required queries */ ! public void addRequiredQuery(MatchQuery query) { if (query == null) { throw new NullPointerException("Can't add a null query"); --- 67,71 ---- * @param query the subquery that is added to the list of required queries */ ! public void addRequired(MatchQuery query) { if (query == null) { throw new NullPointerException("Can't add a null query"); |
From: Walter v. I. <it...@us...> - 2004-09-13 13:39:33
|
Update of /cvsroot/javamatch/javamatch/examples/camping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22101/examples/camping Modified Files: SiteFinder.java Log Message: Remove "Query" from addRequired and addPreferred Index: SiteFinder.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/examples/camping/SiteFinder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SiteFinder.java 13 Sep 2004 11:32:59 -0000 1.2 --- SiteFinder.java 13 Sep 2004 13:39:22 -0000 1.3 *************** *** 20,26 **** // build the match query tree QuerySet query = new QuerySet(); ! query.addPreferredQuery(new LessThan("size", 100)); // look for a small site ! query.addPreferredQuery(new NumberEquals("distanceToSwimmingPool", 0)); // with an on-site swimming pool ! query.addPreferredQuery(new Maximum("priceIndication")); // with the lowest price // execute the query --- 20,26 ---- // build the match query tree QuerySet query = new QuerySet(); ! query.addPreferred(new LessThan("size", 100)); // look for a small site ! query.addPreferred(new NumberEquals("distanceToSwimmingPool", 0)); // with an on-site swimming pool ! query.addPreferred(new Maximum("priceIndication")); // with the lowest price // execute the query |
From: Walter v. I. <it...@us...> - 2004-09-13 13:39:31
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22101/docs/website Modified Files: javamatch.xml Log Message: Remove "Query" from addRequired and addPreferred Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** javamatch.xml 13 Sep 2004 12:37:41 -0000 1.9 --- javamatch.xml 13 Sep 2004 13:39:22 -0000 1.10 *************** *** 38,44 **** </p> <pre class="source">QuerySet query = new QuerySet(); ! query.addPreferredQuery(new LessThan("size", 100)); ! query.addPreferredQuery(new NumberEquals("distanceToSwimmingPool", 0)); ! query.addPreferredQuery(new Minimum("priceIndication")); List campSites = guide.getCampSites(); --- 38,44 ---- </p> <pre class="source">QuerySet query = new QuerySet(); ! query.addPreferred(new LessThan("size", 100)); ! query.addPreferred(new NumberEquals("distanceToSwimmingPool", 0)); ! query.addPreferred(new Minimum("priceIndication")); List campSites = guide.getCampSites(); *************** *** 60,67 **** </p> <pre class="source">QuerySet query = new QuerySet(); ! query.addRequiredQuery(new StringEquals("brand", "BMW")); ! query.addPreferredQuery(new Range("buildYear", 1997, 2002)); ! query.addPreferredQuery(new LessThan("price", 10000)); ! query.addPreferredQuery(new LessThan("mileage", 80000)); List allCars = carData.getAllCars(); --- 60,67 ---- </p> <pre class="source">QuerySet query = new QuerySet(); ! query.addRequired(new StringEquals("brand", "BMW")); ! query.addPreferred(new Range("buildYear", 1997, 2002)); ! query.addPreferred(new LessThan("price", 10000)); ! query.addPreferred(new LessThan("mileage", 80000)); List allCars = carData.getAllCars(); |
From: Walter v. I. <it...@us...> - 2004-09-13 12:37:53
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10733 Modified Files: javamatch.xml Log Message: Added comparison with SODAQuery Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** javamatch.xml 13 Sep 2004 11:32:58 -0000 1.8 --- javamatch.xml 13 Sep 2004 12:37:41 -0000 1.9 *************** *** 261,277 **** <h3>I only want exact matches. How can I get them?</h3> <p> ! Exact matches can be specified using an AndList-query. However, if ! you only want exact results from your database, plain SQL might be a ! better alternative, as it is executed inside the database. That ! causes less overhead. </p> <h2>Usage</h2> - <h3>I get very little results. What's wrong?</h3> - <p> - Are you using an AndList instead of an OrList? The AndList means that - all sub-queries must match the specified criteria more than 80% (by default). - The OrList returns a higher value when at least one of the subqueries - matches. - </p> </page> <page title="Documentation" filebase="docs"> --- 261,270 ---- <h3>I only want exact matches. How can I get them?</h3> <p> ! Exact matches can be specified using the QuerySet.addRequiredQuery(). ! However, if you only want exact results from your database, plain SQL ! might be a better alternative, as it is executed inside the database. ! That causes less (processing and communication) overhead. </p> <h2>Usage</h2> </page> <page title="Documentation" filebase="docs"> *************** *** 293,300 **** </p> <p> ! Queries may be combined by using MatchList-queries (such as the OrList and the ! AndList). The OrList takes the (weighted) average of all subqueries, and returns ! that value. That way, the object that best matches all subqueries returns the ! highest match value. </p> <h3>Two-pass queries</h3> --- 286,292 ---- </p> <p> ! Queries may be combined by using QuerySet-queries. A QuerySet has a list of required ! and a list of preferred subqueries. When all required subqueries match completely, ! the object that best matches most preferred subqueries returns the highest match value. </p> <h3>Two-pass queries</h3> *************** *** 315,319 **** <h3>Persistent storage</h3> <ul> ! <li><a href="http://www.prevayler.org">Prevayler</a> (Persistence without database)</li> <li><a href="http://www.jdocentral.com">Java Data Objects</a> (standard for object-relational mapping)</li> <li><a href="http://www.hibernate.org/">Hibernate</a> (Object-relational mapping tool)</li> --- 307,311 ---- <h3>Persistent storage</h3> <ul> ! <li><a href="http://www.prevayler.org">Prevayler</a> (Persistence without database). See <a href="integration.html#prevayler">Integration with Prevayler</a> for an example</li> <li><a href="http://www.jdocentral.com">Java Data Objects</a> (standard for object-relational mapping)</li> <li><a href="http://www.hibernate.org/">Hibernate</a> (Object-relational mapping tool)</li> *************** *** 321,325 **** <h3>Object-oriented data access</h3> <ul> ! <li><a href="http://sodaquery.sourceforge.net">SODAQuery</a> (Searching data in object databases)</li> </ul> <h3>Object data retrieval</h3> --- 313,317 ---- <h3>Object-oriented data access</h3> <ul> ! <li><a href="http://sodaquery.sourceforge.net">SODAQuery</a> (Searching data in object databases). See the <a href="#sodaquery">comparison</a> below</li> </ul> <h3>Object data retrieval</h3> *************** *** 331,334 **** --- 323,399 ---- <li><a href="http://www.searchtools.com/info/database-search.html">Database searching</a></li> </ul> + <h2>Other technologies in depth</h2> + <a name="sodaquery"/> + <h3>SodaQuery</h3> + <p> + SODAQuery project summary:<br/> + <i>S.O.D.A. is a an object API to communicate with databases. The current + specification is focussed on queries. Goals are: type safety, object reuse, + minimum string use, programming language independance.</i> + </p> + <p> + The main differences and similarities between JavaMatch and + <a href="http://sodaquery.sourceforge.net">SODAQuery</a> are: + </p> + <p> + <b>Returned results</b><br/> + - SODA returns all objects that match the specified constraints.<br/> + - JavaMatch provides a QuerySet, that includes both a required and a preferred part. + The required part is similar to SODAQuery. Within the objects that match all + required subqueries, the engine looks for the objects that best match the + preferred subqueries. It returns the top 10 of the best matching objects, with + the best matching object first + </p> + <p> + <b>Comparison operators</b><br/> + - SODA"s Constraint interface has a fixed set of evaluation modes. + These can be mapped to / executed by the underlying database system.<br/> + - JavaMatch has a hierarchy of queries, that is executed in the Java Virtual Machine + </p> + <p> + <b>Customizable filtering</b><br/> + - SODA provides the Evaluation interface. When a query is executed, the + Evaluation acts as a final filter on the objects that are returned<br/> + - JavaMatch"s queries can be customized by subclassing class MatchQuery + </p> + <p> + <b>Programming language</b><br/> + - SODA is programming langage independant. Java (JDK version 1.0 and later) and C# are supported<br/> + - JavaMatch is Java-only (JDK version 1.4 and later) + </p> + <p> + <b>Limit usage of strings</b><br/> + - Applies to both systems, while providing maximum flexibility with respect to runtime dynamics<br/> + </p> + <p> + <b>Runtime member retrieval</b><br/> + - SODA has a Query interface, that describes how to descend from an object to its + members, and to put restrictions on those members<br/> + - JavaMatch"s Queries that retrieve object members have an argument "memberName" + in their contructor. This is the path that is followed to retrieve a member value + </p> + <p> + <b>Performance</b><br/> + - SODA"s constraints can be mapped to operators in the underlying + database. Therefore, they can be executed by the database itself. + The Evaluation leads to data transfer from the server to the client<br/> + - JavaMatch operates on the full set of objects. All data is sent from + the underlying data storage mechanism to the Java Virtual Machine + </p> + <p> + <b>Collections</b><br/> + - SODA uses an ObjectContainer as a bridge to the data structure<br/> + - JavaMatch operates on standard Java collection classes (java.util.List, java.util.Iterator) + </p> + <p> + <b>Data types</b><br/> + - SODA uses an ObjectSet to return the results<br/> + - JavaMatch returns its results as a java.util.List + </p> + <p> + <b>Memory</b><br/> + - SODA returns the objects one-at-a-time, so the entire database won"t be kept in memory<br/> + - JavaMatch returns a limited amount of results, so only the best matching objects are kept in memory + </p> </page> <page title="Integration" filebase="integration"> *************** *** 444,448 **** <tr> <td>20040913</td> ! <td>Added RegexMatches, BooleanEquals, threshold</td> </tr> <tr> --- 509,514 ---- <tr> <td>20040913</td> ! <td>Replaced MatchList, OrList, AndList with QuerySet. Added RegexMatches, ! BooleanEquals, threshold value. Added comparison with SODAQuery</td> </tr> <tr> |
From: Walter v. I. <it...@us...> - 2004-09-13 11:33:08
|
Update of /cvsroot/javamatch/javamatch/examples/camping In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30222/examples/camping Modified Files: SiteFinder.java Log Message: Replace MatchList, AndList, OrList with QuerySet Index: SiteFinder.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/examples/camping/SiteFinder.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** SiteFinder.java 3 Sep 2004 08:21:19 -0000 1.1.1.1 --- SiteFinder.java 13 Sep 2004 11:32:59 -0000 1.2 *************** *** 19,26 **** // build the match query tree ! OrList query = new OrList(); ! query.addMatchQuery(new LessThan("size", 100)); // look for a small site ! query.addMatchQuery(new NumberEquals("distanceToSwimmingPool", 0)); // with an on-site swimming pool ! query.addMatchQuery(new Maximum("priceIndication")); // with the lowest price // execute the query --- 19,26 ---- // build the match query tree ! QuerySet query = new QuerySet(); ! query.addPreferredQuery(new LessThan("size", 100)); // look for a small site ! query.addPreferredQuery(new NumberEquals("distanceToSwimmingPool", 0)); // with an on-site swimming pool ! query.addPreferredQuery(new Maximum("priceIndication")); // with the lowest price // execute the query |
From: Walter v. I. <it...@us...> - 2004-09-13 11:33:08
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30222/docs/website Modified Files: javamatch.xml Log Message: Replace MatchList, AndList, OrList with QuerySet Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** javamatch.xml 13 Sep 2004 09:17:40 -0000 1.7 --- javamatch.xml 13 Sep 2004 11:32:58 -0000 1.8 *************** *** 37,44 **** The following code defines and executes this match query: </p> ! <pre class="source">OrList query = new OrList(); ! query.addQuery(new LessThan("size", 100)); ! query.addQuery(new NumberEquals("distanceToSwimmingPool", 0)); ! query.addQuery(new Minimum("priceIndication")); List campSites = guide.getCampSites(); --- 37,44 ---- The following code defines and executes this match query: </p> ! <pre class="source">QuerySet query = new QuerySet(); ! query.addPreferredQuery(new LessThan("size", 100)); ! query.addPreferredQuery(new NumberEquals("distanceToSwimmingPool", 0)); ! query.addPreferredQuery(new Minimum("priceIndication")); List campSites = guide.getCampSites(); *************** *** 59,67 **** second-hand car, I can specify the following query: </p> ! <pre class="source">OrList query = new OrList(); ! query.addQuery(new StringEquals("brand", "BMW")); ! query.addQuery(new Range("buildYear", 1997, 2002)); ! query.addQuery(new LessThan("price", 10000)); ! query.addQuery(new LessThan("mileage", 80000)); List allCars = carData.getAllCars(); --- 59,67 ---- second-hand car, I can specify the following query: </p> ! <pre class="source">QuerySet query = new QuerySet(); ! query.addRequiredQuery(new StringEquals("brand", "BMW")); ! query.addPreferredQuery(new Range("buildYear", 1997, 2002)); ! query.addPreferredQuery(new LessThan("price", 10000)); ! query.addPreferredQuery(new LessThan("mileage", 80000)); List allCars = carData.getAllCars(); *************** *** 111,118 **** <tr> <td>0.75</td> ! <td><b><i>Alpha Romeo</i></b></td> <td>2000</td> ! <td>$7,800.00</td> ! <td>55,000</td> </tr> <tr> --- 111,118 ---- <tr> <td>0.75</td> ! <td>BMW</td> <td>2000</td> ! <td>$3,800.00</td> ! <td><b><i>120,000</i></b></td> </tr> <tr> |
From: Walter v. I. <it...@us...> - 2004-09-13 11:32:44
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30020/query/test Modified Files: TestAll.java Added Files: QuerySetTest.java Removed Files: MatchListStub.java MatchListTest.java OrListTest.java Log Message: Replace MatchList, AndList, OrList with QuerySet --- OrListTest.java DELETED --- --- MatchListTest.java DELETED --- Index: TestAll.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/TestAll.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestAll.java 13 Sep 2004 08:45:48 -0000 1.3 --- TestAll.java 13 Sep 2004 11:32:19 -0000 1.4 *************** *** 33,38 **** public static TestSuite suite() { TestSuite suite = new TestSuite(); ! suite.addTestSuite(OrListTest.class); ! suite.addTestSuite(MatchListTest.class); suite.addTestSuite(NumericQueryTest.class); suite.addTestSuite(NumberEqualsTest.class); --- 33,37 ---- public static TestSuite suite() { TestSuite suite = new TestSuite(); ! suite.addTestSuite(QuerySetTest.class); suite.addTestSuite(NumericQueryTest.class); suite.addTestSuite(NumberEqualsTest.class); --- MatchListStub.java DELETED --- --- NEW FILE: QuerySetTest.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query.test; import junit.framework.*; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; /** * Class QuerySetTest tests the QuerySet functionality */ public class QuerySetTest extends TestCase { public QuerySetTest(String name) { super(name); } public void testAddNullRequiredQuery() { QuerySet curQuery = new QuerySet(); try { curQuery.addRequiredQuery(null); fail("Shouldn't be able to add null required Query"); } catch (NullPointerException npe) { // should occur } } public void testTwoPassRequired() { QuerySet curQuery = new QuerySet(); MatchMock match = new MatchMock(); match.setTwoPass(true); curQuery.addRequiredQuery(match); curQuery.addRequiredQuery(new ConstantMatch(0.4f)); curQuery.addRequiredQuery(new ConstantMatch(0.3f)); assertTrue(curQuery.isTwoPass()); } public void testNoTwoPassRequired() { QuerySet curQuery = new QuerySet(); curQuery.addRequiredQuery(new ConstantMatch(0.4f)); curQuery.addRequiredQuery(new ConstantMatch(0.3f)); assertFalse(curQuery.isTwoPass()); } public void testAddNullPreferredQuery() { QuerySet curQuery = new QuerySet(); try { curQuery.addPreferredQuery(null); fail("Shouldn't be able to add null preferred Query"); } catch (NullPointerException npe) { // should occur } } public void testAddNullWeightedPreferredQuery() { QuerySet curQuery = new QuerySet(); try { curQuery.addPreferredQuery(null, 1f); fail("Shouldn't be able to add null preferred Query"); } catch (NullPointerException npe) { // should occur } } public void testTwoPassPreferred() { QuerySet curQuery = new QuerySet(); MatchMock match = new MatchMock(); match.setTwoPass(true); curQuery.addPreferredQuery(match); curQuery.addPreferredQuery(new ConstantMatch(0.4f)); curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertTrue(curQuery.isTwoPass()); } public void testNoTwoPassPreferred() { QuerySet curQuery = new QuerySet(); curQuery.addPreferredQuery(new ConstantMatch(0.4f)); curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertFalse(curQuery.isTwoPass()); } public void testRequiredMatch() { try { QuerySet curQuery = new QuerySet(); curQuery.addRequiredQuery(new ConstantMatch(1.0f)); curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { fail("unable to match"); } } public void testRequiredMismatch() { try { QuerySet curQuery = new QuerySet(); curQuery.addRequiredQuery(new ConstantMatch(0.9f)); curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertEquals(0.0f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { fail("unable to match"); } } public void testSingleValuePreferred() { try { QuerySet curQuery = new QuerySet(); curQuery.addPreferredQuery(new ConstantMatch(0.3f)); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { fail("unable to match"); } } public void testSingleWeighedValuePreferred() { try { QuerySet curQuery = new QuerySet(); curQuery.addPreferredQuery(new ConstantMatch(0.3f), 0.1f); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { fail("unable to match"); } } public void testDoubleValuePreferred() { try { QuerySet curQuery = new QuerySet(); curQuery.addPreferredQuery(new ConstantMatch(0.3f)); curQuery.addPreferredQuery(new ConstantMatch(0.2f)); assertEquals(0.25f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { fail("unable to match"); } } public void testDoubleWeighedValuePreferred() { try { QuerySet curQuery = new QuerySet(); curQuery.addPreferredQuery(new ConstantMatch(0.5f)); curQuery.addPreferredQuery(new ConstantMatch(0.2f), 2f); assertEquals(0.3f, curQuery.getMatchValue(new Object()), 0.01f); } catch (MatchException me) { fail("unable to match"); } } } |
From: Walter v. I. <it...@us...> - 2004-09-13 11:32:30
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30020/query Added Files: QuerySet.java Removed Files: AndList.java MatchList.java OrList.java Log Message: Replace MatchList, AndList, OrList with QuerySet --- AndList.java DELETED --- --- OrList.java DELETED --- --- MatchList.java DELETED --- --- NEW FILE: QuerySet.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query; import java.util.*; import net.sourceforge.javamatch.engine.*; /** * Class QuerySet combines multiple subqueries into a single query. The * subqueries in a QuerySet may be required or preferred. When an object is * matched, all required subqueries must match completely, or the QuerySet * reports a mismatch. When all required subqueries match, the preferred * subqueries determine the match value of the matched object. Preferred * subqueries may be weighted. The match value is the weighted average of * all preferred subqueries. */ public class QuerySet extends MatchQuery { /** The list of match queries, with their weight, that make up the preferred part of this QuerySet. They are stored as WeightedMatchQuery-objects, to merge the query and its weight */ private Vector preferredQueries = new Vector(); /** The list of match queries that make up the required part of this match query. These are stored as just the query objects, as required queries don't have a weight factor */ private Vector requiredQueries = new Vector(); /** * Adds a the given subquery to the list of preferred queries, with a * default weight (1) * @param query the subquery that is added to the list of preferred queries */ public void addPreferredQuery(MatchQuery query) { addPreferredQuery(query, 1f); } /** * Adds a the given subquery to the list of preferred queries, with the * given weight * @param query the subquery that is added to this MatchList * @param weight the relative weight of this subquery */ public void addPreferredQuery(MatchQuery query, float weight) { if (query == null) { throw new NullPointerException("Can't add a null query"); } preferredQueries.add(new WeightedMatchQuery(query, weight)); } /** * Adds a the given subquery to the list of required queries * @param query the subquery that is added to the list of required queries */ public void addRequiredQuery(MatchQuery query) { if (query == null) { throw new NullPointerException("Can't add a null query"); } requiredQueries.add(query); } /** * Returns if this MatchQuery is two-pass. When the query is two-pass, a * call to prePass will be made for every object, before the matchValue is * requested * @return false if the query is single-pass, true if the query is two-pass */ public boolean isTwoPass() { Iterator queryIterator = preferredQueries.iterator(); while (queryIterator.hasNext()) { MatchQuery curQuery = ((WeightedMatchQuery)queryIterator.next()).getQuery(); if (curQuery.isTwoPass()) { return true; } } queryIterator = requiredQueries.iterator(); while (queryIterator.hasNext()) { MatchQuery curQuery = (MatchQuery)queryIterator.next(); if (curQuery.isTwoPass()) { return true; } } return false; } /** * Performs the pre-pass of a two-pass query. A MatchList is two-pass if and * only if at least one of its sub-queries is two-pass. * @param matchedObject the object theat is currently matched * @throws MatchException when the prePass failed */ public void prePass(Object matchedObject) throws MatchException { Iterator queryIterator = requiredQueries.iterator(); while (queryIterator.hasNext()) { MatchQuery curQuery = (MatchQuery)queryIterator.next(); if (curQuery.isTwoPass()) { curQuery.prePass(matchedObject); } } queryIterator = preferredQueries.iterator(); while (queryIterator.hasNext()) { MatchQuery curQuery = ((WeightedMatchQuery)queryIterator.next()).getQuery(); if (curQuery.isTwoPass()) { curQuery.prePass(matchedObject); } } } /** * Returns the match value of this match query, when executed on the given * object. * @param targetObject the object agains which the query is executed * @return A value between 0 and 1, both inclusive, that indicates how good * the object matches this query. 0 means a mismatch, 1 means a full * match * @throws MatchException when the value could not be retrieved */ public float getMatchValue(Object targetObject) throws MatchException { Iterator queryIterator = requiredQueries.iterator(); while (queryIterator.hasNext()) { MatchQuery curQuery = (MatchQuery)queryIterator.next(); if (curQuery.getMatchValue(targetObject) < 1f) { return 0f; } } float totalWeight = 0; float totalMatchValue = 0; queryIterator = preferredQueries.iterator(); while (queryIterator.hasNext()) { WeightedMatchQuery curWeightedQuery = (WeightedMatchQuery)queryIterator.next(); MatchQuery curQuery = curWeightedQuery.getQuery(); float itemWeight = curWeightedQuery.getWeight(); totalWeight += itemWeight; float matchValue = curQuery.getMatchValue(targetObject); totalMatchValue += matchValue * itemWeight; } return totalMatchValue / totalWeight; } /** * Class WeightedMatchQuery combined a match query and its weight */ class WeightedMatchQuery { /** The relative weight of this match query */ private float weight; /** The match query */ private MatchQuery query; /** * Creates a new WeightedMatchQuery, with the given query and the given * relative weight * @param query the original subquery * @param weight the relative weight of this subquery */ public WeightedMatchQuery(MatchQuery query, float weight) { this.query = query; this.weight = weight; } /** * Returns the query * @return the original subquery */ public MatchQuery getQuery() { return query; } /** * Returns the relative weight of this query * @return the weight of this subquery */ public float getWeight() { return weight; } } } |
From: Walter v. I. <it...@us...> - 2004-09-13 11:29:34
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29268 Modified Files: RegexMatches.java Log Message: rename javadoc parameter name Index: RegexMatches.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/RegexMatches.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RegexMatches.java 13 Sep 2004 09:20:56 -0000 1.2 --- RegexMatches.java 13 Sep 2004 11:29:23 -0000 1.3 *************** *** 36,40 **** * against the given regular expression * @param memberName the name of the member that is matched ! * @param matchValue the value against which is matched * @throws PatternSyntaxException If the expression's syntax is invalid */ --- 36,40 ---- * against the given regular expression * @param memberName the name of the member that is matched ! * @param expression the value against which is matched * @throws PatternSyntaxException If the expression's syntax is invalid */ |
From: Walter v. I. <it...@us...> - 2004-09-13 09:21:07
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7045/net/sourceforge/javamatch/query Modified Files: RegexMatches.java Log Message: fix typo Index: RegexMatches.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/RegexMatches.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RegexMatches.java 13 Sep 2004 08:45:48 -0000 1.1 --- RegexMatches.java 13 Sep 2004 09:20:56 -0000 1.2 *************** *** 34,38 **** /** * Creates a new RegexMatches-query, that checks the given member name ! * againstthe given regular expression * @param memberName the name of the member that is matched * @param matchValue the value against which is matched --- 34,38 ---- /** * Creates a new RegexMatches-query, that checks the given member name ! * against the given regular expression * @param memberName the name of the member that is matched * @param matchValue the value against which is matched |
From: Walter v. I. <it...@us...> - 2004-09-13 09:17:49
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6434 Modified Files: javamatch.xml Log Message: updated history Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** javamatch.xml 10 Sep 2004 12:58:27 -0000 1.6 --- javamatch.xml 13 Sep 2004 09:17:40 -0000 1.7 *************** *** 443,446 **** --- 443,450 ---- </tr> <tr> + <td>20040913</td> + <td>Added RegexMatches, BooleanEquals, threshold</td> + </tr> + <tr> <td>20040910</td> <td>Updated car example-results and FAQ-SQL</td> |
From: Walter v. I. <it...@us...> - 2004-09-13 09:14:22
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5800/javamatch/engine/test Modified Files: MatchEngineTest.java MatchResultTest.java Added Files: ObjectValueQuery.java Log Message: Added threshold value, minimum match value for objects to be included Index: MatchEngineTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test/MatchEngineTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MatchEngineTest.java 10 Sep 2004 14:22:17 -0000 1.3 --- MatchEngineTest.java 13 Sep 2004 09:14:11 -0000 1.4 *************** *** 21,24 **** --- 21,25 ---- import junit.framework.*; import net.sourceforge.javamatch.engine.*; + import net.sourceforge.javamatch.query.*; import net.sourceforge.javamatch.query.test.*; *************** *** 184,186 **** --- 185,210 ---- } } + + public void testThreshold() { + try { + MatchEngine engine = new MatchEngine(); + engine.setThreshold(0.3f); + MatchQuery query = new ObjectValueQuery("floatValue"); + Vector objects = new Vector(); + objects.add(new DataObject(0.0f)); + objects.add(new DataObject(0.1f)); + objects.add(new DataObject(0.2f)); + objects.add(new DataObject(0.3f)); + objects.add(new DataObject(0.4f)); + objects.add(new DataObject(0.5f)); + MatchResult result = engine.executeQuery(query, objects); + Iterator resultIterator = result.getResultIterator(); + assertEquals(0.5f, ((ResultItem)resultIterator.next()).getMatchValue(), 0.001f); + assertEquals(0.4f, ((ResultItem)resultIterator.next()).getMatchValue(), 0.001f); + assertEquals(0.3f, ((ResultItem)resultIterator.next()).getMatchValue(), 0.001f); + assertFalse(resultIterator.hasNext()); + } catch (MatchException me) { + fail("unable to match"); + } + } } --- NEW FILE: ObjectValueQuery.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.engine.test; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; /** * Class ObjectValueQuery returns the value of a member in the matched objects * as result of the match */ public class ObjectValueQuery extends NumericQuery { /** The member that is called */ private String memberName; /** * Crates a new ObjectValueQuery, which returns the value of the given member */ public ObjectValueQuery(String memberName) { this.memberName = memberName; } /** * Returns the match value of this constant match */ public float getMatchValue(Object targetObject) throws MatchException { return (float)getValue(targetObject, memberName); } } Index: MatchResultTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test/MatchResultTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MatchResultTest.java 7 Sep 2004 09:41:07 -0000 1.2 --- MatchResultTest.java 13 Sep 2004 09:14:11 -0000 1.3 *************** *** 335,338 **** --- 335,354 ---- } + public void testThreshold() { + MatchResult result = new MatchResult(engine); + result.setThreshold(0.3f); + result.addResultItem(new Object(), 0.0f); + result.addResultItem(new Object(), 0.1f); + result.addResultItem(new Object(), 0.2f); + result.addResultItem(new Object(), 0.3f); + result.addResultItem(new Object(), 0.4f); + result.addResultItem(new Object(), 0.5f); + Iterator resultIterator = result.getResultIterator(); + assertEquals(0.5f, ((ResultItem)(resultIterator.next())).getMatchValue(), 0.001f); + assertEquals(0.4f, ((ResultItem)(resultIterator.next())).getMatchValue(), 0.001f); + assertEquals(0.3f, ((ResultItem)(resultIterator.next())).getMatchValue(), 0.001f); + assertFalse(resultIterator.hasNext()); + } + public void testSetMaxNumResultItemsAfterAdd() { MatchResult result = new MatchResult(engine); |
From: Walter v. I. <it...@us...> - 2004-09-13 09:14:22
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5800/javamatch/query/test Modified Files: DataObject.java Log Message: Added threshold value, minimum match value for objects to be included Index: DataObject.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/DataObject.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataObject.java 13 Sep 2004 08:45:48 -0000 1.2 --- DataObject.java 13 Sep 2004 09:14:12 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- private String stringValue; private boolean boolValue; + private float floatValue; public DataObject(int intValue) { *************** *** 35,38 **** --- 36,43 ---- } + public DataObject(float floatValue) { + this.floatValue = floatValue; + } + public DataObject(int intValue, String stringValue) { this.intValue = intValue; *************** *** 44,47 **** --- 49,56 ---- } + public float getFloatValue() { + return floatValue; + } + public String getStringValue() { return stringValue; |
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 |
From: Walter v. I. <it...@us...> - 2004-09-13 08:45:58
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv711/net/sourceforge/javamatch/query/test Modified Files: ContainsTest.java DataObject.java GreaterThanTest.java LessThanTest.java MaximumTest.java MinimumTest.java NumberEqualsTest.java RangeTest.java StringEqualsTest.java TestAll.java Added Files: BooleanEqualsTest.java RegexMatchesTest.java Log Message: Added regex, booleanEquals, test for null members --- NEW FILE: RegexMatchesTest.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query.test; import java.util.regex.*; import junit.framework.*; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; /** * Class RegexMatchesTest tests the RegexMatches query */ public class RegexMatchesTest extends TestCase { public RegexMatchesTest(String name) { super(name); } public void testMatch() { try { RegexMatches regexMatches = new RegexMatches("stringValue", "a*b"); DataObject dataObject = new DataObject("aaab"); assertEquals(1.0, regexMatches.getMatchValue(dataObject), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testMismatch() { try { RegexMatches regexMatches = new RegexMatches("stringValue", "a*b"); DataObject dataObject = new DataObject("aaabc"); assertEquals(0.0, regexMatches.getMatchValue(dataObject), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testNullRegex() { try { RegexMatches regexMatches = new RegexMatches("stringValue", null); fail("Shouldn't be able to craete RegexMatches with null expression"); } catch (NullPointerException npe) { // should occur } } public void testInvalidPattern() { try { RegexMatches regexMatches = new RegexMatches("stringValue", "\\"); fail("Shouldn't be able to craete RegexMatches with invalid pattern"); } catch (PatternSyntaxException pse) { // should occur } } public void testNullMember() { try { RegexMatches regexMatches = new RegexMatches(null, ""); fail("Shouldn't be able to create RegexMatches with null member"); } catch (NullPointerException npe) { // should occur } } } Index: DataObject.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/DataObject.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DataObject.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- DataObject.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 21,24 **** --- 21,25 ---- private int intValue; private String stringValue; + private boolean boolValue; public DataObject(int intValue) { *************** *** 30,33 **** --- 31,38 ---- } + public DataObject(boolean boolValue) { + this.boolValue = boolValue; + } + public DataObject(int intValue, String stringValue) { this.intValue = intValue; *************** *** 42,44 **** --- 47,53 ---- return stringValue; } + + public boolean getBoolValue() { + return boolValue; + } } Index: StringEqualsTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/StringEqualsTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** StringEqualsTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- StringEqualsTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 79,81 **** --- 79,90 ---- } } + + public void testNullMember() { + try { + StringEquals stringEquals = new StringEquals(null, ""); + fail("Shouldn't be able to create StringEquals with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: LessThanTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/LessThanTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LessThanTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- LessThanTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 59,61 **** --- 59,70 ---- } } + + public void testNullMember() { + try { + LessThan lessThan = new LessThan(null, 0); + fail("Shouldn't be able to create LessThan with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: NumberEqualsTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/NumberEqualsTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** NumberEqualsTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- NumberEqualsTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 49,51 **** --- 49,60 ---- } } + + public void testNullMember() { + try { + NumberEquals numberEquals = new NumberEquals(null, 0.0); + fail("Shouldn't be able to create NumberEquals with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } --- NEW FILE: BooleanEqualsTest.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query.test; import junit.framework.*; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; /** * Class BooleanEqualsTest tests the BooleanEquals query */ public class BooleanEqualsTest extends TestCase { public BooleanEqualsTest(String name) { super(name); } public void testTrue() { try { BooleanEquals booleanEquals = new BooleanEquals("boolValue"); DataObject dataObject = new DataObject(true); assertEquals(1.0, booleanEquals.getMatchValue(dataObject), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testFalse() { try { BooleanEquals booleanEquals = new BooleanEquals("boolValue"); DataObject dataObject = new DataObject(false); assertEquals(0.0, booleanEquals.getMatchValue(dataObject), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testNullMember() { try { StringEquals stringEquals = new StringEquals(null, ""); fail("Shouldn't be able to create StringEquals with null member"); } catch (NullPointerException npe) { // should occur } } } Index: TestAll.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/TestAll.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestAll.java 9 Sep 2004 14:18:59 -0000 1.2 --- TestAll.java 13 Sep 2004 08:45:48 -0000 1.3 *************** *** 46,49 **** --- 46,51 ---- suite.addTestSuite(ContainsTest.class); suite.addTestSuite(NotQueryTest.class); + suite.addTestSuite(RegexMatchesTest.class); + suite.addTestSuite(BooleanEqualsTest.class); // ... and others return suite; Index: MinimumTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/MinimumTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MinimumTest.java 6 Sep 2004 09:14:37 -0000 1.2 --- MinimumTest.java 13 Sep 2004 08:45:48 -0000 1.3 *************** *** 142,144 **** --- 142,153 ---- } } + + public void testNullMember() { + try { + Minimum minimum = new Minimum(null); + fail("Shouldn't be able to create Minimum with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: MaximumTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/MaximumTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MaximumTest.java 6 Sep 2004 09:14:30 -0000 1.2 --- MaximumTest.java 13 Sep 2004 08:45:48 -0000 1.3 *************** *** 142,144 **** --- 142,153 ---- } } + + public void testNullMember() { + try { + Maximum maximum = new Maximum(null); + fail("Shouldn't be able to create Maximum with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: RangeTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/RangeTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** RangeTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- RangeTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 79,81 **** --- 79,90 ---- } } + + public void testNullMember() { + try { + Range range = new Range(null, 0, 0); + fail("Shouldn't be able to create Range with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: ContainsTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/ContainsTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ContainsTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- ContainsTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 79,81 **** --- 79,90 ---- } } + + public void testNullMember() { + try { + Contains contains = new Contains(null, ""); + fail("Shouldn't be able to create Contains with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: GreaterThanTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/GreaterThanTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** GreaterThanTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- GreaterThanTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 59,61 **** --- 59,70 ---- } } + + public void testNullMember() { + try { + GreaterThan greaterThan = new GreaterThan(null, 0); + fail("Shouldn't be able to create GreaterThan with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } |
From: Walter v. I. <it...@us...> - 2004-09-13 08:45:57
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv711/net/sourceforge/javamatch/query Modified Files: Contains.java GreaterThan.java LessThan.java Maximum.java Minimum.java NumberEquals.java Range.java StringEquals.java Added Files: BooleanEquals.java RegexMatches.java Log Message: Added regex, booleanEquals, test for null members --- NEW FILE: BooleanEquals.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query; import net.sourceforge.javamatch.engine.*; /** * Class BooleanEquals is a query that check if a boolean member returns true */ public class BooleanEquals extends MatchQuery { /** The name of the member of the object that is matched */ private String memberName; /** * Creates a new BooleanEquals-query, that checks if member with the given * member name returns true * @param memberName the name of the member that is matched */ public BooleanEquals(String memberName) { if (memberName == null) { throw new NullPointerException("Member name can't be null"); } this.memberName = memberName; } /** * Returns the match value of this match query, when executed on the given * object. * @param targetObject the object agains which the query is executed * @return A value between 0 and 1, both inclusive, that indicates how good * the object matches this query. 0 means a mismatch, 1 means a full * match * @throws MatchException when the value could not be retrieved */ public float getMatchValue(Object targetObject) throws MatchException { Boolean objectValue = (Boolean)getObjectValue(targetObject, memberName); if (objectValue.booleanValue()) { return 1f; } return 0f; } } Index: GreaterThan.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/GreaterThan.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** GreaterThan.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- GreaterThan.java 13 Sep 2004 08:45:47 -0000 1.2 *************** *** 38,41 **** --- 38,44 ---- */ public GreaterThan(String memberName, double matchValue) { + if (memberName == null) { + throw new NullPointerException("Member name can't be null"); + } this.memberName = memberName; this.matchValue = matchValue; Index: Minimum.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/Minimum.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Minimum.java 6 Sep 2004 09:14:30 -0000 1.2 --- Minimum.java 13 Sep 2004 08:45:47 -0000 1.3 *************** *** 41,44 **** --- 41,47 ---- */ public Minimum(String memberName) { + if (memberName == null) { + throw new NullPointerException("Member name can't be null"); + } this.memberName = memberName; } Index: NumberEquals.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/NumberEquals.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** NumberEquals.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- NumberEquals.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 38,41 **** --- 38,44 ---- */ public NumberEquals(String memberName, double matchValue) { + if (memberName == null) { + throw new NullPointerException("Member name can't be null"); + } this.memberName = memberName; this.matchValue = matchValue; Index: Range.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/Range.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Range.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- Range.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 42,45 **** --- 42,48 ---- */ public Range(String memberName, double minimumValue, double maximumValue) { + if (memberName == null) { + throw new NullPointerException("Member name can't be null"); + } this.memberName = memberName; this.minimumValue = minimumValue; Index: Contains.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/Contains.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Contains.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- Contains.java 13 Sep 2004 08:45:47 -0000 1.2 *************** *** 38,41 **** --- 38,44 ---- */ public Contains(String memberName, String matchValue) { + if (memberName == null) { + throw new NullPointerException("Member name can't be null"); + } this.memberName = memberName; this.matchValue = matchValue; --- NEW FILE: RegexMatches.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query; import java.util.regex.*; import net.sourceforge.javamatch.engine.*; /** * Class RegexMatches is a query that check if a string matches a certain * regular expression */ public class RegexMatches extends StringQuery { /** The name of the member of the object that is matched */ private String memberName; /** The regular expression that describes the matching pattern */ private String expression; /** * Creates a new RegexMatches-query, that checks the given member name * againstthe given regular expression * @param memberName the name of the member that is matched * @param matchValue the value against which is matched * @throws PatternSyntaxException If the expression's syntax is invalid */ public RegexMatches(String memberName, String expression) throws PatternSyntaxException { if (memberName == null) { throw new NullPointerException("Member name can't be null"); } if (expression == null) { throw new NullPointerException("Expression can't be null"); } this.memberName = memberName; this.expression = expression; Pattern.compile(expression); } /** * Returns the match value of this match query, when executed on the given * object. * @param targetObject the object agains which the query is executed * @return A value between 0 and 1, both inclusive, that indicates how good * the object matches this query. 0 means a mismatch, 1 means a full * match * @throws MatchException when the value could not be retrieved */ public float getMatchValue(Object targetObject) throws MatchException { String objectValue = getValue(targetObject, memberName); float returnValue = 0.0f; if (objectValue != null) { if (Pattern.compile(expression).matcher(objectValue).matches()) { returnValue = 1.0f; } } return returnValue; } } Index: Maximum.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/Maximum.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Maximum.java 6 Sep 2004 09:14:30 -0000 1.2 --- Maximum.java 13 Sep 2004 08:45:47 -0000 1.3 *************** *** 41,44 **** --- 41,47 ---- */ public Maximum(String memberName) { + if (memberName == null) { + throw new NullPointerException("Member name can't be null"); + } this.memberName = memberName; } Index: LessThan.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/LessThan.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LessThan.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- LessThan.java 13 Sep 2004 08:45:47 -0000 1.2 *************** *** 38,41 **** --- 38,44 ---- */ public LessThan(String memberName, double matchValue) { + if (memberName == null) { + throw new NullPointerException("Member name can't be null"); + } this.memberName = memberName; this.matchValue = matchValue; Index: StringEquals.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/StringEquals.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** StringEquals.java 3 Sep 2004 08:21:22 -0000 1.1.1.1 --- StringEquals.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 38,41 **** --- 38,44 ---- */ public StringEquals(String memberName, String matchValue) { + if (memberName == null) { + throw new NullPointerException("Member name can't be null"); + } this.memberName = memberName; this.matchValue = matchValue; |
From: Walter v. I. <it...@us...> - 2004-09-13 07:24:49
|
Update of /cvsroot/javamatch/javamatch/docs/website/resources/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16403/website/resources/images Modified Files: hierarchy.png Log Message: Added regex, booleanEquals, replace MatchList etc. with QuerySet Index: hierarchy.png =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/resources/images/hierarchy.png,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvsnx9dhm and /tmp/cvs24uoHj differ |
From: Walter v. I. <it...@us...> - 2004-09-13 07:24:48
|
Update of /cvsroot/javamatch/javamatch/docs/assets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16403/assets Modified Files: Match Hierarchy.vsd Log Message: Added regex, booleanEquals, replace MatchList etc. with QuerySet Index: Match Hierarchy.vsd =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/assets/Match Hierarchy.vsd,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 Binary files /tmp/cvs5vHjTU and /tmp/cvsr8PeSR differ |
From: Walter v. I. <it...@us...> - 2004-09-13 07:17:48
|
Update of /cvsroot/javamatch/javamatch In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14977 Modified Files: build.xml Log Message: Show date of generation in web site Index: build.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/build.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** build.xml 3 Sep 2004 12:10:38 -0000 1.2 --- build.xml 13 Sep 2004 07:17:36 -0000 1.3 *************** *** 123,126 **** --- 123,136 ---- <target name="run_site_generator" depends="compile_site_generator"> <mkdir dir="generated/website"/> + <mkdir dir="generated/site_templates"/> + <tstamp> + <format property="TODAY" pattern="MMMM d, yyyy"/> + </tstamp> + <copy todir="generated/site_templates"> + <fileset dir="docs/website/templates"/> + <filterset> + <filter token="TODAY" value="${TODAY}"/> + </filterset> + </copy> <java classname="sitegenerator.SiteGenerator" *************** *** 128,132 **** dir="." failonerror="true"> ! <arg line="-projectFile docs/website/javamatch.xml -templateDir docs/website/templates -projectTemplate index.vm -outputDir generated/website"/> <classpath> <pathelement path="generated"/> --- 138,142 ---- dir="." failonerror="true"> ! <arg line="-projectFile docs/website/javamatch.xml -templateDir generated/site_templates -projectTemplate index.vm -outputDir generated/website"/> <classpath> <pathelement path="generated"/> |
From: Walter v. I. <it...@us...> - 2004-09-13 07:17:48
|
Update of /cvsroot/javamatch/javamatch/docs/website/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14977/docs/website/templates Modified Files: page.vm Log Message: Show date of generation in web site Index: page.vm =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/templates/page.vm,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** page.vm 6 Sep 2004 09:13:05 -0000 1.3 --- page.vm 13 Sep 2004 07:17:37 -0000 1.4 *************** *** 82,86 **** <hr/> <p class="copyright">Copyright © 2004, Walter van Iterson<br/> ! latest update: September, 2004 </p> </td> --- 82,86 ---- <hr/> <p class="copyright">Copyright © 2004, Walter van Iterson<br/> ! latest update: @TODAY@ </p> </td> |
From: Walter v. I. <it...@us...> - 2004-09-10 14:22:51
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18704/src/net/sourceforge/javamatch/engine/test Modified Files: MatchEngineTest.java Log Message: Added iterators, to support JDO extents Index: MatchEngineTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/test/MatchEngineTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MatchEngineTest.java 7 Sep 2004 09:41:07 -0000 1.2 --- MatchEngineTest.java 10 Sep 2004 14:22:17 -0000 1.3 *************** *** 21,25 **** import junit.framework.*; import net.sourceforge.javamatch.engine.*; ! import net.sourceforge.javamatch.query.test.ConstantMatch; /** --- 21,25 ---- import junit.framework.*; import net.sourceforge.javamatch.engine.*; ! import net.sourceforge.javamatch.query.test.*; /** *************** *** 67,70 **** --- 67,131 ---- } + public void testExecuteNullQueryIterators() { + MatchEngine engine = new MatchEngine(); + Vector v = new Vector(); + try { + engine.executeQuery(null, v.iterator(), v.iterator()); + fail("Shouldn't be able to execute null query"); + } catch (NullPointerException npe) { + // should occur + } catch (MatchException me) { + fail("unable to match"); + } + } + + public void testExecuteNullDataIterator() { + MatchEngine engine = new MatchEngine(); + try { + engine.executeQuery(new ConstantMatch(3f), null, null); + fail("Shouldn't be able to execute query with null data"); + } catch (NullPointerException npe) { + // should occur + } catch (MatchException me) { + fail("unable to match"); + } + } + + public void testExecuteNullQueryDataIterator() { + MatchEngine engine = new MatchEngine(); + try { + engine.executeQuery(null, null, null); + fail("Shouldn't be able to execute null query with null data"); + } catch (NullPointerException npe) { + // should occur + } catch (MatchException me) { + fail("unable to match"); + } + } + + public void testExecuteOneIterator() { + MatchEngine engine = new MatchEngine(); + try { + MatchResult result = engine.executeQuery(new ConstantMatch(3f), new Vector().iterator(), null); + assertFalse(result.getResultIterator().hasNext()); + } catch (MatchException me) { + fail("unable to match"); + } + } + + public void testExecuteOneIteratorTwoPass() { + MatchEngine engine = new MatchEngine(); + MatchMock query = new MatchMock(); + query.setTwoPass(true); + try { + engine.executeQuery(query, new Vector().iterator(), null); + fail("shouldn't be able to execute two-pass query with one iterator"); + } catch (NullPointerException npe) { + // should occur + } catch (MatchException me) { + fail("unable to match"); + } + } + public void testAddNullListener() { MatchEngine engine = new MatchEngine(); |
From: Walter v. I. <it...@us...> - 2004-09-10 14:22:50
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18704/src/net/sourceforge/javamatch/engine Modified Files: MatchEngine.java Log Message: Added iterators, to support JDO extents Index: MatchEngine.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/engine/MatchEngine.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MatchEngine.java 7 Sep 2004 09:41:06 -0000 1.2 --- MatchEngine.java 10 Sep 2004 14:22:17 -0000 1.3 *************** *** 44,63 **** * @param itemsToMatch the items that are matched * @return a MatchResult, that contains the best matching ResultItems */ public MatchResult executeQuery(MatchQuery query, List itemsToMatch) throws MatchException { if (query == null) { throw new NullPointerException("Match engine can't execute a null " + "query"); } ! if (itemsToMatch == null) { throw new NullPointerException("Match engine can't execute a query " ! + "on null items"); } notifyListenersStarted(query); if (query.isTwoPass()) { ! Iterator itemIterator = itemsToMatch.iterator(); ! while (itemIterator.hasNext()) { ! Object curItem = itemIterator.next(); curItem = retrieveObject(curItem); query.prePass(curItem); --- 44,89 ---- * @param itemsToMatch the items that are matched * @return a MatchResult, that contains the best matching ResultItems + * @throws MatchException when matching failed */ public MatchResult executeQuery(MatchQuery query, List itemsToMatch) throws MatchException { + if (itemsToMatch == null) { + throw new NullPointerException("Match engine can't execute a query " + + "on null items"); + } + return executeQuery(query, itemsToMatch.iterator(), itemsToMatch.iterator()); + } + + /** + * Executes the specified match query on all objects in the given List. + * Returns a MatchResult, that contains the best matching items with their + * match value. The number of items that are returned can be specified by + * @link #setReturnedItemCount. + * @param query the query that is executed + * @param dataIterator1 an iterator that iterates over the items that are matched + * @param dataIterator2 a second iterator that iterates over the items that + * are used in the pre-pass of a two-pass query. This iterator may be + * null if the query is single-pass + * @return a MatchResult, that contains the best matching ResultItems + * @throws MatchException when matching failed + */ + public MatchResult executeQuery(MatchQuery query, Iterator dataIterator1, Iterator dataIterator2) + throws MatchException { if (query == null) { throw new NullPointerException("Match engine can't execute a null " + "query"); } ! if (dataIterator1 == null) { throw new NullPointerException("Match engine can't execute a query " ! + "with a null data iterator"); } notifyListenersStarted(query); if (query.isTwoPass()) { ! if (dataIterator2 == null) { ! throw new NullPointerException("Match engine can't execute a " + ! "2-pass query with a null second data iterator"); ! } ! while (dataIterator2.hasNext()) { ! Object curItem = dataIterator2.next(); curItem = retrieveObject(curItem); query.prePass(curItem); *************** *** 68,74 **** MatchResult result = new MatchResult(this); result.setMaxNumResultItems(maxNumResultItems); ! Iterator itemIterator = itemsToMatch.iterator(); ! while (itemIterator.hasNext()) { ! Object curItem = itemIterator.next(); curItem = retrieveObject(curItem); float matchValue = query.getMatchValue(curItem); --- 94,99 ---- MatchResult result = new MatchResult(this); result.setMaxNumResultItems(maxNumResultItems); ! while (dataIterator1.hasNext()) { ! Object curItem = dataIterator1.next(); curItem = retrieveObject(curItem); float matchValue = query.getMatchValue(curItem); |
From: Walter v. I. <it...@us...> - 2004-09-10 13:00:49
|
Update of /cvsroot/javamatch/javamatch/docs/website/resources/style In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30953 Modified Files: style.css Log Message: Added p.example (indent 20 pixels) Index: style.css =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/resources/style/style.css,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** style.css 9 Sep 2004 14:19:51 -0000 1.2 --- style.css 10 Sep 2004 13:00:40 -0000 1.3 *************** *** 69,70 **** --- 69,74 ---- border: 1px solid black; } + + p.example { + margin-left: 20px; + } |
From: Walter v. I. <it...@us...> - 2004-09-10 12:58:48
|
Update of /cvsroot/javamatch/javamatch/docs/website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30474 Modified Files: javamatch.xml Log Message: Added chapter about results to car example, some other stuff Index: javamatch.xml =================================================================== RCS file: /cvsroot/javamatch/javamatch/docs/website/javamatch.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** javamatch.xml 9 Sep 2004 14:19:50 -0000 1.5 --- javamatch.xml 10 Sep 2004 12:58:27 -0000 1.6 *************** *** 8,24 **** generic match engine, not targeted at a specific domain. It can be applied to any runtime data structure, and the extensive query mechanism allows for highly ! customizable tuning of your searches. ! </p> ! <p> ! In other words, JavaMatch provides a superset of search engine-like functionality ! to your data structures. It allows for more vague searches than SQL SELECT queries, ! can be applied to any java data structure, and is accessible via a Java-only API. </p> ! <p> ! JavaMatch will be integrated with object-relational mapping tools, such as ! Hibernate and JDO. This allows to matching within databases. Integration ! with JDO is planned for release 0.2 </p> ! <h2>Example 1: Simple query</h2> <p> Nice those stories, but how does it work in practice? Let me give you an example: --- 8,27 ---- generic match engine, not targeted at a specific domain. It can be applied to any runtime data structure, and the extensive query mechanism allows for highly ! customizable tuning of your searches. JavaMatch can be integrated with object- ! relational mapping tools. This allows you to match inside databases. </p> ! <h3>Functionality</h3> ! <p> JavaMatch's functionality compared to "normal" database searching can be described ! by using an analogy:</p> ! <p class="example"> ! If you search for something in Google, you don't just see the pages that <b>exactly</b> ! match your search query, you'll also get the results that <b>best</b> match the search ! query (unless you use the "+"-syntax).<br/> ! JavaMatch provides this Google-like functionality, but then applied to a Java data ! structure: It looks for the objects that <b>best</b> match the query: Out of the ! entire data set, it returns the top-10 (or more, if you specify so) of the best ! matching objects. </p> ! <h2>Example 1: Queries</h2> <p> Nice those stories, but how does it work in practice? Let me give you an example: *************** *** 41,47 **** List campSites = guide.getCampSites(); MatchResult matchResult = matchEngine.executeQuery(query, campSites);</pre> - <p><b><i> - Note: the syntax for retrieval of data members (such as "size") will change in version 0.2 - </i></b></p> <p> Class MatchResult contains a list of ResultItem's. A ResultItem consists of a --- 44,47 ---- *************** *** 54,60 **** The full source can be found in the directory examples/camping in the distribution </p> ! <h2>Example 2: Extension</h2> <p> ! The JavaMatch engine is domain-indepentent, so if I want to look for a certain second-hand car, I can specify the following query: </p> --- 54,60 ---- The full source can be found in the directory examples/camping in the distribution </p> ! <h2>Example 2: Results and extensions</h2> <p> ! The JavaMatch engine is domain-independent, so if I want to look for a certain second-hand car, I can specify the following query: </p> *************** *** 67,71 **** List allCars = carData.getAllCars(); MatchResult matchResult = matchEngine.executeQuery(query, allCars);</pre> ! <p> You may want to find a match with more complicated, domain-specific criteria, for example if the car has had regular service intervals. In this case, you can --- 67,136 ---- List allCars = carData.getAllCars(); MatchResult matchResult = matchEngine.executeQuery(query, allCars);</pre> ! <hr/> ! <h3>Results</h3> ! <p> ! When you execute this query, the match engine might return objects with the ! following data: ! </p> ! <table class= "enum"> ! <tr> ! <th>Match value</th> ! <th>brand</th> ! <th>buildYear</th> ! <th>price</th> ! <th>mileage</th> ! </tr> ! <tr> ! <td>1.00</td> ! <td>BMW</td> ! <td>1998</td> ! <td>$7,900.00</td> ! <td>44,000</td> ! </tr> ! <tr> ! <td>1.00</td> ! <td>BMW</td> ! <td>2002</td> ! <td>$9,999.00</td> ! <td>25,000</td> ! </tr> ! <tr> ! <td>1.00</td> ! <td>BMW</td> ! <td>1997</td> ! <td>$6,400.00</td> ! <td>62,000</td> ! </tr> ! <tr> ! <td>0.75</td> ! <td>BMW</td> ! <td>2002</td> ! <td><b><i>$13,000.00</i></b></td> ! <td>35,000</td> ! </tr> ! <tr> ! <td>0.75</td> ! <td><b><i>Alpha Romeo</i></b></td> ! <td>2000</td> ! <td>$7,800.00</td> ! <td>55,000</td> ! </tr> ! <tr> ! <td>0.50</td> ! <td>BMW</td> ! <td><b><i>2003</i></b></td> ! <td><b><i>$15,500.00</i></b></td> ! <td>12,000</td> ! </tr> ! </table> ! <p> ! As you can see in row 1 to 3, the match engine first returns the objects that ! exactly match the criteria. This is similar to the rows you'll get when you ! execute an SQL query. Row 4 to 6 are different: they show the objects that ! don't match <b>exactly</b>, but the objects that <b>best</b> match the query. ! </p> ! <hr/> ! <h3>Extensions</h3> ! <p> You may want to find a match with more complicated, domain-specific criteria, for example if the car has had regular service intervals. In this case, you can *************** *** 137,141 **** </page> <page title="FAQ" filebase="faq"> ! <h2>"What is JavaMatch, compared to..."</h2> <h3>What is JavaMatch, compared to a search engine?</h3> <p> --- 202,206 ---- </page> <page title="FAQ" filebase="faq"> ! <h2>What is JavaMatch, compared to...</h2> <h3>What is JavaMatch, compared to a search engine?</h3> <p> *************** *** 154,158 **** </p> <h3>What is JavaMatch, compared to SQL?</h3> ! <p>If you compare the functionality of JavaMatch with SQL, you'll see two big differences: <ul> --- 219,223 ---- </p> <h3>What is JavaMatch, compared to SQL?</h3> ! <p>If you compare the functionality of JavaMatch with SQL, you'll see a couple of differences: <ul> *************** *** 162,165 **** --- 227,235 ---- objects <b>best</b> match your query, and returns their top 10, in ascending order</li> + <li>SQL has a limited set of query operators, JavaMatch's queries can be extended + to target a specific domain</li> + <li>SQL executes the query inside the database, and returns the results. JavaMatch + retrieves all data from the underlying data storage mechanism, and performs the + matching in the Java runtime environment</li> </ul> </p> *************** *** 171,175 **** optimized better. </p> ! <h2>"How, when and where to use"</h2> <h3>Why hasn't this been implemented before?</h3> <p>Usually, large amounts of data are kept in a database instead of in memory --- 241,245 ---- optimized better. </p> ! <h2>How, when and where to use</h2> <h3>Why hasn't this been implemented before?</h3> <p>Usually, large amounts of data are kept in a database instead of in memory *************** *** 196,200 **** causes less overhead. </p> ! <h2>"Usage"</h2> <h3>I get very little results. What's wrong?</h3> <p> --- 266,270 ---- causes less overhead. </p> ! <h2>Usage</h2> <h3>I get very little results. What's wrong?</h3> <p> *************** *** 343,347 **** <ul> <li>Better syntax for following and constraining object references, ! handle collections</li> </ul> </td> --- 413,421 ---- <ul> <li>Better syntax for following and constraining object references, ! handle collections.<br/> ! For example: "Has a" and "sum"-operators on collections (A resume that ! contains at least one project related to car manufacturing, or the sum ! of the duration of all projects that had something to do with Java ! technology)</li> </ul> </td> *************** *** 369,372 **** --- 443,450 ---- </tr> <tr> + <td>20040910</td> + <td>Updated car example-results and FAQ-SQL</td> + </tr> + <tr> <td>20040909</td> <td>Added NotQuery, listener mechanism, added FAQ contents, fixed |