You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by ma...@apache.org on 2009/03/24 13:28:15 UTC
svn commit: r757762 - in /lucene/java/trunk/contrib/surround: README.txt
src/test/org/apache/lucene/queryParser/surround/query/Test03Distance.java
Author: markrmiller
Date: Tue Mar 24 12:28:13 2009
New Revision: 757762
URL: http://svn.apache.org/viewvc?rev=757762&view=rev
Log:
LUCENE-1563:Add example test case for surround query language
Modified:
lucene/java/trunk/contrib/surround/README.txt
lucene/java/trunk/contrib/surround/src/test/org/apache/lucene/queryParser/surround/query/Test03Distance.java
Modified: lucene/java/trunk/contrib/surround/README.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/surround/README.txt?rev=757762&r1=757761&r2=757762&view=diff
==============================================================================
--- lucene/java/trunk/contrib/surround/README.txt (original)
+++ lucene/java/trunk/contrib/surround/README.txt Tue Mar 24 12:28:13 2009
@@ -39,7 +39,7 @@
99n(aa,bb,cc) unordered span query with slop 98
20n(aa*,bb*)
-3w(a?a or bb?, cc+)
+3w(a?a or bb?, cc*)
title: text: aa
title : text : aa or bb
@@ -64,12 +64,11 @@
* suffix truncation is implemented very similar to Lucene's PrefixQuery.
Wildcards (? and internal *) are implemented with regular expressions
-allow further variations. A reimplementation using
+to allow further variations. A reimplementation using
WildCardTermEnum (correct name?) should be no problem.
Warnings about missing terms are sent to System.out, this might
-be replaced by another stream.
+be replaced by another stream, and tested for in the tests.
-BooleanQueryTest.TestCollector uses a results checking method that should
+BooleanQueryTst.TestCollector uses a results checking method that should
be replaced by the checking method from Lucene's TestBasics.java.
-
Modified: lucene/java/trunk/contrib/surround/src/test/org/apache/lucene/queryParser/surround/query/Test03Distance.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/surround/src/test/org/apache/lucene/queryParser/surround/query/Test03Distance.java?rev=757762&r1=757761&r2=757762&view=diff
==============================================================================
--- lucene/java/trunk/contrib/surround/src/test/org/apache/lucene/queryParser/surround/query/Test03Distance.java (original)
+++ lucene/java/trunk/contrib/surround/src/test/org/apache/lucene/queryParser/surround/query/Test03Distance.java Tue Mar 24 12:28:13 2009
@@ -59,26 +59,15 @@
SingleFieldTestDb db1 = new SingleFieldTestDb(docs1, fieldName);
- String[] docs2 = {
- "w1 w2 w3 w4 w5",
- "w1 w3 w2 w3",
- ""
- };
-
- SingleFieldTestDb db2 = new SingleFieldTestDb(docs2, fieldName);
-
- public void distanceTest1(String query, int[] expdnrs) throws Exception {
- BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db1, fieldName, this,
+ private void distanceTst(String query, int[] expdnrs, SingleFieldTestDb db) throws Exception {
+ BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db, fieldName, this,
new BasicQueryFactory(maxBasicQueries));
bqt.setVerbose(verbose);
bqt.doTest();
}
- public void distanceTest2(String query, int[] expdnrs) throws Exception {
- BooleanQueryTst bqt = new BooleanQueryTst( query, expdnrs, db2, fieldName, this,
- new BasicQueryFactory(maxBasicQueries));
- bqt.setVerbose(verbose);
- bqt.doTest();
+ public void distanceTest1(String query, int[] expdnrs) throws Exception {
+ distanceTst(query, expdnrs, db1);
}
public void test0W01() throws Exception {
@@ -182,6 +171,18 @@
public void test1Ntrunc09() throws Exception {
int[] expdnrs = {3}; distanceTest1( "(orda2 OR orda3) 2N (word2 OR worda3)", expdnrs);
}
+
+ String[] docs2 = {
+ "w1 w2 w3 w4 w5",
+ "w1 w3 w2 w3",
+ ""
+ };
+
+ SingleFieldTestDb db2 = new SingleFieldTestDb(docs2, fieldName);
+
+ public void distanceTest2(String query, int[] expdnrs) throws Exception {
+ distanceTst(query, expdnrs, db2);
+ }
public void test2Wprefix01() throws Exception {
int[] expdnrs = {0}; distanceTest2( "W (w1, w2, w3)", expdnrs);
@@ -217,4 +218,25 @@
public void test2Nnested02() throws Exception {
int[] expdnrs = {0,1}; distanceTest2( "w1 2N w2 2N w3", expdnrs);
}
+
+ String[] docs3 = {
+ "low pressure temperature inversion and rain",
+ "when the temperature has a negative height above a depression no precipitation gradient is expected",
+ "when the temperature has a negative height gradient above a depression no precipitation is expected",
+ ""
+ };
+
+ SingleFieldTestDb db3 = new SingleFieldTestDb(docs3, fieldName);
+
+ public void distanceTest3(String query, int[] expdnrs) throws Exception {
+ distanceTst(query, expdnrs, db3);
+ }
+
+ public void test3Example01() throws Exception {
+ int[] expdnrs = {0,2}; // query does not match doc 1 because "gradient" is in wrong place there.
+ distanceTest3("50n((low w pressure*) or depression*,"
+ + "5n(temperat*, (invers* or (negativ* 3n gradient*))),"
+ + "rain* or precipitat*)",
+ expdnrs);
+ }
}