本文整理汇总了C#中Lucene.Net.Search.PhraseQuery.GetSlop方法的典型用法代码示例。如果您正苦于以下问题:C# PhraseQuery.GetSlop方法的具体用法?C# PhraseQuery.GetSlop怎么用?C# PhraseQuery.GetSlop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Search.PhraseQuery
的用法示例。
在下文中一共展示了PhraseQuery.GetSlop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitPhraseQuery
public override Query VisitPhraseQuery(PhraseQuery phraseq)
{
_dump.Append("PhraseQ(");
var terms = phraseq.GetTerms();
PhraseQuery newQuery = null;
int index = 0;
int count = terms.Length;
while (index < count)
{
var visitedTerm = VisitTerm(terms[index]);
if (newQuery != null)
{
newQuery.Add(visitedTerm);
}
else if (visitedTerm != terms[index])
{
newQuery = new PhraseQuery();
for (int i = 0; i < index; i++)
newQuery.Add(terms[i]);
newQuery.Add(visitedTerm);
}
index++;
if (index < count)
_dump.Append(", ");
}
_dump.Append(", Slop:").Append(phraseq.GetSlop()).Append(BoostToString(phraseq)).Append(")");
if (newQuery != null)
return newQuery;
return phraseq;
}
示例2: VisitPhraseQuery
public override Query VisitPhraseQuery(PhraseQuery phraseq)
{
var terms = phraseq.GetTerms();
var field = terms[0].Field();
_text.Append(field);
_text.Append(":\"");
var positions = new int[terms.Length];
for (int i = 0; i < positions.Length; i++)
positions[i] = i;
var pieces = new string[terms.Length];
for (int i = 0; i < terms.Length; i++)
{
int pos = ((System.Int32)positions[i]);
System.String s = pieces[pos];
if (s == null)
s = (terms[i]).Text();
else
s += "|" + (terms[i]).Text();
pieces[pos] = s;
}
for (int i = 0; i < pieces.Length; i++)
{
if (i > 0)
_text.Append(' ');
System.String s = pieces[i];
if (s == null)
_text.Append('?');
else
_text.Append(s);
}
_text.Append("\"");
var slop = phraseq.GetSlop();
if (slop != 0)
{
_text.Append("~");
_text.Append(slop);
}
_text.Append(BoostToString(phraseq.GetBoost()));
return base.VisitPhraseQuery(phraseq);
}
示例3: CheckOverlap
/*
* Check if PhraseQuery A and B have overlapped part.
*
* ex1) A="a b", B="b c" => overlap; expandQueries={"a b c"}
* ex2) A="b c", B="a b" => overlap; expandQueries={"a b c"}
* ex3) A="a b", B="c d" => no overlap; expandQueries={}
*/
private void CheckOverlap(Dictionary<Query,Query> expandQueries, PhraseQuery a, PhraseQuery b)
{
if (a.GetSlop() != b.GetSlop()) return;
Term[] ats = a.GetTerms();
Term[] bts = b.GetTerms();
if (fieldMatch && !ats[0].Field().Equals(bts[0].Field())) return;
CheckOverlap(expandQueries, ats, bts, a.GetSlop(), a.GetBoost());
CheckOverlap(expandQueries, bts, ats, b.GetSlop(), b.GetBoost());
}