Merge branch 'master' of ssh://git.indexdata.com/home/git/private/cql-java
authorMike Taylor <mike@miketaylor.org.uk>
Thu, 17 Jun 2010 09:17:43 +0000 (10:17 +0100)
committerMike Taylor <mike@miketaylor.org.uk>
Thu, 17 Jun 2010 09:17:43 +0000 (10:17 +0100)
12 files changed:
Build
Changes
pom.xml
src/main/java/org/z3950/zing/cql/CQLGenerator.java
src/main/java/org/z3950/zing/cql/CQLParser.java
src/main/java/org/z3950/zing/cql/Makefile
test/random/mkrandom
test/regression/queries.raw
test/regression/sections/02/02.xcql
test/regression/sections/02/12.xcql
test/regression/sections/05/06.xcql
test/regression/sections/09/01.xcql

diff --git a/Build b/Build
index a399888..2c2f550 100755 (executable)
--- a/Build
+++ b/Build
@@ -3,7 +3,7 @@
 # $Id: Build,v 1.2 2002-11-20 17:20:11 mike Exp $
 
 : ${MAKE=make}
-for dir in src/org/z3950/zing/cql test/regression docs; do
+for dir in src/main/java/org/z3950/zing/cql test/regression docs; do
        echo "=== Building in $dir ==="
        ( cd $dir; $MAKE ${@+"$@"} )
 done
diff --git a/Changes b/Changes
index 1197ce9..1a85da8 100644 (file)
--- a/Changes
+++ b/Changes
@@ -6,6 +6,16 @@ See the bottom of this file for a list of things still to do.
 The work for releases 1.0, 1.2 and 1.2.1 was sponsored by the National
 Library of Australia, whose help we gratefully acknowledge.
 
+1.5  Tue May 25 16:44:35 CEST 2010
+       - Fix recognition of word-relations to correctly match what is
+         specified in the CQL v1.1 and v1.2 documents.  In
+         particular, "encloses" and "within" are recognised, so that
+         Masterkey's use of "encloses" for IP range authentication
+         works again.
+       - Update regression tests accordingly.
+       - Extend test/random/ to emit summary line of successful
+         recompilations.
+
 1.4  Thu May 20 00:38:40 BST 2010
        - Add support for interpreting sequences of non-keywords as a
          single multi-word term rather than a broken INDEX RELATION
diff --git a/pom.xml b/pom.xml
index d536a3d..663fe2c 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
   <groupId>org.z3950.zing</groupId>
   <artifactId>cql-java</artifactId>
   <packaging>jar</packaging>
-  <version>1.4</version>
+  <version>1.5</version>
   <name>cql-java</name>
   <url>http://maven.apache.org</url>
     <build>
index 416b771..cc8ac14 100644 (file)
@@ -198,7 +198,7 @@ public class CQLGenerator {
            return generate_numeric_relation();
        } else {
            switch (rnd.nextInt(3)) {
-           case 0: return "exact";
+           case 0: return "within";
            case 1: return "all";
            case 2: return "any";
            }
index 25b49d0..90e9f59 100644 (file)
@@ -241,10 +241,13 @@ public class CQLParser {
              " (" + lexer.render() + ")");
         if (lexer.ttype == lexer.TT_WORD &&
             (lexer.sval.indexOf('.') >= 0 ||
-             lexer.sval.equals("exact") ||
              lexer.sval.equals("any") ||
              lexer.sval.equals("all") ||
-             (lexer.sval.equals("scr") && compat == V1POINT2)))
+             lexer.sval.equals("within") ||
+             lexer.sval.equals("encloses") ||
+             (lexer.sval.equals("exact") && compat != V1POINT2) ||
+             (lexer.sval.equals("scr") && compat != V1POINT2) ||
+             (lexer.sval.equals("adj") && compat == V1POINT2)))
           return true;
 
         return isSymbolicRelation();
index 00b82d5..c318cc0 100644 (file)
@@ -18,10 +18,10 @@ OBJ = Utils.class \
        UnknownIndexException.class UnknownRelationException.class \
        UnknownRelationModifierException.class UnknownPositionException.class
 
-JARPATH = ../lib/cql-java.jar
+JARPATH = ../../../lib/cql-java.jar
 JAR = ../../../../../../$(JARPATH)
 $(JAR): $(OBJ)
