lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r381108 - in /lucene/java/trunk/contrib/regex/src: java/org/apache/lucene/search/regex/ java/org/apache/regexp/ test/org/apache/lucene/search/regex/
Date Sun, 26 Feb 2006 15:38:33 GMT
Author: ehatcher
Date: Sun Feb 26 07:38:30 2006
New Revision: 381108

URL: http://svn.apache.org/viewcvs?rev=381108&view=rev
Log:
Many javadoc additions, and adding ASL to each file

Added:
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/package.html
    lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/package.html
Modified:
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexCapabilities.java
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQuery.java
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQueryCapable.java
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexTermEnum.java
    lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/SpanRegexQuery.java
    lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/RegexpTunnel.java
    lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java
(original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JakartaRegexpCapabilities.java
Sun Feb 26 07:38:30 2006
@@ -1,8 +1,29 @@
 package org.apache.lucene.search.regex;
 
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import org.apache.regexp.RE;
 import org.apache.regexp.RegexpTunnel;
 
+/**
+ * Implementation tying <a href="http://jakarta.apache.org/regexp">Jakarta Regexp</a>
+ * to RegexQuery.  Thanks to some internals of Jakarta Regexp, this
+ * has a solid {@link #prefix} implementation.
+ */
 public class JakartaRegexpCapabilities implements RegexCapabilities {
   private RE regexp;
 

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
(original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java
Sun Feb 26 07:38:30 2006
@@ -1,7 +1,30 @@
 package org.apache.lucene.search.regex;
 
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import java.util.regex.Pattern;
 
+/**
+ * An implementation tying Java's built-in java.util.regex to RegexQuery.
+ *
+ * Note that because this implementation currently only returns null from
+ * {@link #prefix} that queries using this implementation will enumerate and
+ * attempt to {@link #match} each term for the specified field in the index.
+ */
 public class JavaUtilRegexCapabilities implements RegexCapabilities {
   private Pattern pattern;
 

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexCapabilities.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexCapabilities.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexCapabilities.java
(original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexCapabilities.java
Sun Feb 26 07:38:30 2006
@@ -1,7 +1,47 @@
 package org.apache.lucene.search.regex;
 
-public interface RegexCapabilities {
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Defines basic operations needed by {@link RegexQuery} for a regular
+ * expression implementation.
+ */
+interface RegexCapabilities {
+  /**
+   * Called by the constructor of {@link RegexTermEnum} allowing
+   * implementations to cache a compiled version of the regular
+   * expression pattern.
+   *
+   * @param pattern regular expression pattern
+   */
   void compile(String pattern);
+
+  /**
+   *
+   * @param string
+   * @return true if string matches the pattern last passed to {@link #compile}.
+   */
   boolean match(String string);
+
+  /**
+   * A wise prefix implementation can reduce the term enumeration (and thus performance)
+   * of RegexQuery dramatically!
+   *
+   * @return static non-regex prefix of the pattern last passed to {@link #compile}.  May
return null.
+   */
   String prefix();
 }

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQuery.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQuery.java
(original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQuery.java
Sun Feb 26 07:38:30 2006
@@ -1,5 +1,21 @@
 package org.apache.lucene.search.regex;
 
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import org.apache.lucene.search.MultiTermQuery;
 import org.apache.lucene.search.FilteredTermEnum;
 import org.apache.lucene.index.Term;
@@ -7,17 +23,32 @@
 
 import java.io.IOException;
 
+/** Implements the regular expression term search query.
+ * The expressions supported depend on the regular expression implementation
+ * used by way of the {@link RegexCapabilities} interface.
+ *
+ * @see RegexTermEnum
+ */
 public class RegexQuery extends MultiTermQuery implements RegexQueryCapable {
   private RegexCapabilities regexImpl = new JavaUtilRegexCapabilities();
 
+  /** Constructs a query for terms matching <code>term</code>. */
   public RegexQuery(Term term) {
     super(term);
   }
 
+  /**
+   * Defines which {@link RegexCapabilities} implementation is used by this instance.
+   *
+   * @param impl
+   */
   public void setRegexImplementation(RegexCapabilities impl) {
     this.regexImpl = impl;
   }
 
+  /**
+   * @return The implementation used by this instance.
+   */
   public RegexCapabilities getRegexImplementation() {
     return regexImpl;
   }

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQueryCapable.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQueryCapable.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQueryCapable.java
(original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexQueryCapable.java
Sun Feb 26 07:38:30 2006
@@ -1,6 +1,26 @@
 package org.apache.lucene.search.regex;
 
-public interface RegexQueryCapable {
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
+ * Defines methods for regular expression supporting Querys to use.
+ */
+interface RegexQueryCapable {
   void setRegexImplementation(RegexCapabilities impl);
   RegexCapabilities getRegexImplementation();
 }

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexTermEnum.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexTermEnum.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexTermEnum.java
(original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/RegexTermEnum.java
Sun Feb 26 07:38:30 2006
@@ -1,10 +1,35 @@
 package org.apache.lucene.search.regex;
 
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import org.apache.lucene.search.FilteredTermEnum;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 
 import java.io.IOException;
+
+/**
+ * Subclass of FilteredTermEnum for enumerating all terms that match the
+ * specified regular expression term using the specified regular expression
+ * implementation.
+ * <p>
+ * Term enumerations are always ordered by Term.compareTo().  Each term in
+ * the enumeration is greater than all that precede it.
+ */
 
 public class RegexTermEnum extends FilteredTermEnum {
   private String field = "";

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/SpanRegexQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/SpanRegexQuery.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/SpanRegexQuery.java
(original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/SpanRegexQuery.java
Sun Feb 26 07:38:30 2006
@@ -1,5 +1,21 @@
 package org.apache.lucene.search.regex;
 
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.search.Query;
@@ -16,6 +32,10 @@
 import java.util.Collection;
 import java.util.ArrayList;
 
+/**
+ * A SpanQuery version of {@link RegexQuery} allowing regular expression
+ * queries to be nested within other SpanQuery subclasses.
+ */
 public class SpanRegexQuery extends SpanQuery implements RegexQueryCapable {
   private RegexCapabilities regexImpl = new JavaUtilRegexCapabilities();
   private Term term;

Added: lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/package.html
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/package.html?rev=381108&view=auto
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/package.html (added)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/lucene/search/regex/package.html Sun
Feb 26 07:38:30 2006
@@ -0,0 +1,5 @@
+<html><head></head>
+<body>
+Regular expression Query.
+</body>
+</html>

Modified: lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/RegexpTunnel.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/RegexpTunnel.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/RegexpTunnel.java (original)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/RegexpTunnel.java Sun Feb 26
07:38:30 2006
@@ -1,6 +1,23 @@
 package org.apache.regexp;
 
 /**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/**
  * This class exists as a gateway to access useful Jakarta Regexp package protected data.
  */
 public class RegexpTunnel {

Added: lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/package.html
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/package.html?rev=381108&view=auto
==============================================================================
--- lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/package.html (added)
+++ lucene/java/trunk/contrib/regex/src/java/org/apache/regexp/package.html Sun Feb 26 07:38:30
2006
@@ -0,0 +1,7 @@
+<html><head></head>
+<body>
+This package exists to allow access to useful package protected data within
+Jakarta Regexp.  This data has now been opened up with an accessor, but
+an official release with that change has not been made to date.
+</body>
+</html>

Modified: lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java?rev=381108&r1=381107&r2=381108&view=diff
==============================================================================
--- lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
(original)
+++ lucene/java/trunk/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
Sun Feb 26 07:38:30 2006
@@ -12,22 +12,29 @@
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.search.spans.SpanNearQuery;
 import org.apache.lucene.search.spans.SpanQuery;
+import org.apache.lucene.search.spans.SpanFirstQuery;
 
 public class TestSpanRegexQuery extends TestCase {
   public void testSpanRegex() throws Exception {
     RAMDirectory directory = new RAMDirectory();
     IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), true);
     Document doc = new Document();
-    doc.add(new Field("field", "the quick brown fox jumps over the lazy dog", Field.Store.NO,
Field.Index.TOKENIZED));
+//    doc.add(new Field("field", "the quick brown fox jumps over the lazy dog", Field.Store.NO,
Field.Index.TOKENIZED));
+//    writer.addDocument(doc);
+//    doc = new Document();
+    doc.add(new Field("field", "auto update", Field.Store.NO, Field.Index.TOKENIZED));
+    writer.addDocument(doc);
+    doc = new Document();
+    doc.add(new Field("field", "first auto update", Field.Store.NO, Field.Index.TOKENIZED));
     writer.addDocument(doc);
     writer.optimize();
     writer.close();
 
     IndexSearcher searcher = new IndexSearcher(directory);
-    SpanRegexQuery srq = new SpanRegexQuery(new Term("field", "q.[aeiou]c.*"));
-    SpanTermQuery stq = new SpanTermQuery(new Term("field","dog"));
-    SpanNearQuery query = new SpanNearQuery(new SpanQuery[] {srq, stq}, 6, true);
-    Hits hits = searcher.search(query);
+    SpanRegexQuery srq = new SpanRegexQuery(new Term("field", "aut.*"));
+    SpanFirstQuery sfq = new SpanFirstQuery(srq, 1);
+//    SpanNearQuery query = new SpanNearQuery(new SpanQuery[] {srq, stq}, 6, true);
+    Hits hits = searcher.search(sfq);
     assertEquals(1, hits.length());
   }
 }



Mime
View raw message