You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ar...@apache.org on 2008/07/15 23:44:10 UTC
svn commit: r677059 [14/19] - in /incubator/lucene.net/trunk/C#/src: ./
Demo/DeleteFiles/ Demo/DemoLib/ Demo/IndexFiles/ Demo/IndexHtml/
Demo/SearchFiles/ Lucene.Net/ Lucene.Net/Analysis/ Lucene.Net/Index/
Lucene.Net/Search/ Lucene.Net/Search/Function/...
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpanExplanations.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/Spans/TestSpanExplanations.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpanExplanations.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpanExplanations.cs Tue Jul 15 14:44:04 2008
@@ -47,7 +47,7 @@
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
+ [Test]
public virtual void TestST2()
{
SpanQuery q = St("w1");
@@ -55,14 +55,14 @@
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
+ [Test]
public virtual void TestST4()
{
SpanQuery q = St("xx");
Qtest(q, new int[]{2, 3});
}
- [Test]
+ [Test]
public virtual void TestST5()
{
SpanQuery q = St("xx");
@@ -72,37 +72,37 @@
/* some SpanFirstQueries */
- [Test]
- public virtual void TestSF1()
+ [Test]
+ public virtual void TestSF1()
{
SpanQuery q = Sf(("w1"), 1);
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSF2()
+ [Test]
+ public virtual void TestSF2()
{
SpanQuery q = Sf(("w1"), 1);
q.SetBoost(1000);
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSF4()
+ [Test]
+ public virtual void TestSF4()
{
SpanQuery q = Sf(("xx"), 2);
Qtest(q, new int[]{2});
}
- [Test]
- public virtual void TestSF5()
+ [Test]
+ public virtual void TestSF5()
{
SpanQuery q = Sf(("yy"), 2);
Qtest(q, new int[]{});
}
- [Test]
- public virtual void TestSF6()
+ [Test]
+ public virtual void TestSF6()
{
SpanQuery q = Sf(("yy"), 4);
q.SetBoost(1000);
@@ -111,29 +111,29 @@
/* some SpanOrQueries */
- [Test]
- public virtual void TestSO1()
+ [Test]
+ public virtual void TestSO1()
{
SpanQuery q = Sor("w1", "QQ");
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSO2()
+ [Test]
+ public virtual void TestSO2()
{
SpanQuery q = Sor("w1", "w3", "zz");
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSO3()
+ [Test]
+ public virtual void TestSO3()
{
SpanQuery q = Sor("w5", "QQ", "yy");
Qtest(q, new int[]{0, 2, 3});
}
- [Test]
- public virtual void TestSO4()
+ [Test]
+ public virtual void TestSO4()
{
SpanQuery q = Sor("w5", "QQ", "yy");
Qtest(q, new int[]{0, 2, 3});
@@ -143,78 +143,78 @@
/* some SpanNearQueries */
- [Test]
- public virtual void TestSNear1()
+ [Test]
+ public virtual void TestSNear1()
{
SpanQuery q = Snear("w1", "QQ", 100, true);
Qtest(q, new int[]{});
}
- [Test]
- public virtual void TestSNear2()
+ [Test]
+ public virtual void TestSNear2()
{
SpanQuery q = Snear("w1", "xx", 100, true);
Qtest(q, new int[]{2, 3});
}
- [Test]
- public virtual void TestSNear3()
+ [Test]
+ public virtual void TestSNear3()
{
SpanQuery q = Snear("w1", "xx", 0, true);
Qtest(q, new int[]{2});
}
- [Test]
- public virtual void TestSNear4()
+ [Test]
+ public virtual void TestSNear4()
{
SpanQuery q = Snear("w1", "xx", 1, true);
Qtest(q, new int[]{2, 3});
}
- [Test]
- public virtual void TestSNear5()
+ [Test]
+ public virtual void TestSNear5()
{
SpanQuery q = Snear("xx", "w1", 0, false);
Qtest(q, new int[]{2});
}
- [Test]
- public virtual void TestSNear6()
+ [Test]
+ public virtual void TestSNear6()
{
SpanQuery q = Snear("w1", "w2", "QQ", 100, true);
Qtest(q, new int[]{});
}
- [Test]
- public virtual void TestSNear7()
+ [Test]
+ public virtual void TestSNear7()
{
SpanQuery q = Snear("w1", "xx", "w2", 100, true);
Qtest(q, new int[]{2, 3});
}
- [Test]
- public virtual void TestSNear8()
+ [Test]
+ public virtual void TestSNear8()
{
SpanQuery q = Snear("w1", "xx", "w2", 0, true);
Qtest(q, new int[]{2});
}
- [Test]
- public virtual void TestSNear9()
+ [Test]
+ public virtual void TestSNear9()
{
SpanQuery q = Snear("w1", "xx", "w2", 1, true);
Qtest(q, new int[]{2, 3});
}
- [Test]
- public virtual void TestSNear10()
+ [Test]
+ public virtual void TestSNear10()
{
SpanQuery q = Snear("xx", "w1", "w2", 0, false);
Qtest(q, new int[]{2});
}
- [Test]
- public virtual void TestSNear11()
+ [Test]
+ public virtual void TestSNear11()
{
SpanQuery q = Snear("w1", "w2", "w3", 1, true);
Qtest(q, new int[]{0, 1});
@@ -223,38 +223,38 @@
/* some SpanNotQueries */
- [Test]
- public virtual void TestSNot1()
+ [Test]
+ public virtual void TestSNot1()
{
SpanQuery q = Snot(Sf("w1", 10), St("QQ"));
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSNot2()
+ [Test]
+ public virtual void TestSNot2()
{
SpanQuery q = Snot(Sf("w1", 10), St("QQ"));
q.SetBoost(1000);
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSNot4()
+ [Test]
+ public virtual void TestSNot4()
{
SpanQuery q = Snot(Sf("w1", 10), St("xx"));
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSNot5()
+ [Test]
+ public virtual void TestSNot5()
{
SpanQuery q = Snot(Sf("w1", 10), St("xx"));
q.SetBoost(1000);
Qtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSNot7()
+ [Test]
+ public virtual void TestSNot7()
{
SpanQuery f = Snear("w1", "w3", 10, true);
f.SetBoost(1000);
@@ -262,8 +262,8 @@
Qtest(q, new int[]{0, 1, 3});
}
- [Test]
- public virtual void TestSNot10()
+ [Test]
+ public virtual void TestSNot10()
{
SpanQuery t = St("xx");
t.SetBoost(10000);
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpanExplanationsOfNonMatches.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/Spans/TestSpanExplanationsOfNonMatches.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpanExplanationsOfNonMatches.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpanExplanationsOfNonMatches.cs Tue Jul 15 14:44:04 2008
@@ -15,6 +15,8 @@
* limitations under the License.
*/
+using NUnit.Framework;
+
using System;
using Query = Lucene.Net.Search.Query;
@@ -25,7 +27,8 @@
/// <summary> subclass of TestSimpleExplanations that verifies non matches.</summary>
- public class TestSpanExplanationsOfNonMatches : TestSpanExplanations
+ [TestFixture]
+ public class TestSpanExplanationsOfNonMatches : TestSpanExplanations
{
/// <summary> Overrides superclass to ignore matches and focus on non-matches
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpans.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/Spans/TestSpans.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpans.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpans.cs Tue Jul 15 14:44:04 2008
@@ -19,28 +19,30 @@
using NUnit.Framework;
-using IndexSearcher = Lucene.Net.Search.IndexSearcher;
-using Query = Lucene.Net.Search.Query;
-using CheckHits = Lucene.Net.Search.CheckHits;
-using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Term = Lucene.Net.Index.Term;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
-using Document = Lucene.Net.Documents.Document;
-using Field = Lucene.Net.Documents.Field;
+using CheckHits = Lucene.Net.Search.CheckHits;
+using IndexSearcher = Lucene.Net.Search.IndexSearcher;
+using Query = Lucene.Net.Search.Query;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search.Spans
{
[TestFixture]
- public class TestSpans
+ public class TestSpans : LuceneTestCase
{
private IndexSearcher searcher;
public const System.String field = "field";
[SetUp]
- public virtual void SetUp()
+ public override void SetUp()
{
+ base.SetUp();
RAMDirectory directory = new RAMDirectory();
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
for (int i = 0; i < docFields.Length; i++)
@@ -89,91 +91,91 @@
}
[Test]
- public virtual void TestSpanNearOrdered01()
+ public virtual void TestSpanNearOrdered01()
{
OrderedSlopTest3(0, new int[]{0});
}
[Test]
- public virtual void TestSpanNearOrdered02()
+ public virtual void TestSpanNearOrdered02()
{
OrderedSlopTest3(1, new int[]{0, 1});
}
[Test]
- public virtual void TestSpanNearOrdered03()
+ public virtual void TestSpanNearOrdered03()
{
OrderedSlopTest3(2, new int[]{0, 1, 2});
}
[Test]
- public virtual void TestSpanNearOrdered04()
+ public virtual void TestSpanNearOrdered04()
{
OrderedSlopTest3(3, new int[]{0, 1, 2, 3});
}
[Test]
- public virtual void TestSpanNearOrdered05()
+ public virtual void TestSpanNearOrdered05()
{
OrderedSlopTest3(4, new int[]{0, 1, 2, 3});
}
[Test]
- public virtual void TestSpanNearOrderedEqual01()
+ public virtual void TestSpanNearOrderedEqual01()
{
OrderedSlopTest3Equal(0, new int[]{});
}
[Test]
- public virtual void TestSpanNearOrderedEqual02()
+ public virtual void TestSpanNearOrderedEqual02()
{
OrderedSlopTest3Equal(1, new int[]{1});
}
[Test]
- public virtual void TestSpanNearOrderedEqual03()
+ public virtual void TestSpanNearOrderedEqual03()
{
OrderedSlopTest3Equal(2, new int[]{1});
}
[Test]
- public virtual void TestSpanNearOrderedEqual04()
+ public virtual void TestSpanNearOrderedEqual04()
{
OrderedSlopTest3Equal(3, new int[]{1, 3});
}
[Test]
- public virtual void TestSpanNearOrderedEqual11()
+ public virtual void TestSpanNearOrderedEqual11()
{
OrderedSlopTest1Equal(0, new int[]{4});
}
[Test]
- public virtual void TestSpanNearOrderedEqual12()
+ public virtual void TestSpanNearOrderedEqual12()
{
OrderedSlopTest1Equal(0, new int[]{4});
}
[Test]
- public virtual void TestSpanNearOrderedEqual13()
+ public virtual void TestSpanNearOrderedEqual13()
{
OrderedSlopTest1Equal(1, new int[]{4, 5, 6});
}
[Test]
- public virtual void TestSpanNearOrderedEqual14()
+ public virtual void TestSpanNearOrderedEqual14()
{
OrderedSlopTest1Equal(2, new int[]{4, 5, 6, 7});
}
[Test]
- public virtual void TestSpanNearOrderedEqual15()
+ public virtual void TestSpanNearOrderedEqual15()
{
OrderedSlopTest1Equal(3, new int[]{4, 5, 6, 7});
}
[Test]
- public virtual void TestSpanNearOrderedOverlap()
+ public virtual void TestSpanNearOrderedOverlap()
{
bool ordered = true;
int slop = 1;
@@ -194,84 +196,84 @@
}
- private Spans OrSpans(System.String[] terms)
- {
- SpanQuery[] sqa = new SpanQuery[terms.Length];
- for (int i = 0; i < terms.Length; i++)
- {
- sqa[i] = MakeSpanTermQuery(terms[i]);
- }
- return (new SpanOrQuery(sqa)).GetSpans(searcher.GetIndexReader());
- }
-
- private void TstNextSpans(Spans spans, int doc, int start, int end)
- {
- Assert.IsTrue(spans.Next(), "next");
- Assert.AreEqual(doc, spans.Doc(), "doc");
- Assert.AreEqual(start, spans.Start(), "start");
- Assert.AreEqual(end, spans.End(), "end");
- }
-
- [Test]
- public virtual void TestSpanOrEmpty()
- {
- Spans spans = OrSpans(new System.String[0]);
- Assert.IsFalse(spans.Next(), "empty next");
- }
-
- [Test]
- public virtual void TestSpanOrSingle()
- {
- Spans spans = OrSpans(new System.String[]{"w5"});
- TstNextSpans(spans, 0, 4, 5);
- Assert.IsFalse(spans.Next(), "final next");
- }
-
- [Test]
- public virtual void TestSpanOrDouble()
- {
- Spans spans = OrSpans(new System.String[]{"w5", "yy"});
- TstNextSpans(spans, 0, 4, 5);
- TstNextSpans(spans, 2, 3, 4);
- TstNextSpans(spans, 3, 4, 5);
- TstNextSpans(spans, 7, 3, 4);
- Assert.IsFalse(spans.Next(), "final next");
- }
-
- [Test]
- public virtual void TestSpanOrDoubleSkip()
- {
- Spans spans = OrSpans(new System.String[]{"w5", "yy"});
- Assert.IsTrue(spans.SkipTo(3), "initial skipTo");
- Assert.AreEqual(3, spans.Doc(), "doc");
- Assert.AreEqual(4, spans.Start(), "start");
- Assert.AreEqual(5, spans.End(), "end");
- TstNextSpans(spans, 7, 3, 4);
- Assert.IsFalse(spans.Next(), "final next");
- }
-
- [Test]
- public virtual void TestSpanOrUnused()
- {
- Spans spans = OrSpans(new System.String[]{"w5", "unusedTerm", "yy"});
- TstNextSpans(spans, 0, 4, 5);
- TstNextSpans(spans, 2, 3, 4);
- TstNextSpans(spans, 3, 4, 5);
- TstNextSpans(spans, 7, 3, 4);
- Assert.IsFalse(spans.Next(), "final next");
- }
-
- [Test]
- public virtual void TestSpanOrTripleSameDoc()
- {
- Spans spans = OrSpans(new System.String[]{"t1", "t2", "t3"});
- TstNextSpans(spans, 11, 0, 1);
- TstNextSpans(spans, 11, 1, 2);
- TstNextSpans(spans, 11, 2, 3);
- TstNextSpans(spans, 11, 3, 4);
- TstNextSpans(spans, 11, 4, 5);
- TstNextSpans(spans, 11, 5, 6);
- Assert.IsFalse(spans.Next(), "final next");
- }
- }
+ private Spans OrSpans(System.String[] terms)
+ {
+ SpanQuery[] sqa = new SpanQuery[terms.Length];
+ for (int i = 0; i < terms.Length; i++)
+ {
+ sqa[i] = MakeSpanTermQuery(terms[i]);
+ }
+ return (new SpanOrQuery(sqa)).GetSpans(searcher.GetIndexReader());
+ }
+
+ private void TstNextSpans(Spans spans, int doc, int start, int end)
+ {
+ Assert.IsTrue(spans.Next(), "next");
+ Assert.AreEqual(doc, spans.Doc(), "doc");
+ Assert.AreEqual(start, spans.Start(), "start");
+ Assert.AreEqual(end, spans.End(), "end");
+ }
+
+ [Test]
+ public virtual void TestSpanOrEmpty()
+ {
+ Spans spans = OrSpans(new System.String[0]);
+ Assert.IsFalse(spans.Next(), "empty next");
+ }
+
+ [Test]
+ public virtual void TestSpanOrSingle()
+ {
+ Spans spans = OrSpans(new System.String[]{"w5"});
+ TstNextSpans(spans, 0, 4, 5);
+ Assert.IsFalse(spans.Next(), "final next");
+ }
+
+ [Test]
+ public virtual void TestSpanOrDouble()
+ {
+ Spans spans = OrSpans(new System.String[]{"w5", "yy"});
+ TstNextSpans(spans, 0, 4, 5);
+ TstNextSpans(spans, 2, 3, 4);
+ TstNextSpans(spans, 3, 4, 5);
+ TstNextSpans(spans, 7, 3, 4);
+ Assert.IsFalse(spans.Next(), "final next");
+ }
+
+ [Test]
+ public virtual void TestSpanOrDoubleSkip()
+ {
+ Spans spans = OrSpans(new System.String[]{"w5", "yy"});
+ Assert.IsTrue(spans.SkipTo(3), "initial skipTo");
+ Assert.AreEqual(3, spans.Doc(), "doc");
+ Assert.AreEqual(4, spans.Start(), "start");
+ Assert.AreEqual(5, spans.End(), "end");
+ TstNextSpans(spans, 7, 3, 4);
+ Assert.IsFalse(spans.Next(), "final next");
+ }
+
+ [Test]
+ public virtual void TestSpanOrUnused()
+ {
+ Spans spans = OrSpans(new System.String[]{"w5", "unusedTerm", "yy"});
+ TstNextSpans(spans, 0, 4, 5);
+ TstNextSpans(spans, 2, 3, 4);
+ TstNextSpans(spans, 3, 4, 5);
+ TstNextSpans(spans, 7, 3, 4);
+ Assert.IsFalse(spans.Next(), "final next");
+ }
+
+ [Test]
+ public virtual void TestSpanOrTripleSameDoc()
+ {
+ Spans spans = OrSpans(new System.String[]{"t1", "t2", "t3"});
+ TstNextSpans(spans, 11, 0, 1);
+ TstNextSpans(spans, 11, 1, 2);
+ TstNextSpans(spans, 11, 2, 3);
+ TstNextSpans(spans, 11, 3, 4);
+ TstNextSpans(spans, 11, 4, 5);
+ TstNextSpans(spans, 11, 5, 6);
+ Assert.IsFalse(spans.Next(), "final next");
+ }
+ }
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpansAdvanced.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/Spans/TestSpansAdvanced.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpansAdvanced.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpansAdvanced.cs Tue Jul 15 14:44:04 2008
@@ -19,15 +19,16 @@
using NUnit.Framework;
-using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Term = Lucene.Net.Index.Term;
-using Lucene.Net.Search;
-using Searchable = Lucene.Net.Search.Searchable;
using Directory = Lucene.Net.Store.Directory;
using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
+using Lucene.Net.Search;
+using Searchable = Lucene.Net.Search.Searchable;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search.Spans
{
@@ -40,22 +41,24 @@
/// <author> Reece Wilton
/// </author>
[TestFixture]
- public class TestSpansAdvanced
+ public class TestSpansAdvanced : LuceneTestCase
{
// location to the index
protected internal Directory mDirectory;
- protected internal IndexSearcher searcher;
+ protected internal IndexSearcher searcher;
- // field names in the index
+ // field names in the index
private const System.String FIELD_ID = "ID";
protected internal const System.String FIELD_TEXT = "TEXT";
/// <summary> Initializes the tests by adding 4 identical documents to the index.</summary>
[SetUp]
- public virtual void SetUp()
+ public override void SetUp()
{
+ base.SetUp();
+ base.SetUp();
// create test index
mDirectory = new RAMDirectory();
@@ -65,14 +68,15 @@
AddDocument(writer, "3", "I think it should work.");
AddDocument(writer, "4", "I think it should work.");
writer.Close();
- searcher = new IndexSearcher(mDirectory);
- }
+ searcher = new IndexSearcher(mDirectory);
+ }
[TearDown]
- public virtual void TearDown()
+ public override void TearDown()
{
- searcher.Close();
- mDirectory.Close();
+ base.TearDown();
+ searcher.Close();
+ mDirectory.Close();
mDirectory = null;
}
@@ -100,7 +104,7 @@
/// </summary>
/// <throws> IOException </throws>
[Test]
- public virtual void TestBooleanQueryWithSpanQueries()
+ public virtual void TestBooleanQueryWithSpanQueries()
{
DoTestBooleanQueryWithSpanQueries(searcher, 0.3884282f);
@@ -117,9 +121,9 @@
BooleanQuery query = new BooleanQuery();
query.Add(spanQuery, BooleanClause.Occur.MUST);
query.Add(spanQuery, BooleanClause.Occur.MUST);
- System.String[] expectedIds = new System.String[]{"1", "2", "3", "4"};
+ System.String[] expectedIds = new System.String[]{"1", "2", "3", "4"};
float[] expectedScores = new float[]{expectedScore, expectedScore, expectedScore, expectedScore};
- AssertHits(s, query, "two span queries", expectedIds, expectedScores);
+ AssertHits(s, query, "two span queries", expectedIds, expectedScores);
}
@@ -138,43 +142,43 @@
/// <throws> IOException </throws>
protected internal virtual void AssertHits(Searcher s, Query query, System.String description, System.String[] expectedIds, float[] expectedScores)
{
- QueryUtils.Check(query, s);
+ QueryUtils.Check(query, s);
- float tolerance = 1e-5f;
+ float tolerance = 1e-5f;
- // Hits hits = searcher.search(query);
- // hits normalizes and throws things off if one score is greater than 1.0
- TopDocs topdocs = s.Search(query, null, 10000);
-
- /// <summary>**
- /// // display the hits
- /// System.out.println(hits.length() + " hits for search: \"" + description + '\"');
- /// for (int i = 0; i < hits.length(); i++) {
- /// System.out.println(" " + FIELD_ID + ':' + hits.doc(i).get(FIELD_ID) + " (score:" + hits.score(i) + ')');
- /// }
- /// ***
- /// </summary>
-
- // did we get the hits we expected
- Assert.AreEqual(expectedIds.Length, topdocs.totalHits);
- for (int i = 0; i < topdocs.totalHits; i++)
- {
- //System.out.println(i + " exp: " + expectedIds[i]);
- //System.out.println(i + " field: " + hits.doc(i).get(FIELD_ID));
+ // Hits hits = searcher.search(query);
+ // hits normalizes and throws things off if one score is greater than 1.0
+ TopDocs topdocs = s.Search(query, null, 10000);
+
+ /// <summary>**
+ /// // display the hits
+ /// System.out.println(hits.length() + " hits for search: \"" + description + '\"');
+ /// for (int i = 0; i < hits.length(); i++) {
+ /// System.out.println(" " + FIELD_ID + ':' + hits.doc(i).get(FIELD_ID) + " (score:" + hits.score(i) + ')');
+ /// }
+ /// ***
+ /// </summary>
+
+ // did we get the hits we expected
+ Assert.AreEqual(expectedIds.Length, topdocs.totalHits);
+ for (int i = 0; i < topdocs.totalHits; i++)
+ {
+ //System.out.println(i + " exp: " + expectedIds[i]);
+ //System.out.println(i + " field: " + hits.doc(i).get(FIELD_ID));
- int id = topdocs.scoreDocs[i].doc;
- float score = topdocs.scoreDocs[i].score;
- Lucene.Net.Documents.Document doc = s.Doc(id);
- Assert.AreEqual(expectedIds[i], doc.Get(FIELD_ID));
- bool scoreEq = System.Math.Abs(expectedScores[i] - score) < tolerance;
- if (!scoreEq)
- {
- System.Console.Out.WriteLine(i + " warning, expected score: " + expectedScores[i] + ", actual " + score);
- System.Console.Out.WriteLine(s.Explain(query, id));
- }
- Assert.AreEqual(expectedScores[i], score, tolerance);
- Assert.AreEqual(s.Explain(query, id).GetValue(), score, tolerance);
- }
- }
+ int id = topdocs.scoreDocs[i].doc;
+ float score = topdocs.scoreDocs[i].score;
+ Lucene.Net.Documents.Document doc = s.Doc(id);
+ Assert.AreEqual(expectedIds[i], doc.Get(FIELD_ID));
+ bool scoreEq = System.Math.Abs(expectedScores[i] - score) < tolerance;
+ if (!scoreEq)
+ {
+ System.Console.Out.WriteLine(i + " warning, expected score: " + expectedScores[i] + ", actual " + score);
+ System.Console.Out.WriteLine(s.Explain(query, id));
+ }
+ Assert.AreEqual(expectedScores[i], score, tolerance);
+ Assert.AreEqual(s.Explain(query, id).GetValue(), score, tolerance);
+ }
+ }
}
}
\ No newline at end of file
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpansAdvanced2.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/Spans/TestSpansAdvanced2.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpansAdvanced2.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/Spans/TestSpansAdvanced2.cs Tue Jul 15 14:44:04 2008
@@ -19,10 +19,10 @@
using NUnit.Framework;
-using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
using IndexReader = Lucene.Net.Index.IndexReader;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Term = Lucene.Net.Index.Term;
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
using Lucene.Net.Search;
using Searchable = Lucene.Net.Search.Searchable;
@@ -36,12 +36,13 @@
/// </summary>
/// <author> Reece Wilton
/// </author>
+ [TestFixture]
public class TestSpansAdvanced2:TestSpansAdvanced
{
internal IndexSearcher searcher2;
/// <summary> Initializes the tests by adding documents to the index.</summary>
[SetUp]
- public virtual void SetUp()
+ public override void SetUp()
{
base.SetUp();
@@ -53,16 +54,16 @@
AddDocument(writer, "D", "Should we, should we, should we.");
writer.Close();
- // re-open the searcher since we added more docs
- searcher2 = new IndexSearcher(mDirectory);
- }
+ // re-open the searcher since we added more docs
+ searcher2 = new IndexSearcher(mDirectory);
+ }
/// <summary> Verifies that the index has the correct number of documents.
///
/// </summary>
/// <throws> Exception </throws>
[Test]
- public virtual void TestVerifyIndex()
+ public virtual void TestVerifyIndex()
{
IndexReader reader = IndexReader.Open(mDirectory);
Assert.AreEqual(8, reader.NumDocs());
@@ -74,7 +75,7 @@
/// </summary>
/// <throws> IOException </throws>
[Test]
- public virtual void TestSingleSpanQuery()
+ public virtual void TestSingleSpanQuery()
{
Query spanQuery = new SpanTermQuery(new Term(FIELD_TEXT, "should"));
@@ -88,7 +89,7 @@
/// </summary>
/// <throws> IOException </throws>
[Test]
- public virtual void TestMultipleDifferentSpanQueries()
+ public virtual void TestMultipleDifferentSpanQueries()
{
Query spanQuery1 = new SpanTermQuery(new Term(FIELD_TEXT, "should"));
@@ -97,10 +98,10 @@
query.Add(spanQuery1, BooleanClause.Occur.MUST);
query.Add(spanQuery2, BooleanClause.Occur.MUST);
System.String[] expectedIds = new System.String[]{"D", "A"};
- // these values were pre LUCENE-413
- // float[] expectedScores = new float[]{0.93163157f, 0.20698164f};
- float[] expectedScores = new float[]{1.0191123f, 0.93163157f};
- AssertHits(searcher2, query, "multiple different span queries", expectedIds, expectedScores);
+ // these values were pre LUCENE-413
+ // float[] expectedScores = new float[]{0.93163157f, 0.20698164f};
+ float[] expectedScores = new float[]{1.0191123f, 0.93163157f};
+ AssertHits(searcher2, query, "multiple different span queries", expectedIds, expectedScores);
}
/// <summary> Tests two span queries.
@@ -108,7 +109,7 @@
/// </summary>
/// <throws> IOException </throws>
[Test]
- public override void TestBooleanQueryWithSpanQueries()
+ public override void TestBooleanQueryWithSpanQueries()
{
DoTestBooleanQueryWithSpanQueries(searcher2, 0.73500174f);
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestBoolean2.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestBoolean2.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestBoolean2.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestBoolean2.cs Tue Jul 15 14:44:04 2008
@@ -19,14 +19,15 @@
using NUnit.Framework;
-using RAMDirectory = Lucene.Net.Store.RAMDirectory;
-using IndexWriter = Lucene.Net.Index.IndexWriter;
-using Term = Lucene.Net.Index.Term;
-using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
-using QueryParser = Lucene.Net.QueryParsers.QueryParser;
+using IndexWriter = Lucene.Net.Index.IndexWriter;
+using Term = Lucene.Net.Index.Term;
using ParseException = Lucene.Net.QueryParsers.ParseException;
+using QueryParser = Lucene.Net.QueryParsers.QueryParser;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search
{
@@ -36,7 +37,7 @@
/// This also tests the scoring order of BooleanQuery.
/// </summary>
[TestFixture]
- public class TestBoolean2
+ public class TestBoolean2 : LuceneTestCase
{
[Serializable]
private class AnonymousClassDefaultSimilarity:DefaultSimilarity
@@ -68,8 +69,9 @@
public const System.String field = "field";
[SetUp]
- public virtual void SetUp()
+ public override void SetUp()
{
+ base.SetUp();
RAMDirectory directory = new RAMDirectory();
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true);
for (int i = 0; i < docFields.Length; i++)
@@ -86,8 +88,8 @@
public virtual Query MakeQuery(System.String queryText)
{
- Query q = (new Lucene.Net.QueryParsers.QueryParser(field, new WhitespaceAnalyzer())).Parse(queryText);
- return q;
+ Query q = (new Lucene.Net.QueryParsers.QueryParser(field, new WhitespaceAnalyzer())).Parse(queryText);
+ return q;
}
public virtual void QueriesTest(System.String queryText, int[] expDocNrs)
@@ -97,11 +99,11 @@
try
{
Query query1 = MakeQuery(queryText);
- BooleanQuery.SetUseScorer14(true);
+ BooleanQuery.SetAllowDocsOutOfOrder(true);
Hits hits1 = searcher.Search(query1);
Query query2 = MakeQuery(queryText); // there should be no need to parse again...
- BooleanQuery.SetUseScorer14(false);
+ BooleanQuery.SetAllowDocsOutOfOrder(false);
Hits hits2 = searcher.Search(query2);
CheckHits.CheckHitsQuery(query2, hits1, hits2, expDocNrs);
@@ -109,12 +111,12 @@
finally
{
// even when a test fails.
- BooleanQuery.SetUseScorer14(false);
+ BooleanQuery.SetAllowDocsOutOfOrder(false);
}
}
[Test]
- public virtual void TestQueries01()
+ public virtual void TestQueries01()
{
System.String queryText = "+w3 +xx";
int[] expDocNrs = new int[]{2, 3};
@@ -122,7 +124,7 @@
}
[Test]
- public virtual void TestQueries02()
+ public virtual void TestQueries02()
{
System.String queryText = "+w3 xx";
int[] expDocNrs = new int[]{2, 3, 1, 0};
@@ -130,7 +132,7 @@
}
[Test]
- public virtual void TestQueries03()
+ public virtual void TestQueries03()
{
System.String queryText = "w3 xx";
int[] expDocNrs = new int[]{2, 3, 1, 0};
@@ -138,7 +140,7 @@
}
[Test]
- public virtual void TestQueries04()
+ public virtual void TestQueries04()
{
System.String queryText = "w3 -xx";
int[] expDocNrs = new int[]{1, 0};
@@ -146,7 +148,7 @@
}
[Test]
- public virtual void TestQueries05()
+ public virtual void TestQueries05()
{
System.String queryText = "+w3 -xx";
int[] expDocNrs = new int[]{1, 0};
@@ -154,7 +156,7 @@
}
[Test]
- public virtual void TestQueries06()
+ public virtual void TestQueries06()
{
System.String queryText = "+w3 -xx -w5";
int[] expDocNrs = new int[]{1};
@@ -162,7 +164,7 @@
}
[Test]
- public virtual void TestQueries07()
+ public virtual void TestQueries07()
{
System.String queryText = "-w3 -xx -w5";
int[] expDocNrs = new int[]{};
@@ -170,7 +172,7 @@
}
[Test]
- public virtual void TestQueries08()
+ public virtual void TestQueries08()
{
System.String queryText = "+w3 xx -w5";
int[] expDocNrs = new int[]{2, 3, 1};
@@ -178,7 +180,7 @@
}
[Test]
- public virtual void TestQueries09()
+ public virtual void TestQueries09()
{
System.String queryText = "+w3 +xx +w2 zz";
int[] expDocNrs = new int[]{2, 3};
@@ -186,7 +188,7 @@
}
[Test]
- public virtual void TestQueries10()
+ public virtual void TestQueries10()
{
System.String queryText = "+w3 +xx +w2 zz";
int[] expDocNrs = new int[]{2, 3};
@@ -195,7 +197,7 @@
}
[Test]
- public virtual void TestRandomQueries()
+ public virtual void TestRandomQueries()
{
System.Random rnd = new System.Random((System.Int32) 0);
@@ -216,15 +218,15 @@
// match up.
Sort sort = Sort.INDEXORDER;
- BooleanQuery.SetUseScorer14(false);
+ BooleanQuery.SetAllowDocsOutOfOrder(false);
- QueryUtils.Check(q1, searcher);
+ QueryUtils.Check(q1, searcher);
- Hits hits1 = searcher.Search(q1, sort);
+ Hits hits1 = searcher.Search(q1, sort);
if (hits1.Length() > 0)
hits1.Id(hits1.Length() - 1);
- BooleanQuery.SetUseScorer14(true);
+ BooleanQuery.SetAllowDocsOutOfOrder(true);
Hits hits2 = searcher.Search(q1, sort);
if (hits2.Length() > 0)
hits2.Id(hits1.Length() - 1);
@@ -235,7 +237,7 @@
finally
{
// even when a test fails.
- BooleanQuery.SetUseScorer14(false);
+ BooleanQuery.SetAllowDocsOutOfOrder(false);
}
// System.out.println("Total hits:"+tot);
@@ -280,7 +282,7 @@
}
if (cb != null)
cb.PostCreate(current);
- ((System.Collections.ArrayList)current.Clauses()).TrimToSize();
+ ((System.Collections.ArrayList)current.Clauses()).TrimToSize();
return current;
}
}
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanMinShouldMatch.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestBooleanMinShouldMatch.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanMinShouldMatch.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanMinShouldMatch.cs Tue Jul 15 14:44:04 2008
@@ -19,7 +19,6 @@
using NUnit.Framework;
-using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
using IndexReader = Lucene.Net.Index.IndexReader;
@@ -27,6 +26,8 @@
using Term = Lucene.Net.Index.Term;
using Directory = Lucene.Net.Store.Directory;
using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search
{
@@ -34,7 +35,7 @@
/// <summary>Test that BooleanQuery.setMinimumNumberShouldMatch works.</summary>
[TestFixture]
- public class TestBooleanMinShouldMatch
+ public class TestBooleanMinShouldMatch : LuceneTestCase
{
private class AnonymousClassCallback : TestBoolean2.Callback
{
@@ -48,10 +49,10 @@
this.enclosingInstance = enclosingInstance;
}
- private System.Random rnd;
+ private System.Random rnd;
private TestBooleanMinShouldMatch enclosingInstance;
- public TestBooleanMinShouldMatch Enclosing_Instance
+ public TestBooleanMinShouldMatch Enclosing_Instance
{
get
{
@@ -78,10 +79,13 @@
public IndexSearcher s;
[SetUp]
- public virtual void SetUp()
+ public override void SetUp()
{
+ base.SetUp();
+
+
System.String[] data = new System.String[]{"A 1 2 3 4 5 6", "Z 4 5 6", null, "B 2 4 5 6", "Y 3 5 6", null, "C 3 6", "X 4 5 6"};
index = new RAMDirectory();
@@ -90,12 +94,12 @@
for (int i = 0; i < data.Length; i++)
{
Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
- doc.Add(new Field("id", System.Convert.ToString(i), Field.Store.YES, Field.Index.UN_TOKENIZED)); //Field.Keyword("id",String.valueOf(i)));
- doc.Add(new Field("all", "all", Field.Store.YES, Field.Index.UN_TOKENIZED)); //Field.Keyword("all","all"));
- if (null != data[i])
+ doc.Add(new Field("id", System.Convert.ToString(i), Field.Store.YES, Field.Index.UN_TOKENIZED)); //Field.Keyword("id",String.valueOf(i)));
+ doc.Add(new Field("all", "all", Field.Store.YES, Field.Index.UN_TOKENIZED)); //Field.Keyword("all","all"));
+ if (null != data[i])
{
- doc.Add(new Field("data", data[i], Field.Store.YES, Field.Index.TOKENIZED)); //Field.Text("data",data[i]));
- }
+ doc.Add(new Field("data", data[i], Field.Store.YES, Field.Index.TOKENIZED)); //Field.Text("data",data[i]));
+ }
writer.AddDocument(doc);
}
@@ -113,14 +117,14 @@
Hits h = s.Search(q);
if (expected != h.Length())
{
- PrintHits("TestBooleanMinShouldMatch", h); // PrintHits(NUnit.Framework.TestCase.GetName(), h); // {{Aroush-1.9}} 'GetName()' gives us the name of the test in JUnit, how is it done in NUnit?
- }
+ PrintHits("TestBooleanMinShouldMatch", h); // PrintHits(TestCase.GetName(), h); // {{Aroush-1.9}} 'GetName()' gives us the name of the test in JUnit, how is it done in NUnit?
+ }
Assert.AreEqual(expected, h.Length(), "result count");
- QueryUtils.Check(q, s);
- }
+ QueryUtils.Check(q, s);
+ }
[Test]
- public virtual void TestAllOptional()
+ public virtual void TestAllOptional()
{
BooleanQuery q = new BooleanQuery();
@@ -133,15 +137,15 @@
}
[Test]
- public virtual void TestOneReqAndSomeOptional()
+ public virtual void TestOneReqAndSomeOptional()
{
/* one required, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.SHOULD); //false, false);
q.SetMinimumNumberShouldMatch(2); // 2 of 3 optional
@@ -149,16 +153,16 @@
}
[Test]
- public virtual void TestSomeReqAndSomeOptional()
+ public virtual void TestSomeReqAndSomeOptional()
{
/* two required, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.SHOULD); //false, false);
q.SetMinimumNumberShouldMatch(2); // 2 of 3 optional
@@ -166,15 +170,15 @@
}
[Test]
- public virtual void TestOneProhibAndSomeOptional()
+ public virtual void TestOneProhibAndSomeOptional()
{
/* one prohibited, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
q.SetMinimumNumberShouldMatch(2); // 2 of 3 optional
@@ -182,16 +186,16 @@
}
[Test]
- public virtual void TestSomeProhibAndSomeOptional()
+ public virtual void TestSomeProhibAndSomeOptional()
{
/* two prohibited, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "C")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "C")), BooleanClause.Occur.MUST_NOT); //false, true );
q.SetMinimumNumberShouldMatch(2); // 2 of 3 optional
@@ -199,17 +203,17 @@
}
[Test]
- public virtual void TestOneReqOneProhibAndSomeOptional()
+ public virtual void TestOneReqOneProhibAndSomeOptional()
{
/* one required, one prohibited, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); // true, false);
- q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); // true, false);
+ q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
q.SetMinimumNumberShouldMatch(3); // 3 of 4 optional
@@ -217,18 +221,18 @@
}
[Test]
- public virtual void TestSomeReqOneProhibAndSomeOptional()
+ public virtual void TestSomeReqOneProhibAndSomeOptional()
{
/* two required, one prohibited, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
q.SetMinimumNumberShouldMatch(3); // 3 of 4 optional
@@ -236,18 +240,18 @@
}
[Test]
- public virtual void TestOneReqSomeProhibAndSomeOptional()
+ public virtual void TestOneReqSomeProhibAndSomeOptional()
{
/* one required, two prohibited, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "C")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "C")), BooleanClause.Occur.MUST_NOT); //false, true );
q.SetMinimumNumberShouldMatch(3); // 3 of 4 optional
@@ -255,19 +259,19 @@
}
[Test]
- public virtual void TestSomeReqSomeProhibAndSomeOptional()
+ public virtual void TestSomeReqSomeProhibAndSomeOptional()
{
/* two required, two prohibited, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "C")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "C")), BooleanClause.Occur.MUST_NOT); //false, true );
q.SetMinimumNumberShouldMatch(3); // 3 of 4 optional
@@ -275,19 +279,19 @@
}
[Test]
- public virtual void TestMinHigherThenNumOptional()
+ public virtual void TestMinHigherThenNumOptional()
{
/* two required, two prohibited, some optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "C")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "5")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "4")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST_NOT); //false, true );
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "1")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "C")), BooleanClause.Occur.MUST_NOT); //false, true );
q.SetMinimumNumberShouldMatch(90); // 90 of 4 optional ?!?!?!
@@ -295,15 +299,15 @@
}
[Test]
- public virtual void TestMinEqualToNumOptional()
+ public virtual void TestMinEqualToNumOptional()
{
/* two required, two optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "6")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.SHOULD); //false, false);
q.SetMinimumNumberShouldMatch(2); // 2 of 2 optional
@@ -311,14 +315,14 @@
}
[Test]
- public virtual void TestOneOptionalEqualToMin()
+ public virtual void TestOneOptionalEqualToMin()
{
/* two required, one optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.SHOULD); //false, false);
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "3")), BooleanClause.Occur.SHOULD); //false, false);
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.MUST); //true, false);
q.SetMinimumNumberShouldMatch(1); // 1 of 1 optional
@@ -326,13 +330,13 @@
}
[Test]
- public virtual void TestNoOptionalButMin()
+ public virtual void TestNoOptionalButMin()
{
/* two required, no optional */
BooleanQuery q = new BooleanQuery();
- q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
- q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("all", "all")), BooleanClause.Occur.MUST); //true, false);
+ q.Add(new TermQuery(new Term("data", "2")), BooleanClause.Occur.MUST); //true, false);
q.SetMinimumNumberShouldMatch(1); // 1 of 0 optional
@@ -370,14 +374,14 @@
TopDocs top1 = s.Search(q1, null, 100);
TopDocs top2 = s.Search(q2, null, 100);
- QueryUtils.Check(q1, s);
- QueryUtils.Check(q2, s);
+ QueryUtils.Check(q1, s);
+ QueryUtils.Check(q2, s);
- // The constrained query
+ // The constrained query
// should be a superset to the unconstrained query.
if (top2.totalHits > top1.totalHits)
{
- TestCase.Fail("Constrained results not a subset:\n" + CheckHits.TopdocsString(top1, 0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
+ Assert.Fail("Constrained results not a subset:\n" + CheckHits.TopdocsString(top1, 0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
}
for (int hit = 0; hit < top2.totalHits; hit++)
@@ -395,7 +399,7 @@
// check if scores match
if (System.Math.Abs(otherScore - score) > 1.0e-6f)
{
- TestCase.Fail("Doc " + id + " scores don't match\n" + CheckHits.TopdocsString(top1, 0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
+ Assert.Fail("Doc " + id + " scores don't match\n" + CheckHits.TopdocsString(top1, 0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
}
}
}
@@ -403,7 +407,7 @@
// check if subset
if (!found)
{
- TestCase.Fail("Doc " + id + " not found\n" + CheckHits.TopdocsString(top1, 0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
+ Assert.Fail("Doc " + id + " not found\n" + CheckHits.TopdocsString(top1, 0, 0) + CheckHits.TopdocsString(top2, 0, 0) + "for query:" + q2.ToString());
}
}
}
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanOr.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestBooleanOr.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanOr.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanOr.cs Tue Jul 15 14:44:04 2008
@@ -19,12 +19,13 @@
using NUnit.Framework;
-using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Term = Lucene.Net.Index.Term;
using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search
{
@@ -35,7 +36,7 @@
/// <author> appler@gmail.com
/// </author>
[TestFixture]
- public class TestBooleanOr
+ public class TestBooleanOr : LuceneTestCase
{
private static System.String FIELD_T = "T";
@@ -50,12 +51,12 @@
private int Search(Query q)
{
- QueryUtils.Check(q, searcher);
- return searcher.Search(q).Length();
- }
+ QueryUtils.Check(q, searcher);
+ return searcher.Search(q).Length();
+ }
[Test]
- public virtual void TestElements()
+ public virtual void TestElements()
{
Assert.AreEqual(1, Search(t1));
Assert.AreEqual(1, Search(t2));
@@ -69,7 +70,7 @@
/// </summary>
/// <throws> IOException </throws>
[Test]
- public virtual void TestFlat()
+ public virtual void TestFlat()
{
BooleanQuery q = new BooleanQuery();
q.Add(new BooleanClause(t1, BooleanClause.Occur.SHOULD));
@@ -85,7 +86,7 @@
/// </summary>
/// <throws> IOException </throws>
[Test]
- public virtual void TestParenthesisMust()
+ public virtual void TestParenthesisMust()
{
BooleanQuery q3 = new BooleanQuery();
q3.Add(new BooleanClause(t1, BooleanClause.Occur.SHOULD));
@@ -105,7 +106,7 @@
/// </summary>
/// <throws> IOException </throws>
[Test]
- public virtual void TestParenthesisMust2()
+ public virtual void TestParenthesisMust2()
{
BooleanQuery q3 = new BooleanQuery();
q3.Add(new BooleanClause(t1, BooleanClause.Occur.SHOULD));
@@ -125,7 +126,7 @@
/// </summary>
/// <throws> IOException </throws>
[Test]
- public virtual void TestParenthesisShould()
+ public virtual void TestParenthesisShould()
{
BooleanQuery q3 = new BooleanQuery();
q3.Add(new BooleanClause(t1, BooleanClause.Occur.SHOULD));
@@ -140,9 +141,10 @@
}
[SetUp]
- public virtual void SetUp()
+ public override void SetUp()
{
- //base.SetUp();
+ //base.SetUp();
+ base.SetUp();
//
RAMDirectory rd = new RAMDirectory();
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanPrefixQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestBooleanPrefixQuery.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanPrefixQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanPrefixQuery.cs Tue Jul 15 14:44:04 2008
@@ -19,24 +19,26 @@
using NUnit.Framework;
-using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+//using TestRunner = junit.textui.TestRunner;
+using Document = Lucene.Net.Documents.Document;
+using Field = Lucene.Net.Documents.Field;
+using IndexReader = Lucene.Net.Index.IndexReader;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Term = Lucene.Net.Index.Term;
-using IndexReader = Lucene.Net.Index.IndexReader;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
-using Document = Lucene.Net.Documents.Document;
-using Field = Lucene.Net.Documents.Field;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search
{
- /// <author> schnee
- /// </author>
- /// <version> $Id: TestBooleanPrefixQuery.java 472959 2006-11-09 16:21:50Z yonik $
- ///
+ /// <summary> </summary>
+ /// <version> $Id: TestBooleanPrefixQuery.java 583534 2007-10-10 16:46:35Z mikemccand $
+ ///
/// </version>
+
[TestFixture]
- public class TestBooleanPrefixQuery
+ public class TestBooleanPrefixQuery : LuceneTestCase
{
[STAThread]
@@ -46,14 +48,14 @@
}
/* // {{Aroush}} Do we need this method?
- public static NUnit.Framework.TestCase Suite()
+ public static TestCase Suite()
{
return new NUnit.Core.TestSuite(typeof(TestBooleanPrefixQuery));
}
- */
+ */
[Test]
- public virtual void TestMethod()
+ public virtual void TestMethod()
{
RAMDirectory directory = new RAMDirectory();
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestBooleanQuery.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanQuery.cs Tue Jul 15 14:44:04 2008
@@ -20,15 +20,16 @@
using NUnit.Framework;
using Term = Lucene.Net.Index.Term;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search
{
[TestFixture]
- public class TestBooleanQuery
+ public class TestBooleanQuery : LuceneTestCase
{
[Test]
- public virtual void TestEquality()
+ public virtual void TestEquality()
{
BooleanQuery bq1 = new BooleanQuery();
bq1.Add(new TermQuery(new Term("field", "value1")), BooleanClause.Occur.SHOULD);
@@ -50,14 +51,14 @@
}
[Test]
- public virtual void TestException()
+ public virtual void TestException()
{
try
{
BooleanQuery.SetMaxClauseCount(0);
Assert.Fail();
}
- catch (System.ArgumentException e)
+ catch (System.ArgumentException)
{
// okay
}
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanScorer.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestBooleanScorer.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanScorer.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestBooleanScorer.cs Tue Jul 15 14:44:04 2008
@@ -19,28 +19,32 @@
using NUnit.Framework;
-using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
using Document = Lucene.Net.Documents.Document;
using Field = Lucene.Net.Documents.Field;
using IndexWriter = Lucene.Net.Index.IndexWriter;
using Term = Lucene.Net.Index.Term;
using RAMDirectory = Lucene.Net.Store.RAMDirectory;
+using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search
{
- /// <author> Christoph Goller
- /// </author>
- /// <version> $rcs = ' $Id: TestBooleanScorer.java 472959 2006-11-09 16:21:50Z yonik $ ' ;
- /// </version>
+ /// <summary> </summary>
+ /// <version> $rcs = ' $Id: TestBooleanScorer.java 583534 2007-10-10 16:46:35Z mikemccand $ ' ;
+ /// </version>
[TestFixture]
- public class TestBooleanScorer
+ public class TestBooleanScorer : LuceneTestCase
{
+ //public TestBooleanScorer(System.String name) : base(name)
+ //{
+ //}
+
private const System.String FIELD = "category";
[Test]
- public virtual void TestMethod()
+ public virtual void TestMethod()
{
RAMDirectory directory = new RAMDirectory();
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestCachingWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestCachingWrapperFilter.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestCachingWrapperFilter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestCachingWrapperFilter.cs Tue Jul 15 14:44:04 2008
@@ -19,19 +19,20 @@
using NUnit.Framework;
-using Directory = Lucene.Net.Store.Directory;
-using RAMDirectory = Lucene.Net.Store.RAMDirectory;
using IndexReader = Lucene.Net.Index.IndexReader;
using IndexWriter = Lucene.Net.Index.IndexWriter;
+using Directory = Lucene.Net.Store.Directory;
+using RAMDirectory = Lucene.Net.Store.RAMDirectory;
using StandardAnalyzer = Lucene.Net.Analysis.Standard.StandardAnalyzer;
+using LuceneTestCase = Lucene.Net.Util.LuceneTestCase;
namespace Lucene.Net.Search
{
[TestFixture]
- public class TestCachingWrapperFilter
+ public class TestCachingWrapperFilter : LuceneTestCase
{
[Test]
- public virtual void TestCachingWorks()
+ public virtual void TestCachingWorks()
{
Directory dir = new RAMDirectory();
IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true);
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestComplexExplanations.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestComplexExplanations.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestComplexExplanations.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestComplexExplanations.cs Tue Jul 15 14:44:04 2008
@@ -21,15 +21,6 @@
using Occur = Lucene.Net.Search.BooleanClause.Occur;
using Lucene.Net.Search.Spans;
-using RAMDirectory = Lucene.Net.Store.RAMDirectory;
-using IndexWriter = Lucene.Net.Index.IndexWriter;
-using IndexReader = Lucene.Net.Index.IndexReader;
-using Term = Lucene.Net.Index.Term;
-using WhitespaceAnalyzer = Lucene.Net.Analysis.WhitespaceAnalyzer;
-using Document = Lucene.Net.Documents.Document;
-using Field = Lucene.Net.Documents.Field;
-using QueryParser = Lucene.Net.QueryParsers.QueryParser;
-using ParseException = Lucene.Net.QueryParsers.ParseException;
namespace Lucene.Net.Search
{
@@ -38,29 +29,12 @@
/// on the assumption that if the explanations work out right for them,
/// they should work for anything.
/// </summary>
- [TestFixture]
- public class TestComplexExplanations : TestExplanations
+ [TestFixture]
+ public class TestComplexExplanations : TestExplanations
{
[Serializable]
private class AnonymousClassDefaultSimilarity : DefaultSimilarity
{
- public AnonymousClassDefaultSimilarity(TestComplexExplanations enclosingInstance)
- {
- InitBlock(enclosingInstance);
- }
- private void InitBlock(TestComplexExplanations enclosingInstance)
- {
- this.enclosingInstance = enclosingInstance;
- }
- private TestComplexExplanations enclosingInstance;
- public TestComplexExplanations Enclosing_Instance
- {
- get
- {
- return enclosingInstance;
- }
-
- }
public override float QueryNorm(float sumOfSquaredWeights)
{
return 1.0f; // / (float) Math.sqrt(1.0f + sumOfSquaredWeights);
@@ -71,16 +45,21 @@
/// nice with boosts of 0.0
/// </summary>
[SetUp]
- public override void SetUp()
+ public override void SetUp()
+ {
+ base.SetUp();
+ searcher.SetSimilarity(new AnonymousClassDefaultSimilarity());
+ }
+
+ // must be static for weight serialization tests
+ private static DefaultSimilarity CreateQnorm1Similarity()
{
- if (searcher == null)
- base.SetUp();
- searcher.SetSimilarity(new AnonymousClassDefaultSimilarity(this));
+ return new AnonymousClassDefaultSimilarity();
}
- [Test]
- public virtual void Test1()
+ [Test]
+ public virtual void Test1()
{
BooleanQuery q = new BooleanQuery();
@@ -122,7 +101,7 @@
Qtest(q, new int[]{0, 1, 2});
}
- [Test]
+ [Test]
public virtual void Test2()
{
@@ -175,36 +154,36 @@
// complex, and they expose weakness in dealing with queries that match
// with scores of 0 wrapped in other queries
- [Test]
- public virtual void TestT3()
+ [Test]
+ public virtual void TestT3()
{
Bqtest("w1^0.0", new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestMA3()
+ [Test]
+ public virtual void TestMA3()
{
Query q = new MatchAllDocsQuery();
q.SetBoost(0);
Bqtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestFQ5()
+ [Test]
+ public virtual void TestFQ5()
{
Bqtest(new FilteredQuery(qp.Parse("xx^0"), new ItemizedFilter(new int[]{1, 3})), new int[]{3});
}
- [Test]
- public virtual void TestCSQ4()
+ [Test]
+ public virtual void TestCSQ4()
{
Query q = new ConstantScoreQuery(new ItemizedFilter(new int[]{3}));
q.SetBoost(0);
Bqtest(q, new int[]{3});
}
- [Test]
- public virtual void TestDMQ10()
+ [Test]
+ public virtual void TestDMQ10()
{
DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.5f);
q.Add(qp.Parse("yy w5^100"));
@@ -213,8 +192,8 @@
Bqtest(q, new int[]{0, 2, 3});
}
- [Test]
- public virtual void TestMPQ7()
+ [Test]
+ public virtual void TestMPQ7()
{
MultiPhraseQuery q = new MultiPhraseQuery();
q.Add(Ta(new System.String[]{"w1"}));
@@ -224,89 +203,89 @@
Bqtest(q, new int[]{0, 1, 2});
}
- [Test]
- public virtual void TestBQ12()
+ [Test]
+ public virtual void TestBQ12()
{
// NOTE: using qtest not bqtest
Qtest("w1 w2^0.0", new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestBQ13()
+ [Test]
+ public virtual void TestBQ13()
{
// NOTE: using qtest not bqtest
Qtest("w1 -w5^0.0", new int[]{1, 2, 3});
}
- [Test]
- public virtual void TestBQ18()
+ [Test]
+ public virtual void TestBQ18()
{
// NOTE: using qtest not bqtest
Qtest("+w1^0.0 w2", new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestBQ21()
+ [Test]
+ public virtual void TestBQ21()
{
Bqtest("(+w1 w2)^0.0", new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestBQ22()
+ [Test]
+ public virtual void TestBQ22()
{
Bqtest("(+w1^0.0 w2)^0.0", new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestST3()
+ [Test]
+ public virtual void TestST3()
{
SpanQuery q = St("w1");
q.SetBoost(0);
Bqtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestST6()
+ [Test]
+ public virtual void TestST6()
{
SpanQuery q = St("xx");
q.SetBoost(0);
Qtest(q, new int[]{2, 3});
}
- [Test]
- public virtual void TestSF3()
+ [Test]
+ public virtual void TestSF3()
{
SpanQuery q = Sf(("w1"), 1);
q.SetBoost(0);
Bqtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSF7()
+ [Test]
+ public virtual void TestSF7()
{
SpanQuery q = Sf(("xx"), 3);
q.SetBoost(0);
Bqtest(q, new int[]{2, 3});
}
- [Test]
- public virtual void TestSNot3()
+ [Test]
+ public virtual void TestSNot3()
{
SpanQuery q = Snot(Sf("w1", 10), St("QQ"));
q.SetBoost(0);
Bqtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSNot6()
+ [Test]
+ public virtual void TestSNot6()
{
SpanQuery q = Snot(Sf("w1", 10), St("xx"));
q.SetBoost(0);
Bqtest(q, new int[]{0, 1, 2, 3});
}
- [Test]
- public virtual void TestSNot8()
+ [Test]
+ public virtual void TestSNot8()
{
// NOTE: using qtest not bqtest
SpanQuery f = Snear("w1", "w3", 10, true);
@@ -315,8 +294,8 @@
Qtest(q, new int[]{0, 1, 3});
}
- [Test]
- public virtual void TestSNot9()
+ [Test]
+ public virtual void TestSNot9()
{
// NOTE: using qtest not bqtest
SpanQuery t = St("xx");
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestComplexExplanationsOfNonMatches.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestComplexExplanationsOfNonMatches.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestComplexExplanationsOfNonMatches.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestComplexExplanationsOfNonMatches.cs Tue Jul 15 14:44:04 2008
@@ -33,6 +33,7 @@
{
/// <summary> subclass of TestSimpleExplanations that verifies non matches.</summary>
+ [TestFixture]
public class TestComplexExplanationsOfNonMatches : TestComplexExplanations
{
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestConstantScoreRangeQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestConstantScoreRangeQuery.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestConstantScoreRangeQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestConstantScoreRangeQuery.cs Tue Jul 15 14:44:04 2008
@@ -76,15 +76,15 @@
Assert.AreEqual(e, a, m, SCORE_COMP_THRESH);
}
- static public void AssertEquals(System.String m, int e, int a)
- {
- Assert.AreEqual(e, a, m);
- }
+ static public void AssertEquals(System.String m, int e, int a)
+ {
+ Assert.AreEqual(e, a, m);
+ }
- [SetUp]
- public virtual void SetUp()
+ [SetUp]
+ public override void SetUp()
{
-
+ base.SetUp();
System.String[] data = new System.String[]{"A 1 2 3 4 5 6", "Z 4 5 6", null, "B 2 4 5 6", "Y 3 5 6", null, "C 3 6", "X 4 5 6"};
small = new RAMDirectory();
@@ -93,12 +93,12 @@
for (int i = 0; i < data.Length; i++)
{
Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
- doc.Add(new Field("id", System.Convert.ToString(i), Field.Store.YES, Field.Index.UN_TOKENIZED)); //Field.Keyword("id",String.valueOf(i)));
- doc.Add(new Field("all", "all", Field.Store.YES, Field.Index.UN_TOKENIZED)); //Field.Keyword("all","all"));
+ doc.Add(new Field("id", System.Convert.ToString(i), Field.Store.YES, Field.Index.UN_TOKENIZED)); //Field.Keyword("id",String.valueOf(i)));
+ doc.Add(new Field("all", "all", Field.Store.YES, Field.Index.UN_TOKENIZED)); //Field.Keyword("all","all"));
if (null != data[i])
{
- doc.Add(new Field("data", data[i], Field.Store.YES, Field.Index.TOKENIZED)); //Field.Text("data",data[i]));
- }
+ doc.Add(new Field("data", data[i], Field.Store.YES, Field.Index.TOKENIZED)); //Field.Text("data",data[i]));
+ }
writer.AddDocument(doc);
}
@@ -114,16 +114,16 @@
return new ConstantScoreRangeQuery(f, l, h, il, ih);
}
- [Test]
- public virtual void TestBasics()
+ [Test]
+ public virtual void TestBasics()
{
QueryUtils.Check(Csrq("data", "1", "6", T, T));
QueryUtils.Check(Csrq("data", "A", "Z", T, T));
QueryUtils.CheckUnequal(Csrq("data", "1", "6", T, T), Csrq("data", "A", "Z", T, T));
}
- [Test]
- public virtual void TestEqualScores()
+ [Test]
+ public virtual void TestEqualScores()
{
// NOTE: uses index build in *this* SetUp
@@ -144,8 +144,8 @@
}
}
- [Test]
- public virtual void TestBoost()
+ [Test]
+ public virtual void TestBoost()
{
// NOTE: uses index build in *this* SetUp
@@ -189,7 +189,7 @@
}
[Test]
- public virtual void TestBooleanOrderUnAffected()
+ public virtual void TestBooleanOrderUnAffected()
{
// NOTE: uses index build in *this* SetUp
@@ -208,8 +208,8 @@
// ConstantScoreRangeQuery and make sure hte order is the same
BooleanQuery q = new BooleanQuery();
- q.Add(rq, BooleanClause.Occur.MUST); //T, F);
- q.Add(Csrq("data", "1", "6", T, T), BooleanClause.Occur.MUST); //T, F);
+ q.Add(rq, BooleanClause.Occur.MUST); //T, F);
+ q.Add(Csrq("data", "1", "6", T, T), BooleanClause.Occur.MUST); //T, F);
Hits actual = search.Search(q);
@@ -223,8 +223,8 @@
- [Test]
- public virtual void TestRangeQueryId()
+ [Test]
+ public virtual void TestRangeQueryId()
{
// NOTE: uses index build in *super* SetUp
@@ -306,8 +306,8 @@
Assert.AreEqual(1, result.Length(), "med,med,T,T");
}
- [Test]
- public virtual void TestRangeQueryRand()
+ [Test]
+ public virtual void TestRangeQueryRand()
{
// NOTE: uses index build in *super* SetUp
Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestCustomSearcherSort.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestCustomSearcherSort.cs?rev=677059&r1=677058&r2=677059&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestCustomSearcherSort.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestCustomSearcherSort.cs Tue Jul 15 14:44:04 2008
@@ -40,100 +40,95 @@
[Serializable]
[TestFixture]
- public class TestCustomSearcherSort
+ public class TestCustomSearcherSort
{
- private Directory Index
- {
- // create an index for testing
+ private Directory Index
+ {
+ // create an index for testing
- get
- {
- RAMDirectory indexStore = new RAMDirectory();
- IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(), true);
- RandomGen random = new RandomGen(this);
- for (int i = 0; i < INDEX_SIZE; ++i)
- {
- // don't decrease; if to low the problem doesn't show up
- Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
- if ((i % 5) != 0)
- {
- // some documents must not have an entry in the first sort field
- doc.Add(new Field("publicationDate_", random.GetLuceneDate(), Field.Store.YES, Field.Index.UN_TOKENIZED));
- }
- if ((i % 7) == 0)
- {
- // some documents to match the query (see below)
- doc.Add(new Field("content", "test", Field.Store.YES, Field.Index.TOKENIZED));
- }
- // every document has a defined 'mandant' field
- doc.Add(new Field("mandant", System.Convert.ToString(i % 3), Field.Store.YES, Field.Index.UN_TOKENIZED));
- writer.AddDocument(doc);
- }
- writer.Optimize();
- writer.Close();
- return indexStore;
- }
+ get
+ {
+ RAMDirectory indexStore = new RAMDirectory();
+ IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(), true);
+ RandomGen random = new RandomGen(this);
+ for (int i = 0; i < INDEX_SIZE; ++i)
+ {
+ // don't decrease; if to low the problem doesn't show up
+ Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
+ if ((i % 5) != 0)
+ {
+ // some documents must not have an entry in the first sort field
+ doc.Add(new Field("publicationDate_", random.GetLuceneDate(), Field.Store.YES, Field.Index.UN_TOKENIZED));
+ }
+ if ((i % 7) == 0)
+ {
+ // some documents to match the query (see below)
+ doc.Add(new Field("content", "test", Field.Store.YES, Field.Index.TOKENIZED));
+ }
+ // every document has a defined 'mandant' field
+ doc.Add(new Field("mandant", System.Convert.ToString(i % 3), Field.Store.YES, Field.Index.UN_TOKENIZED));
+ writer.AddDocument(doc);
+ }
+ writer.Optimize();
+ writer.Close();
+ return indexStore;
+ }
- }
+ }
- private Directory index = null;
+ private Directory index = null;
private Query query = null;
// reduced from 20000 to 2000 to speed up test...
private const int INDEX_SIZE = 2000;
- [STAThread]
+ [STAThread]
public static void Main(System.String[] argv)
{
// TestRunner.run(Suite()); // {{Aroush}} how is this done in NUnit?
}
- public static NUnit.Framework.TestCase Suite()
+ /// <summary> Create index and query for test cases. </summary>
+ [SetUp]
+ public virtual void SetUp()
{
- return null; // return new NUnit.Core.TestSuite(typeof(TestCustomSearcherSort)); {{Aroush}} how is this done in NUnit?
+ index = Index;
+ query = new TermQuery(new Term("content", "test"));
}
- /// <summary> Create index and query for test cases. </summary>
- [SetUp]
- public virtual void SetUp()
- {
- index = Index;
- query = new TermQuery(new Term("content", "test"));
- }
-
- /// <summary> Run the test using two CustomSearcher instances. </summary>
- [Test]
- public virtual void TestFieldSortCustomSearcher()
- {
- // log("Run testFieldSortCustomSearcher");
- // define the sort criteria
- Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
- Searcher searcher = new CustomSearcher(this, index, 2);
- // search and check hits
- MatchHits(searcher, custSort);
- }
- /// <summary> Run the test using one CustomSearcher wrapped by a MultiSearcher. </summary>
- [Test]
- public virtual void TestFieldSortSingleSearcher()
- {
- // log("Run testFieldSortSingleSearcher");
- // define the sort criteria
- Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
- Searcher searcher = new MultiSearcher(new Lucene.Net.Search.Searchable[]{new CustomSearcher(this, index, 2)});
- // search and check hits
- MatchHits(searcher, custSort);
- }
- /// <summary> Run the test using two CustomSearcher instances. </summary>
- [Test]
- public virtual void TestFieldSortMultiCustomSearcher()
- {
- // log("Run testFieldSortMultiCustomSearcher");
- // define the sort criteria
- Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
- Searcher searcher = new MultiSearcher(new Lucene.Net.Search.Searchable[]{new CustomSearcher(this, index, 0), new CustomSearcher(this, index, 2)});
- // search and check hits
- MatchHits(searcher, custSort);
- }
+ /// <summary> Run the test using two CustomSearcher instances. </summary>
+ [Test]
+ public virtual void TestFieldSortCustomSearcher()
+ {
+ // log("Run testFieldSortCustomSearcher");
+ // define the sort criteria
+ Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
+ Searcher searcher = new CustomSearcher(this, index, 2);
+ // search and check hits
+ MatchHits(searcher, custSort);
+ }
+ /// <summary> Run the test using one CustomSearcher wrapped by a MultiSearcher. </summary>
+ [Test]
+ public virtual void TestFieldSortSingleSearcher()
+ {
+ // log("Run testFieldSortSingleSearcher");
+ // define the sort criteria
+ Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
+ Searcher searcher = new MultiSearcher(new Lucene.Net.Search.Searchable[]{new CustomSearcher(this, index, 2)});
+ // search and check hits
+ MatchHits(searcher, custSort);
+ }
+ /// <summary> Run the test using two CustomSearcher instances. </summary>
+ [Test]
+ public virtual void TestFieldSortMultiCustomSearcher()
+ {
+ // log("Run testFieldSortMultiCustomSearcher");
+ // define the sort criteria
+ Sort custSort = new Sort(new SortField[]{new SortField("publicationDate_"), SortField.FIELD_SCORE});
+ Searcher searcher = new MultiSearcher(new Lucene.Net.Search.Searchable[]{new CustomSearcher(this, index, 0), new CustomSearcher(this, index, 2)});
+ // search and check hits
+ MatchHits(searcher, custSort);
+ }
// make sure the documents returned by the search match the expected list
@@ -289,7 +284,7 @@
}
}
- private class RandomGen
+ private class RandomGen
{
public RandomGen(TestCustomSearcherSort enclosingInstance)
{
@@ -305,27 +300,27 @@
private TestCustomSearcherSort enclosingInstance;
public TestCustomSearcherSort Enclosing_Instance
{
- // Just to generate some different Lucene Date strings
+ // Just to generate some different Lucene Date strings
- get
+ get
{
return enclosingInstance;
}
}
- private System.Random random = new System.Random((System.Int32) 0); // to generate some arbitrary contents
+ private System.Random random = new System.Random((System.Int32) 0); // to generate some arbitrary contents
// private System.Globalization.Calendar base_Renamed;
- private System.DateTime base_Renamed;
+ private System.DateTime base_Renamed;
// Just to generate some different Lucene Date strings
public System.String GetLuceneDate()
{
- long v1 = base_Renamed.Millisecond;
- long v2 = random.Next();
- long v3 = System.Int32.MinValue;
- return DateTools.TimeToString(v1 + v2 - v3, DateTools.Resolution.DAY);
- }
+ long v1 = base_Renamed.Millisecond;
+ long v2 = random.Next();
+ long v3 = System.Int32.MinValue;
+ return DateTools.TimeToString(v1 + v2 - v3, DateTools.Resolution.DAY);
+ }
}
}
}
\ No newline at end of file