- Add support for the new "phonetic" relation modifier,
authormike <mike>
Sun, 17 Nov 2002 23:29:02 +0000 (23:29 +0000)
committermike <mike>
Sun, 17 Nov 2002 23:29:02 +0000 (23:29 +0000)
  including its mapping in "etc/pqf.properties".
- Make prefix-maps bind loosely, so that ``>dc=x a and b''
  applies the dc=x binding to both the ``a'' and ``b''
  sub-queries.
- Write javadoc comments for CQLRelation and ModifierSet.
- Other improvements to javadoc comments (e.g. describe the
  `config' parameter to the toPQF() method.)

Changes
VERSION
etc/pqf.properties
src/org/z3950/zing/cql/CQLLexer.java
src/org/z3950/zing/cql/CQLNode.java
src/org/z3950/zing/cql/CQLParser.java
src/org/z3950/zing/cql/CQLRelation.java
src/org/z3950/zing/cql/Makefile
src/org/z3950/zing/cql/ModifierSet.java

diff --git a/Changes b/Changes
index 0368e07..6531dcb 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,8 +1,20 @@
-$Id: Changes,v 1.12 2002-11-15 15:28:03 mike Exp $
+$Id: Changes,v 1.13 2002-11-17 23:29:02 mike Exp $
 
 Revision history for "cql-java"
 See the bottom of this file for a list of things still to do.
 
+0.4  (IN PROGRESS)
+       - Add support for the new "phonetic" relation modifier,
+         including its mapping in "etc/pqf.properties".
+       - Make prefix-maps bind loosely, so that ``>dc=x a and b''
+         applies the dc=x binding to both the ``a'' and ``b''
+         sub-queries.
+       - Change build process so that javadoc documentation is built
+         by "make" in the "docs" directory.
+       - Write javadoc comments for CQLRelation and ModifierSet.
+       - Other improvements to javadoc comments (e.g. describe the
+         `config' parameter to the toPQF() method.)
+
 0.3  Fri Nov 15 12:04:04 2002
        - Allow keywords to be used unquoted as search terms.
        - Add support for serverChoiceRelation (scr).
@@ -62,14 +74,12 @@ See the bottom of this file for a list of things still to do.
        - Fix the bug where "9x" is parsed as two tokens, a TT_NUMBER
          followed by a TT_WORD.  The problem here is that I don't
          think it's actually possible to fix this without throwing
-         out StreakTokenizer and rolling our own, which we absolutely
+         out StreamTokenizer and rolling our own, which we absolutely
          _don't_ want to do.
-       - Add support for the new "phonetic" relation modifier,
-         including its mapping in "etc/pqf.properties".
-       - Describe prefix-mapping in the CQL tutorial (not really
-         anything to do with cql-java, but this note will remind me
-         to do it.)
-       - Write javadoc comments for CQLRelation and ModifierSet.
+       - Find out what the ZNG group finally settled on as the
+         correct XCQL representation of prefix-mapping, and tweak my
+         toXCQL() output to match that.
+       - Add srw.resultSet support to the toPFQ() method.
        - Write "overview" file for the javadoc documentation.
        - Some niceties for the cql-decompiling back-end:
          * Don't emit redundant parentheses.
diff --git a/VERSION b/VERSION
index 29dd56d..bd73f47 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.4-IN-PROGRESS
+0.4
index 875d871..fd857aa 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: pqf.properties,v 1.3 2002-11-06 20:13:45 mike Exp $
+# $Id: pqf.properties,v 1.4 2002-11-17 23:29:02 mike Exp $
 #
 # Propeties file to drive org.z3950.zing.cql.CQLNode's toPQF()
 # back-end.  This specifies the interpretation of various CQL
@@ -9,11 +9,13 @@
 # qualifiers to Attribute Architecture (util, XD and BIB-2)
 # attributes.
 
-# The default access point:
-#
+# The default access point and result-set references
 qualifier.srw.serverChoice             = 1=1016
        # "any"
 
+### This needs special support in the renderer
+qualifier.srw.resultSet                        = @set
+
 qualifier.dc.title                     = 1=4
 qualifier.dc.subject                   = 1=21
 qualifier.dc.creator                   = 1=1003
@@ -61,12 +63,17 @@ relation.<>                         = 2=6
 relation.all                           = 2=3
 relation.any                           = 2=3
 
+# BIB-1 doesn't have a server choice relation, so we just make the
+# choice here, and use equality (which is clearly correct).
+relation.scr                           = 2=3
+
 # Relation modifiers.
 #
 relationModifier.relevant              = 2=102
 relationModifier.fuzzy                 = 2=100
        ### 100 is "phonetic", which is not quite the same thing
 relationModifier.stem                  = 2=101
+relationModifier.phonetic              = 2=100
 
 # Position attributes may be specified for anchored terms (those
 # beginning with "^", which is stripped) and unanchored (those not
index 8ae5085..2cb0369 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: CQLLexer.java,v 1.5 2002-11-14 22:04:16 mike Exp $
+// $Id: CQLLexer.java,v 1.6 2002-11-17 23:29:02 mike Exp $
 
 package org.z3950.zing.cql;
 import java.io.StreamTokenizer;
@@ -36,6 +36,7 @@ class CQLLexer extends StreamTokenizer {
     static int TT_FUZZY     = 1017;    // The "fuzzy" relation modifier
     static int TT_STEM      = 1018;    // The "stem" relation modifier
     static int TT_SCR       = 1019;    // The server choice relation
+    static int TT_PHONETIC  = 1020;    // The "phonetic" relation modifier
 
     // Support for keywords.  It would be nice to compile this linear
     // list into a Hashtable, but it's hard to store ints as hash
@@ -69,6 +70,7 @@ class CQLLexer extends StreamTokenizer {
        new Keyword(TT_FUZZY, "fuzzy"),
        new Keyword(TT_STEM, "stem"),
        new Keyword(TT_SCR, "scr"),
+       new Keyword(TT_PHONETIC, "phonetic"),
     };
 
     // For halfDecentPushBack() and the code at the top of nextToken()
index cff3d3a..e0fc2e5 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: CQLNode.java,v 1.13 2002-11-08 16:32:01 mike Exp $
+// $Id: CQLNode.java,v 1.14 2002-11-17 23:29:02 mike Exp $
 
 package org.z3950.zing.cql;
 import java.util.Properties;
@@ -7,7 +7,7 @@ import java.util.Properties;
 /**
  * Represents a node in a CQL parse-tree.
  *
- * @version    $Id: CQLNode.java,v 1.13 2002-11-08 16:32:01 mike Exp $
+ * @version    $Id: CQLNode.java,v 1.14 2002-11-17 23:29:02 mike Exp $
  */
 public abstract class CQLNode {
     CQLNode() {}               // prevent javadoc from documenting this
@@ -46,6 +46,13 @@ public abstract class CQLNode {
      * >Chapter 7 (Supporting Tools)</A> of the
      * <A href="http://indexdata.dk/yaz/">YAZ</A> manual.
      * <P>
+     * @param config
+     * A <TT>Properties</TT> object containing configuration
+     * information that specifies the mapping from CQL qualifiers,
+     * relations, etc. to Type-1 attributes.  The mapping
+     * specification is described in the cql-java distribution's
+     * sample PQF-mapping configuration file,
+     * <TT>etc/pqf.properties</TT>, which see.
      * @return
      * A String containing a PQF query equivalent to the parse-tree
      * whose root is this node.  This may be fed into the tool of
index eadedef..6726999 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: CQLParser.java,v 1.20 2002-11-14 22:04:16 mike Exp $
+// $Id: CQLParser.java,v 1.21 2002-11-17 23:29:02 mike Exp $
 
 package org.z3950.zing.cql;
 import java.io.IOException;
@@ -12,7 +12,7 @@ import java.io.FileNotFoundException;
 /**
  * Compiles CQL strings into parse trees of CQLNode subtypes.
  *
- * @version    $Id: CQLParser.java,v 1.20 2002-11-14 22:04:16 mike Exp $
+ * @version    $Id: CQLParser.java,v 1.21 2002-11-17 23:29:02 mike Exp $
  * @see                <A href="http://zing.z3950.org/cql/index.html"
  *                     >http://zing.z3950.org/cql/index.html</A>
  */
@@ -119,7 +119,8 @@ public class CQLParser {
                match('/');
                if (lexer.ttype != lexer.TT_RELEVANT &&
                    lexer.ttype != lexer.TT_FUZZY &&
-                   lexer.ttype != lexer.TT_STEM)
+                   lexer.ttype != lexer.TT_STEM &&
+                   lexer.ttype != lexer.TT_PHONETIC)
                    throw new CQLParseException("expected relation modifier, "
                                                + "got " + lexer.render());
                relation.addModifier(lexer.sval.toLowerCase());
@@ -146,7 +147,7 @@ public class CQLParser {
            name = identifier;
            identifier = matchSymbol("prefix-identifer");
        }
-       CQLNode term = parseTerm(qualifier, relation);
+       CQLNode term = parseQuery(qualifier, relation);
        return new CQLPrefixNode(name, identifier, term);
     }
 
@@ -223,6 +224,7 @@ public class CQLParser {
                lexer.ttype == lexer.TT_SCR);
     }
 
+    // Checks for a relation that may be used inside a prox operator
     private boolean isProxRelation() {
        debug("isProxRelation: checking ttype=" + lexer.ttype +
              " (" + lexer.render() + ")");
@@ -257,6 +259,8 @@ public class CQLParser {
            // The following is a complete list of keywords.  Because
            // they're listed here, they can be used unquoted as
            // qualifiers, terms, prefix names and prefix identifiers.
+           // ### Instead, we should ask the lexer whether what we
+           // have is a keyword, and let the knowledge reside there.
            lexer.ttype == lexer.TT_AND ||
            lexer.ttype == lexer.TT_OR ||
            lexer.ttype == lexer.TT_NOT ||
@@ -273,7 +277,8 @@ public class CQLParser {
            lexer.ttype == lexer.TT_RELEVANT ||
            lexer.ttype == lexer.TT_FUZZY ||
            lexer.ttype == lexer.TT_STEM ||
-           lexer.ttype == lexer.TT_SCR) {
+           lexer.ttype == lexer.TT_SCR ||
+           lexer.ttype == lexer.TT_PHONETIC) {
            String symbol = (lexer.ttype == lexer.TT_NUMBER) ?
                lexer.render() : lexer.sval;
            match(lexer.ttype);
index 0d98674..36fae4a 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: CQLRelation.java,v 1.5 2002-11-06 20:13:45 mike Exp $
+// $Id: CQLRelation.java,v 1.6 2002-11-17 23:29:02 mike Exp $
 
 package org.z3950.zing.cql;
 import java.util.Vector;
@@ -8,23 +8,47 @@ import java.lang.StringBuffer;
 /**
  * Represents a relation between a CQL qualifier and term.
  *
- * @version    $Id: CQLRelation.java,v 1.5 2002-11-06 20:13:45 mike Exp $
+ * @version    $Id: CQLRelation.java,v 1.6 2002-11-17 23:29:02 mike Exp $
  */
 public class CQLRelation extends CQLNode {
     ModifierSet ms;
 
+    /**
+     * Creates a new CQLRelation with the specified base relation.
+     * Typical base relations include the usual six ordering relations
+     * (<TT>&lt;=</TT>, <TT>&gt</TT>, <I>etc.</I>), the text
+     * relations <TT>any</TT>, <TT>all</TT> and <TT>exact</TT> and the
+     * server-choice relation <TT>scr</TT>.
+     */
     public CQLRelation(String base) {
        ms = new ModifierSet(base);
     }
 
+    /**
+     * Returns the base relation with which the CQLRelation was
+     * originally created.
+     */
     public String getBase() {
        return ms.getBase();
     }
 
+    /**
+     * Adds a new relation modifier to the specified CQLRelation.
+     * Typical relation modifiers include <TT>relevant</TT>,
+     * <TT>fuzzy</TT>, <TT>stem</TT> and <TT>phonetic</TT>.  On the
+     * whole, these modifiers have a meaningful interpretation only
+     * for the text relations.
+     */
     public void addModifier(String modifier) {
        ms.addModifier(null, modifier);
     }
 
+    /**
+     * Returns an array of the modifiers associated with a CQLRelation.
+     * @return
+     * An array of zero or more <TT>String</TT>s, each representing a
+     * modifier associated with the specified CQLRelation.
+     */
     public String[] getModifiers() {
        Vector[] v = ms.getModifiers();
        int n = v.length;
index 029ca04..1394928 100644 (file)
@@ -1,13 +1,11 @@
-# $Id: Makefile,v 1.11 2002-11-14 22:04:16 mike Exp $
+# $Id: Makefile,v 1.12 2002-11-17 23:29:02 mike Exp $
 #
-# Your Java compiler, and javadoc, will require that this source
-# directory is on the classpath.  The best way to do that is just to
-# add the cql-java distribution's "src" subdirectory to your CLASSPATH
-# environment variable, like this:
+# Your Java compiler will require that this source directory is on the
+# classpath.  The best way to do that is just to add the cql-java
+# distribution's "src" subdirectory to your CLASSPATH environment
+# variable, like this:
 #      CLASSPATH=$CLASSPATH:/where/ever/you/unpacked/it/cql-java-VERSION/src
 
-DOCDIR = ../../../../../docs
-
 OBJ = Utils.class \
        CQLNode.class CQLTermNode.class CQLBooleanNode.class \
        CQLAndNode.class CQLOrNode.class CQLNotNode.class \
@@ -25,24 +23,6 @@ OBJ = Utils.class \
 %.class: %.java
        javac $<
 
-docs: $(DOCDIR)/overview-tree.html
-
-$(DOCDIR)/overview-tree.html: *.java
-       nice javadoc -d $(DOCDIR) -author -version \
-               -windowtitle cql-java org.z3950.zing.cql
-
 clean:
        rm -f $(OBJ) 'CQLLexer$$Keyword.class'
 
-cleandocs:
-       rm -rf  $(DOCDIR)/allclasses-frame.html \
-               $(DOCDIR)/deprecated-list.html \
-               $(DOCDIR)/help-doc.html \
-               $(DOCDIR)/index-all.html \
-               $(DOCDIR)/index.html \
-               $(DOCDIR)/org \
-               $(DOCDIR)/overview-tree.html \
-               $(DOCDIR)/package-list \
-               $(DOCDIR)/packages.html \
-               $(DOCDIR)/serialized-form.html \
-               $(DOCDIR)/stylesheet.css
index 8b8c245..c88a694 100644 (file)
@@ -1,4 +1,4 @@
-// $Id: ModifierSet.java,v 1.4 2002-11-06 20:13:45 mike Exp $
+// $Id: ModifierSet.java,v 1.5 2002-11-17 23:29:02 mike Exp $
 
 package org.z3950.zing.cql;
 import java.util.Vector;
@@ -9,23 +9,37 @@ import java.lang.StringBuffer;
  * <P>
  * This class is used as a workhorse delegate by both CQLRelation and
  * CQLProxNode - two functionally very separate classes that happen to
- * require the same data structures and functionality.
+ * require similar data structures and functionality.
+ * <P>
+ * A ModifierSet consists of a ``base'' string together with a set of
+ * zero or more <I>type</I>=<I>value</I> pairs, where both type and
+ * value are strings.  Types may be null, values may not.
  *
- * @version $Id: ModifierSet.java,v 1.4 2002-11-06 20:13:45 mike Exp $
+ * @version $Id: ModifierSet.java,v 1.5 2002-11-17 23:29:02 mike Exp $
  */
 public class ModifierSet {
     String base;
     Vector modifiers;
 
+    /**
+     * Creates a new ModifierSet with the specified base.
+     */
     public ModifierSet(String base) {
        this.base = base;
        modifiers = new Vector();
     }
 
+    /**
+     * Returns the base string with which the ModifierSet was created.
+     */
     public String getBase() {
        return base;
     }
 
+    /**
+     * Adds a modifier of the specified <TT>type</TT> and
+     * <TT>value</TT> to a ModifierSet.
+     */
     public void addModifier(String type, String value) {
        Vector modifier = new Vector();
        modifier.add(type);
@@ -33,6 +47,10 @@ public class ModifierSet {
        modifiers.add(modifier);
     }
 
+    /**
+     * Returns the value of the modifier in the specified ModifierSet
+     * that corresponds to the specified type.
+     */
     public String modifier(String type) {
        int n = modifiers.size();
        for (int i = 0; i < n; i++) {
@@ -43,6 +61,13 @@ public class ModifierSet {
        return null;
     }
 
+    /**
+     * Returns an array of the modifiers in a ModifierSet.
+     * @return
+     * An array of modifiers, each represented by a two-element
+     * <TT>Vector</TT>, in which element 0 is the modifier type and
+     * element 1 is the associated value.
+     */
     public Vector[] getModifiers() {
        int n = modifiers.size();
        Vector[] res = new Vector[n];