本文整理汇总了C#中FieldTermStack类的典型用法代码示例。如果您正苦于以下问题:C# FieldTermStack类的具体用法?C# FieldTermStack怎么用?C# FieldTermStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FieldTermStack类属于命名空间,在下文中一共展示了FieldTermStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FieldPhraseList
/// <summary>
/// a constructor.
/// </summary>
/// <param name="fieldTermStack">FieldTermStack object</param>
/// <param name="fieldQuery">FieldQuery object</param>
/// <param name="phraseLimit">maximum size of phraseList</param>
public FieldPhraseList(FieldTermStack fieldTermStack, FieldQuery fieldQuery, int phraseLimit)
{
String field = fieldTermStack.FieldName;
LinkedList<TermInfo> phraseCandidate = new LinkedList<TermInfo>();
QueryPhraseMap currMap = null;
QueryPhraseMap nextMap = null;
while (!fieldTermStack.IsEmpty() && (phraseList.Count < phraseLimit) )
{
phraseCandidate.Clear();
TermInfo ti = fieldTermStack.Pop();
currMap = fieldQuery.GetFieldTermMap(field, ti.Text);
// if not found, discard top TermInfo from stack, then try next element
if (currMap == null) continue;
// if found, search the longest phrase
phraseCandidate.AddLast(ti);
while (true)
{
ti = fieldTermStack.Pop();
nextMap = null;
if (ti != null)
nextMap = currMap.GetTermMap(ti.Text);
if (ti == null || nextMap == null)
{
if (ti != null)
fieldTermStack.Push(ti);
if (currMap.IsValidTermOrPhrase(new List<TermInfo>(phraseCandidate)))
{
AddIfNoOverlap(new WeightedPhraseInfo(phraseCandidate, currMap.Boost, currMap.TermOrPhraseNumber));
}
else
{
while (phraseCandidate.Count > 1)
{
TermInfo last = phraseCandidate.Last.Value;
phraseCandidate.RemoveLast();
fieldTermStack.Push(last);
currMap = fieldQuery.SearchPhrase(field, new List<TermInfo>(phraseCandidate));
if (currMap != null)
{
AddIfNoOverlap(new WeightedPhraseInfo(phraseCandidate, currMap.Boost, currMap.TermOrPhraseNumber));
break;
}
}
}
break;
}
else
{
phraseCandidate.AddLast(ti);
currMap = nextMap;
}
}
}
}
示例2: TestFieldTermStackIndex1w2wSearch1term
public void TestFieldTermStackIndex1w2wSearch1term()
{
MakeIndex1w2w();
FieldQuery fq = new FieldQuery(Tq("pc"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
Assert.AreEqual(1, stack.termList.Count);
Assert.AreEqual("pc(3,5,1)", stack.Pop().ToString());
}
示例3: Ffl
private FieldFragList Ffl(String queryValue, String indexValue)
{
Make1d1fIndex(indexValue);
Query query = paW.Parse(queryValue);
FieldQuery fq = new FieldQuery(query, true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
FieldPhraseList fpl = new FieldPhraseList(stack, fq);
return new SimpleFragListBuilder().CreateFieldFragList(fpl, 20);
}
示例4: TestFieldTermStackIndex1w2wSearch1phrase
public void TestFieldTermStackIndex1w2wSearch1phrase()
{
MakeIndex1w2w();
FieldQuery fq = new FieldQuery(PqF("personal", "computer"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
Assert.AreEqual(2, stack.termList.Count);
Assert.AreEqual("personal(3,5,1)", stack.Pop().ToString());
Assert.AreEqual("computer(3,5,2)", stack.Pop().ToString());
}
示例5: Test2TermsIndex
public void Test2TermsIndex()
{
Make1d1fIndex("a a");
FieldQuery fq = new FieldQuery(Tq("a"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
FieldPhraseList fpl = new FieldPhraseList(stack, fq);
Assert.AreEqual(2, fpl.phraseList.Count);
Assert.AreEqual("a(1.0)((0,1))", fpl.phraseList.First.Value.ToString());
Assert.AreEqual("a(1.0)((2,3))", fpl.phraseList.First.Next.Value.ToString());
}
示例6: Test1Phrase
public void Test1Phrase()
{
MakeIndex();
FieldQuery fq = new FieldQuery(PqF("c", "d"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
Assert.AreEqual(3, stack.termList.Count);
Assert.AreEqual("c(10,11,5)", stack.Pop().ToString());
Assert.AreEqual("c(18,19,9)", stack.Pop().ToString());
Assert.AreEqual("d(20,21,10)", stack.Pop().ToString());
}
示例7: Test1Term
public void Test1Term()
{
MakeIndex();
FieldQuery fq = new FieldQuery(Tq("a"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
Assert.AreEqual(6, stack.termList.Count);
Assert.AreEqual("a(0,1,0)", stack.Pop().ToString());
Assert.AreEqual("a(2,3,1)", stack.Pop().ToString());
Assert.AreEqual("a(4,5,2)", stack.Pop().ToString());
Assert.AreEqual("a(12,13,6)", stack.Pop().ToString());
Assert.AreEqual("a(28,29,14)", stack.Pop().ToString());
Assert.AreEqual("a(32,33,16)", stack.Pop().ToString());
}
示例8: TestFieldTermStackIndex1wSearch2terms
public void TestFieldTermStackIndex1wSearch2terms()
{
MakeIndex1w();
BooleanQuery bq = new BooleanQuery();
bq.Add(Tq("Mac"), Occur.SHOULD);
bq.Add(Tq("MacBook"), Occur.SHOULD);
FieldQuery fq = new FieldQuery(bq, true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
Assert.AreEqual(2, stack.termList.Count);
Dictionary<String, String> expectedSet = new Dictionary<String, String>();
expectedSet.Add("Mac(11,20,3)","");
expectedSet.Add("MacBook(11,20,3)","");
Assert.IsTrue(expectedSet.ContainsKey(stack.Pop().ToString()));
Assert.IsTrue(expectedSet.ContainsKey(stack.Pop().ToString()));
}
示例9: Test1PhraseIndex
public void Test1PhraseIndex()
{
Make1d1fIndex("a b");
FieldQuery fq = new FieldQuery(PqF("a", "b"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
FieldPhraseList fpl = new FieldPhraseList(stack, fq);
Assert.AreEqual(1, fpl.phraseList.Count);
Assert.AreEqual("ab(1.0)((0,3))", fpl.phraseList.First.Value.ToString());
fq = new FieldQuery(Tq("b"), true, true);
stack = new FieldTermStack(reader, 0, F, fq);
fpl = new FieldPhraseList(stack, fq);
Assert.AreEqual(1, fpl.phraseList.Count);
Assert.AreEqual("b(1.0)((2,3))", fpl.phraseList.First.Value.ToString());
}
示例10: Test2Terms
public void Test2Terms()
{
MakeIndex();
BooleanQuery query = new BooleanQuery();
query.Add(Tq("b"), Occur.SHOULD);
query.Add(Tq("c"), Occur.SHOULD);
FieldQuery fq = new FieldQuery(query, true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
Assert.AreEqual(8, stack.termList.Count);
Assert.AreEqual("b(6,7,3)", stack.Pop().ToString());
Assert.AreEqual("b(8,9,4)", stack.Pop().ToString());
Assert.AreEqual("c(10,11,5)", stack.Pop().ToString());
Assert.AreEqual("b(14,15,7)", stack.Pop().ToString());
Assert.AreEqual("b(16,17,8)", stack.Pop().ToString());
Assert.AreEqual("c(18,19,9)", stack.Pop().ToString());
Assert.AreEqual("b(26,27,13)", stack.Pop().ToString());
Assert.AreEqual("b(30,31,15)", stack.Pop().ToString());
}
示例11: Test1PhraseLongMVB
public void Test1PhraseLongMVB()
{
MakeIndexLongMVB();
FieldQuery fq = new FieldQuery(PqF("sp", "pe", "ee", "ed"), true, true); // "speed" -(2gram)-> "sp","pe","ee","ed"
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
FieldPhraseList fpl = new FieldPhraseList(stack, fq);
Assert.AreEqual(1, fpl.phraseList.Count);
Assert.AreEqual("sppeeeed(1.0)((88,93))", fpl.phraseList.First.Value.ToString());
}
示例12: Test1PhraseShortMV
public void Test1PhraseShortMV()
{
MakeIndexShortMV();
FieldQuery fq = new FieldQuery(Tq("d"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
FieldPhraseList fpl = new FieldPhraseList(stack, fq);
Assert.AreEqual(1, fpl.phraseList.Count);
Assert.AreEqual("d(1.0)((6,7))", fpl.phraseList.First.Value.ToString());
}
示例13: Test1PhraseLongMV
public void Test1PhraseLongMV()
{
MakeIndexLongMV();
FieldQuery fq = new FieldQuery(PqF("search", "engines"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
FieldPhraseList fpl = new FieldPhraseList(stack, fq);
Assert.AreEqual(2, fpl.phraseList.Count);
Assert.AreEqual("searchengines(1.0)((102,116))", fpl.phraseList.First.Value.ToString());
Assert.AreEqual("searchengines(1.0)((157,171))", fpl.phraseList.First.Next.Value.ToString());
}
示例14: Test3TermsPhrase
public void Test3TermsPhrase()
{
Make1d1fIndex("d a b a b c d");
FieldQuery fq = new FieldQuery(PqF("a", "b", "c"), true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
FieldPhraseList fpl = new FieldPhraseList(stack, fq);
Assert.AreEqual(1, fpl.phraseList.Count);
Assert.AreEqual("abc(1.0)((6,11))", fpl.phraseList.First.Value.ToString());
}
示例15: TestSearchLongestPhrase
public void TestSearchLongestPhrase()
{
Make1d1fIndex("d a b d c a b c");
BooleanQuery query = new BooleanQuery();
query.Add(PqF("a", "b"), Lucene.Net.Search.BooleanClause.Occur.SHOULD);
query.Add(PqF("a", "b", "c"), Lucene.Net.Search.BooleanClause.Occur.SHOULD);
FieldQuery fq = new FieldQuery(query, true, true);
FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
FieldPhraseList fpl = new FieldPhraseList(stack, fq);
Assert.AreEqual(2, fpl.phraseList.Count);
Assert.AreEqual("ab(1.0)((2,5))", fpl.phraseList.First.Value.ToString());
Assert.AreEqual("abc(1.0)((10,15))", fpl.phraseList.First.Next.Value.ToString());
}