-       cd ../../../../../..; jar cf $(JARPATH) main/java/org/z3950/zing/cql/*.class
+       cd ../../../..; jar cf $(JARPATH) org/z3950/zing/cql/*.class
 
 %.class: %.java
        javac -Xlint:unchecked *.java
index f300534..185f2c3 100755 (executable)
@@ -12,12 +12,17 @@ if (@ARGV > 1) {
     $n = $ARGV[0];
 }
 
+my $nok = 0;
 for (my $i = 0; $i < $n; $i++) {
     print $i+1, " of $n -- ";
     my $query=`CQLGenerator ../../etc/generate.properties`;
     print $query;
     my $canon=`CQLParser -c '$query'`;
-    if ($canon ne $query) {
+    if ($canon eq $query) {
+       $nok++;
+    } else {
        print "ERROR: canonicalised query differs from original\n";
     }
 }
+
+print "Passed $nok/$n -- ", int(100*$nok/$n), "%\n";
index c4104ca..6075e69 100644 (file)
@@ -26,7 +26,7 @@ dc.title any/stem fish
 dc.fish all/stem/fuzzy "fish chips"
 (title any frog)
 ((dc.title any/stem "frog pond"))
-dc.title scr "fish frog chicken"
+dc.title any "fish frog chicken"
 dc.title =/rel.algorithm=CORI squid
 author any/f.foo/b.bar>1 "sanderson taylor"
 numberOfLegs <= 4
@@ -57,7 +57,7 @@ cat prox/distance=3/unit=word/ordered hat
 cat prox/distance<3 hat
 "fish food" prox/unit=sentence and
 title all "chips frog" prox/distance<=5 exact
-(dc.author exact "jones" prox/distance>5/unit=element title >= "smith")
+(dc.author == "jones" prox/distance>5/unit=element title >= "smith")
 ((cat prox hat))
 a and/rel.SumOfScores b
 a and/rel.algorithm=CORI b
@@ -85,7 +85,7 @@ cat?dog
 
 # Lame Searches
 
-any or all:stem and all exact any prox prox=fuzzy
+any or all:stem and all contains any prox proxfuzzy
 (((((((((any)))))))))
 ""
 > any > any = exact any > any
index 2b78ddf..edd35b8 100644 (file)
@@ -1,7 +1,7 @@
 <searchClause>
-  <index>title</index>
+  <index>cql.serverChoice</index>
   <relation>
-    <value>exact</value>
+    <value>=</value>
   </relation>
-  <term>fish</term>
+  <term>title exact fish</term>
 </searchClause>
index a648cc5..b4bcf3b 100644 (file)
@@ -1,7 +1,7 @@
 <searchClause>
   <index>dc.title</index>
   <relation>
-    <value>scr</value>
+    <value>any</value>
   </relation>
   <term>fish frog chicken</term>
 </searchClause>
index 42029b0..4ffea29 100644 (file)
@@ -18,7 +18,7 @@
     <searchClause>
       <index>dc.author</index>
       <relation>
-        <value>exact</value>
+        <value>==</value>
       </relation>
       <term>jones</term>
     </searchClause>
index d0a5e52..f721ed0 100644 (file)
@@ -1,55 +1,39 @@
 <triple>
   <boolean>
-    <value>prox</value>
+    <value>and</value>
   </boolean>
   <leftOperand>
     <triple>
       <boolean>
-        <value>and</value>
+        <value>or</value>
       </boolean>
       <leftOperand>
-        <triple>
-          <boolean>
-            <value>or</value>
-          </boolean>
-          <leftOperand>
-            <searchClause>
-              <index>cql.serverChoice</index>
-              <relation>
-                <value>=</value>
-              </relation>
-              <term>any</term>
-            </searchClause>
-          </leftOperand>
-          <rightOperand>
-            <searchClause>
-              <index>cql.serverChoice</index>
-              <relation>
-                <value>=</value>
-              </relation>
-              <term>all:stem</term>
-            </searchClause>
-          </rightOperand>
-        </triple>
+        <searchClause>
+          <index>cql.serverChoice</index>
+          <relation>
+            <value>=</value>
+          </relation>
+          <term>any</term>
+        </searchClause>
       </leftOperand>
       <rightOperand>
         <searchClause>
-          <index>all</index>
+          <index>cql.serverChoice</index>
           <relation>
-            <value>exact</value>
+            <value>=</value>
           </relation>
-          <term>any</term>
+          <term>all:stem</term>
         </searchClause>
       </rightOperand>
     </triple>
   </leftOperand>
   <rightOperand>
     <searchClause>
-      <index>prox</index>
+      <index>all contains</index>
       <relation>
-        <value>=</value>
+        <value>any</value>
       </relation>
-      <term>fuzzy</term>
+      <term>prox proxfuzzy</term>
     </searchClause>
   </rightOperand>
 </triple>