本文整理汇总了C#中Lucene.Net.Search.Similarity类的典型用法代码示例。如果您正苦于以下问题:C# Similarity类的具体用法?C# Similarity怎么用?C# Similarity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Similarity类属于Lucene.Net.Search命名空间,在下文中一共展示了Similarity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TermWeight
public TermWeight(TermQuery enclosingInstance, Searcher searcher)
{
InitBlock(enclosingInstance);
this.similarity = Enclosing_Instance.GetSimilarity(searcher);
idfExp = similarity.IdfExplain(Enclosing_Instance.term, searcher);
idf = idfExp.Idf;
}
示例2: phraseFreq
private float freq; //prhase frequency in current doc as computed by phraseFreq().
internal PhraseScorer(Weight weight, TermPositions[] tps, int[] offsets, Similarity similarity, byte[] norms):base(similarity)
{
this.norms = norms;
this.weight = weight;
this.value_Renamed = weight.Value;
// convert tps to a list of phrase positions.
// note: phrase-position differs from term-position in that its position
// reflects the phrase offset: pp.pos = tp.pos - offset.
// this allows to easily identify a matching (exact) phrase
// when all PhrasePositions have exactly the same position.
for (int i = 0; i < tps.Length; i++)
{
PhrasePositions pp = new PhrasePositions(tps[i], offsets[i]);
if (last != null)
{
// add next to end of list
last.next = pp;
}
else
{
first = pp;
}
last = pp;
}
pq = new PhraseQueue(tps.Length); // construct empty pq
first.doc = - 1;
}
示例3: MatchAllScorer
internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w, byte[] norms):base(similarity)
{
InitBlock(enclosingInstance);
this.termDocs = reader.TermDocs(null);
score = w.Value;
this.norms = norms;
}
示例4: MatchAllScorer
internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity) : base(similarity)
{
InitBlock(enclosingInstance);
this.reader = reader;
count = - 1;
maxDoc = reader.MaxDoc();
}
示例5: DocSetIteratorWeight
internal DocSetIteratorWeight(Query query, Similarity similarity, DocIdSetIterator iter)
{
_query = query;
_similarity = similarity;
_iter = iter;
_queryNorm = 1.0f;
_queryWeight = _query.Boost;
}
示例6: TermWeight
public TermWeight(TermQuery outerInstance, IndexSearcher searcher, TermContext termStates)
{
this.OuterInstance = outerInstance;
Debug.Assert(termStates != null, "TermContext must not be null");
this.TermStates = termStates;
this.Similarity = searcher.Similarity;
this.Stats = Similarity.ComputeWeight(outerInstance.Boost, searcher.CollectionStatistics(outerInstance.Term_Renamed.Field()), searcher.TermStatistics(outerInstance.Term_Renamed, termStates));
}
示例7: MatchAllScorer
internal MatchAllScorer(MatchAllDocsQuery enclosingInstance, IndexReader reader, Similarity similarity, Weight w):base(similarity)
{
InitBlock(enclosingInstance);
this.reader = reader;
id = - 1;
maxId = reader.MaxDoc() - 1;
score = w.GetValue();
}
示例8: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new System.Collections.Hashtable();
query.ExtractTerms(terms);
idfExp = similarity.idfExplain(new System.Collections.ArrayList(terms.Values), searcher);
idf = idfExp.GetIdf();
}
示例9: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new Support.Set<Lucene.Net.Index.Term>();
query.ExtractTerms(terms);
idfExp = similarity.idfExplain(terms.ToArray(), searcher);
idf = idfExp.GetIdf();
}
示例10: ConjunctionScorer
public ConjunctionScorer(Similarity similarity, Scorer[] scorers)
: base(similarity)
{
this.scorers = scorers;
coord = similarity.Coord(scorers.Length, scorers.Length);
for (int i = 0; i < scorers.Length; i++)
{
if (scorers[i].NextDoc() == NO_MORE_DOCS)
{
// If even one of the sub-scorers does not have any documents, this
// scorer should not attempt to do any more work.
lastDoc = NO_MORE_DOCS;
return ;
}
}
// Sort the array the first time...
// We don't need to sort the array in any future calls because we know
// it will already start off sorted (all scorers on same doc).
// note that this comparator is not consistent with equals!
System.Array.Sort(scorers, new AnonymousClassComparator(this));
// NOTE: doNext() must be called before the re-sorting of the array later on.
// The reason is this: assume there are 5 scorers, whose first docs are 1,
// 2, 3, 5, 5 respectively. Sorting (above) leaves the array as is. Calling
// doNext() here advances all the first scorers to 5 (or a larger doc ID
// they all agree on).
// However, if we re-sort before doNext() is called, the order will be 5, 3,
// 2, 1, 5 and then doNext() will stop immediately, since the first scorer's
// docs equals the last one. So the invariant that after calling doNext()
// all scorers are on the same doc ID is broken.
if (DoNext() == NO_MORE_DOCS)
{
// The scorers did not agree on any document.
lastDoc = NO_MORE_DOCS;
return ;
}
// If first-time skip distance is any predictor of
// scorer sparseness, then we should always try to skip first on
// those scorers.
// Keep last scorer in it's last place (it will be the first
// to be skipped on), but reverse all of the others so that
// they will be skipped on in order of original high skip.
int end = scorers.Length - 1;
int max = end >> 1;
for (int i = 0; i < max; i++)
{
Scorer tmp = scorers[i];
int idx = end - i - 1;
scorers[i] = scorers[idx];
scorers[idx] = tmp;
}
}
示例11: BooleanScorer2
/// <summary>Create a BooleanScorer2.</summary>
/// <param name="similarity">The similarity to be used.
/// </param>
/// <param name="minNrShouldMatch">The minimum number of optional added scorers
/// that should match during the search.
/// In case no required scorers are added,
/// at least one of the optional scorers will have to
/// match during the search.
/// </param>
public BooleanScorer2(Similarity similarity, int minNrShouldMatch)
: base(similarity)
{
if (minNrShouldMatch < 0)
{
throw new System.ArgumentException("Minimum number of optional scorers should not be negative");
}
coordinator = new Coordinator(this);
this.minNrShouldMatch = minNrShouldMatch;
}
示例12: TermScorer
/// <summary> Construct a <code>TermScorer</code>.
///
/// </summary>
/// <param name="weight">The weight of the <code>Term</code> in the query.
/// </param>
/// <param name="td">An iterator over the documents matching the <code>Term</code>.
/// </param>
/// <param name="similarity">The <code>Similarity</code> implementation to be used for score
/// computations.
/// </param>
/// <param name="norms">The field norms of the document fields for the <code>Term</code>.
/// </param>
public /*internal*/ TermScorer(Weight weight, TermDocs td, Similarity similarity, byte[] norms):base(similarity)
{
this.weight = weight;
this.termDocs = td;
this.norms = norms;
this.weightValue = weight.GetValue();
for (int i = 0; i < SCORE_CACHE_SIZE; i++)
scoreCache[i] = GetSimilarity().Tf(i) * weightValue;
}
示例13: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.query = query;
terms = new System.Collections.Hashtable();
query.ExtractTerms(terms);
System.Collections.ArrayList tmp = new System.Collections.ArrayList(terms.Values);
idf = this.query.GetSimilarity(searcher).Idf(tmp, searcher);
}
示例14: FastMatchAllScorer
public FastMatchAllScorer(int maxdoc, int[] delDocs, Similarity similarity, float score)
: base(similarity)
{
doc = -1;
deletedDocs = delDocs;
deletedIndex = 0;
moreDeletions = deletedDocs != null && deletedDocs.Length > 0;
delLen = deletedDocs != null ? deletedDocs.Length : 0;
this.score = score;
maxDoc = maxdoc;
}
示例15: SpanWeight
public SpanWeight(SpanQuery query, Searcher searcher)
{
this.similarity = query.GetSimilarity(searcher);
this.internalQuery = query;
terms = Lucene.Net.Support.Compatibility.SetFactory.CreateHashSet<Term>();
query.ExtractTerms(terms);
idfExp = similarity.IdfExplain(terms, searcher);
idf = idfExp.Idf;
}