本文整理汇总了C#中Lucene.Net.Index.Term.Text方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Index.Term.Text方法的具体用法?C# Lucene.Net.Index.Term.Text怎么用?C# Lucene.Net.Index.Term.Text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Index.Term
的用法示例。
在下文中一共展示了Lucene.Net.Index.Term.Text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WildcardQuery
public WildcardQuery(Term term)
: base(term)
{
//will be removed in 3.0
this.term = term;
this.termContainsWildcard = (term.Text().IndexOf('*') != - 1) || (term.Text().IndexOf('?') != - 1);
}
示例2: RegexTermEnum
public RegexTermEnum(IndexReader reader, Term term)
: base()
{
field = term.Field();
System.String text = term.Text();
pattern = new Pattern(text);
// Find the first regex character position, to find the
// maximum prefix to use for term enumeration
int index = 0;
while (index < text.Length)
{
char c = text[index];
if (!System.Char.IsLetterOrDigit(c))
break;
index++;
}
pre = text.Substring(0, (index) - (0));
SetEnum(reader.Terms(new Term(term.Field(), pre)));
}
示例3: TermCompare
public /*protected internal*/ override bool TermCompare(Term term)
{
if ((System.Object) term.Field() == (System.Object) prefix.Field() && term.Text().StartsWith(prefix.Text()))
{
return true;
}
endEnum = true;
return false;
}
示例4: TermCompare
protected internal override bool TermCompare(Term term)
{
if ((System.Object) field == (System.Object) term.Field())
{
System.String searchText = term.Text();
if (searchText.StartsWith(pre))
{
return pattern.Match(searchText).Success;
}
}
endEnum = true;
return false;
}
示例5: DocFreq
public override int DocFreq(Term term)
{
int df;
try
{
df = ((System.Int32) dfMap[term]);
}
catch (System.NullReferenceException)
{
throw new System.ArgumentException("df for term " + term.Text() + " not available");
}
return df;
}
示例6: TermCompare
protected internal override bool TermCompare(Term term)
{
if (field == term.Field())
{
System.String searchText = term.Text();
if (searchText.StartsWith(pre))
{
return WildcardEquals(text, 0, searchText, preLen);
}
}
endEnum = true;
return false;
}
示例7: WildcardTermEnum
/// <summary> Creates a new <code>WildcardTermEnum</code>. Passing in a
/// {@link Lucene.Net.index.Term Term} that does not contain a
/// <code>WILDCARD_CHAR</code> will cause an exception to be thrown.
/// <p>
/// After calling the constructor the enumeration is already pointing to the first
/// valid term if such a term exists.
/// </summary>
public WildcardTermEnum(IndexReader reader, Term term):base()
{
searchTerm = term;
field = searchTerm.Field();
text = searchTerm.Text();
int sidx = text.IndexOf((System.Char) WILDCARD_STRING);
int cidx = text.IndexOf((System.Char) WILDCARD_CHAR);
int idx = sidx;
if (idx == - 1)
{
idx = cidx;
}
else if (cidx >= 0)
{
idx = System.Math.Min(idx, cidx);
}
pre = searchTerm.Text().Substring(0, (idx) - (0));
preLen = pre.Length;
text = text.Substring(preLen);
SetEnum(reader.Terms(new Term(searchTerm.Field(), pre)));
}
示例8: FuzzyQuery
/// <summary> Create a new FuzzyQuery that will match terms with a similarity
/// of at least <code>minimumSimilarity</code> to <code>term</code>.
/// If a <code>prefixLength</code> > 0 is specified, a common prefix
/// of that length is also required.
///
/// </summary>
/// <param name="term">the term to search for
/// </param>
/// <param name="minimumSimilarity">a value between 0 and 1 to set the required similarity
/// between the query term and the matching terms. For example, for a
/// <code>minimumSimilarity</code> of <code>0.5</code> a term of the same length
/// as the query term is considered similar to the query term if the edit distance
/// between both terms is less than <code>length(term)*0.5</code>
/// </param>
/// <param name="prefixLength">length of common (non-fuzzy) prefix
/// </param>
/// <throws> IllegalArgumentException if minimumSimilarity is >= 1 or < 0 </throws>
/// <summary> or if prefixLength < 0
/// </summary>
public FuzzyQuery(Term term, float minimumSimilarity, int prefixLength):base(term)
{ // will be removed in 3.0
this.term = term;
if (minimumSimilarity >= 1.0f)
throw new System.ArgumentException("minimumSimilarity >= 1");
else if (minimumSimilarity < 0.0f)
throw new System.ArgumentException("minimumSimilarity < 0");
if (prefixLength < 0)
throw new System.ArgumentException("prefixLength < 0");
if (term.Text().Length > 1.0f / (1.0f - minimumSimilarity))
{
this.termLongEnough = true;
}
this.minimumSimilarity = minimumSimilarity;
this.prefixLength = prefixLength;
rewriteMethod = SCORING_BOOLEAN_QUERY_REWRITE;
}
示例9: TermCompare
/// <summary> The termCompare method in FuzzyTermEnum uses Levenshtein distance to
/// calculate the distance between the given term and the comparing term.
/// </summary>
/*protected internal*/
public override bool TermCompare(Term term)
{
if ((System.Object) field == (System.Object) term.Field() && term.Text().StartsWith(prefix))
{
System.String target = term.Text().Substring(prefix.Length);
this.similarity = Similarity(target);
return (similarity > minimumSimilarity);
}
endEnum = true;
return false;
}
示例10: FuzzyTermEnum
/// <summary> Constructor for enumeration of all terms from specified <code>reader</code> which share a prefix of
/// length <code>prefixLength</code> with <code>term</code> and which have a fuzzy similarity >
/// <code>minSimilarity</code>.
/// <p>
/// After calling the constructor the enumeration is already pointing to the first
/// valid term if such a term exists.
///
/// </summary>
/// <param name="reader">Delivers terms.
/// </param>
/// <param name="term">Pattern term.
/// </param>
/// <param name="minSimilarity">Minimum required similarity for terms from the reader. Default value is 0.5f.
/// </param>
/// <param name="prefixLength">Length of required common prefix. Default value is 0.
/// </param>
/// <throws> IOException </throws>
public FuzzyTermEnum(IndexReader reader, Term term, float minSimilarity, int prefixLength)
: base()
{
if (minSimilarity >= 1.0f)
throw new System.ArgumentException("minimumSimilarity cannot be greater than or equal to 1");
else if (minSimilarity < 0.0f)
throw new System.ArgumentException("minimumSimilarity cannot be less than 0");
if (prefixLength < 0)
throw new System.ArgumentException("prefixLength cannot be less than 0");
this.minimumSimilarity = minSimilarity;
this.scale_factor = 1.0f / (1.0f - minimumSimilarity);
this.searchTerm = term;
this.field = searchTerm.Field();
//The prefix could be longer than the word.
//It's kind of silly though. It means we must match the entire word.
int fullSearchTermLength = searchTerm.Text().Length;
int realPrefixLength = prefixLength > fullSearchTermLength?fullSearchTermLength:prefixLength;
this.text = searchTerm.Text().Substring(realPrefixLength);
this.prefix = searchTerm.Text().Substring(0, (realPrefixLength) - (0));
InitializeMaxDistances();
this.d = InitDistanceArray();
SetEnum(reader.Terms(new Term(searchTerm.Field(), prefix)));
}
示例11: DumbRegexpQuery
internal DumbRegexpQuery(Term term, int flags)
: base(term.Field)
{
RegExp re = new RegExp(term.Text(), flags);
Automaton = re.ToAutomaton();
}
示例12: TermCompare
public /*protected internal*/ override bool TermCompare(Term term)
{
if (collator == null)
{
// Use Unicode code point ordering
bool checkLower = false;
if (!includeLower)
// make adjustments to set to exclusive
checkLower = true;
if (term != null && (System.Object) term.Field() == (System.Object) field)
{
// interned comparison
if (!checkLower || null == lowerTermText || String.CompareOrdinal(term.Text(), lowerTermText) > 0)
{
checkLower = false;
if (upperTermText != null)
{
int compare = String.CompareOrdinal(upperTermText, term.Text());
/*
* if beyond the upper term, or is exclusive and this is equal to
* the upper term, break out
*/
if ((compare < 0) || (!includeUpper && compare == 0))
{
endEnum = true;
return false;
}
}
return true;
}
}
else
{
// break
endEnum = true;
return false;
}
return false;
}
else
{
if (term != null && (System.Object) term.Field() == (System.Object) field)
{
// interned comparison
if ((lowerTermText == null || (includeLower?collator.Compare(term.Text().ToString(), lowerTermText.ToString()) >= 0:collator.Compare(term.Text().ToString(), lowerTermText.ToString()) > 0)) && (upperTermText == null || (includeUpper?collator.Compare(term.Text().ToString(), upperTermText.ToString()) <= 0:collator.Compare(term.Text().ToString(), upperTermText.ToString()) < 0)))
{
return true;
}
return false;
}
endEnum = true;
return false;
}
}
示例13: TermCompare
/// <summary> Compares if current upper bound is reached,
/// this also updates the term count for statistics.
/// In contrast to <see cref="FilteredTermEnum" />, a return value
/// of <c>false</c> ends iterating the current enum
/// and forwards to the next sub-range.
/// </summary>
//@Override
/*protected internal*/
public override bool TermCompare(Term term)
{
return ((System.Object) term.Field() == (System.Object) Enclosing_Instance.field && String.CompareOrdinal(term.Text(), currentUpperBound) <= 0);
}
示例14: RangeQuery
/// <summary>Constructs a query selecting all terms greater than
/// <c>lowerTerm</c> but less than <c>upperTerm</c>.
/// There must be at least one term and either term may be null,
/// in which case there is no bound on that side, but if there are
/// two terms, both terms <b>must</b> be for the same field.
/// <p/>
/// If <c>collator</c> is not null, it will be used to decide whether
/// index terms are within the given range, rather than using the Unicode code
/// point order in which index terms are stored.
/// <p/>
/// <strong>WARNING:</strong> Using this constructor and supplying a non-null
/// value in the <c>collator</c> parameter will cause every single
/// index Term in the Field referenced by lowerTerm and/or upperTerm to be
/// examined. Depending on the number of index Terms in this Field, the
/// operation could be very slow.
///
/// </summary>
/// <param name="lowerTerm">The Term at the lower end of the range
/// </param>
/// <param name="upperTerm">The Term at the upper end of the range
/// </param>
/// <param name="inclusive">If true, both <c>lowerTerm</c> and
/// <c>upperTerm</c> will themselves be included in the range.
/// </param>
/// <param name="collator">The collator to use to collate index Terms, to determine
/// their membership in the range bounded by <c>lowerTerm</c> and
/// <c>upperTerm</c>.
/// </param>
public RangeQuery(Term lowerTerm, Term upperTerm, bool inclusive, System.Globalization.CompareInfo collator)
{
if (lowerTerm == null && upperTerm == null)
throw new System.ArgumentException("At least one term must be non-null");
if (lowerTerm != null && upperTerm != null && (System.Object) lowerTerm.Field() != (System.Object) upperTerm.Field())
throw new System.ArgumentException("Both terms must have the same field");
delegate_Renamed = new TermRangeQuery((lowerTerm == null)?upperTerm.Field():lowerTerm.Field(), (lowerTerm == null)?null:lowerTerm.Text(), (upperTerm == null)?null:upperTerm.Text(), inclusive, inclusive, collator);
delegate_Renamed.SetRewriteMethod(TermRangeQuery.SCORING_BOOLEAN_QUERY_REWRITE);
}
示例15: ToAutomaton
/// <summary>
/// Convert Lucene wildcard syntax into an automaton.
/// @lucene.internal
/// </summary>
public static Automaton ToAutomaton(Term wildcardquery)
{
IList<Automaton> automata = new List<Automaton>();
string wildcardText = wildcardquery.Text();
for (int i = 0; i < wildcardText.Length; )
{
int c = Character.CodePointAt(wildcardText, i);
int length = Character.CharCount(c);
switch (c)
{
case WILDCARD_STRING:
automata.Add(BasicAutomata.MakeAnyString());
break;
case WILDCARD_CHAR:
automata.Add(BasicAutomata.MakeAnyChar());
break;
case WILDCARD_ESCAPE:
// add the next codepoint instead, if it exists
if (i + length < wildcardText.Length)
{
int nextChar = Character.CodePointAt(wildcardText, i + length);
length += Character.CharCount(nextChar);
automata.Add(BasicAutomata.MakeChar(nextChar));
break;
} // else fallthru, lenient parsing with a trailing \
goto default;
default:
automata.Add(BasicAutomata.MakeChar(c));
break;
}
i += length;
}
return BasicOperations.Concatenate(automata);
}