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 2007/05/01 20:45:35 UTC
svn commit: r534192 [14/19] - in /incubator/lucene.net/trunk/C#: ./ src/
src/Demo/ src/Demo/DeleteFiles/ src/Demo/DemoLib/ src/Demo/DemoLib/HTML/
src/Demo/IndexFiles/ src/Demo/IndexHtml/ src/Demo/SearchFiles/
src/Lucene.Net/ src/Lucene.Net/Analysis/ sr...
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/QueryParser.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParser.cs Tue May 1 11:45:26 2007
@@ -18,9 +18,10 @@
/* Generated By:JavaCC: Do not edit this line. QueryParser.java */
using System;
+
+using Term = Lucene.Net.Index.Term;
using Lucene.Net.Analysis;
using Lucene.Net.Documents;
-using Term = Lucene.Net.Index.Term;
using Lucene.Net.Search;
using Searchable = Lucene.Net.Search.Searchable;
using Parameter = Lucene.Net.Util.Parameter;
@@ -60,17 +61,34 @@
/// href="http://lucene.apache.org/java/docs/queryparsersyntax.html">query syntax
/// documentation</a>.
/// </p>
- ///
- /// <p>In {@link RangeQuery}s, QueryParser tries to detect date values, e.g. <tt>date:[6/1/2005 TO 6/4/2005]</tt>
- /// produces a range query that searches for "date" fields between 2005-06-01 and 2005-06-04. Note
- /// that the format of the accpeted input depends on {@link #SetLocale(Locale) the locale}. This
- /// feature also assumes that your index uses the {@link DateField} class to store dates.
- /// If you use a different format (e.g. {@link DateTools}) and you still want QueryParser
- /// to turn local dates in range queries into valid queries you need to create your own
- /// query parser that inherits QueryParser and overwrites
- /// {@link #GetRangeQuery(String, String, String, boolean)}.</p>
- ///
- /// <p>Note that QueryParser is <em>not</em> thread-safe.</p>
+ ///
+ /// <p>
+ /// In {@link RangeQuery}s, QueryParser tries to detect date values, e.g.
+ /// <tt>date:[6/1/2005 TO 6/4/2005]</tt> produces a range query that searches
+ /// for "date" fields between 2005-06-01 and 2005-06-04. Note that the format
+ /// of the accepted input depends on {@link #SetLocale(Locale) the locale}.
+ /// By default a date is converted into a search term using the deprecated
+ /// {@link DateField} for compatibility reasons.
+ /// To use the new {@link DateTools} to convert dates, a
+ /// {@link DateTools.Resolution} has to be set.
+ /// </p>
+ /// <p>
+ /// The date resolution that shall be used for RangeQueries can be set
+ /// using {@link #SetDateResolution(DateTools.Resolution)}
+ /// or {@link #SetDateResolution(String, DateTools.Resolution)}. The former
+ /// sets the default date resolution for all fields, whereas the latter can
+ /// be used to set field specific date resolutions. Field specific date
+ /// resolutions take, if set, precedence over the default date resolution.
+ /// </p>
+ /// <p>
+ /// If you use neither {@link DateField} nor {@link DateTools} in your
+ /// index, you can create your own
+ /// query parser that inherits QueryParser and overwrites
+ /// {@link #GetRangeQuery(String, String, String, boolean)} to
+ /// use a different method for date conversion.
+ /// </p>
+ ///
+ /// <p>Note that QueryParser is <em>not</em> thread-safe.</p>
///
/// </summary>
/// <author> Brian Goetz
@@ -79,7 +97,6 @@
/// </author>
/// <author> Tatu Saloranta
/// </author>
-
public class QueryParser : QueryParserConstants
{
private void InitBlock()
@@ -109,6 +126,8 @@
private Operator operator_Renamed = OR_OPERATOR;
internal bool lowercaseExpandedTerms = true;
+ internal bool useOldRangeQuery = false;
+ internal bool allowLeadingWildcard = false;
internal Analyzer analyzer;
internal System.String field;
@@ -117,6 +136,11 @@
internal int fuzzyPrefixLength;
internal System.Globalization.CultureInfo locale = System.Threading.Thread.CurrentThread.CurrentCulture;
+ // the default date resolution
+ internal DateTools.Resolution dateResolution = null;
+ // maps field names to date resolutions
+ internal System.Collections.IDictionary fieldToDateResolution = null;
+
/// <summary>The default operator for parsing queries.
/// Use {@link QueryParser#setDefaultOperator} to change it.
/// </summary>
@@ -142,7 +166,7 @@
field = f;
}
- /// <summary>Parses a query string, returning a {@link Lucene.Net.search.Query}.</summary>
+ /// <summary>Parses a query string, returning a {@link Lucene.Net.Search.Query}.</summary>
/// <param name="query"> the query string to be parsed.
/// </param>
/// <throws> ParseException if the parsing fails </throws>
@@ -153,13 +177,18 @@
{
return Query(field);
}
+ catch (ParseException tme)
+ {
+ // rethrow to include the original query:
+ throw new ParseException("Cannot parse '" + query + "': " + tme.Message);
+ }
catch (TokenMgrError tme)
{
- throw new ParseException(tme.Message);
+ throw new ParseException("Cannot parse '" + query + "': " + tme.Message);
}
- catch (BooleanQuery.TooManyClauses)
+ catch (BooleanQuery.TooManyClauses tmc)
{
- throw new ParseException("Too many boolean clauses");
+ throw new ParseException("Cannot parse '" + query + "': too many boolean clauses");
}
}
@@ -222,6 +251,22 @@
}
+ /// <summary> Set to <code>true</code> to allow <code>*</code> and <code>?</code> as the first character
+ /// of a PrefixQuery and WildcardQuery. Note that this can produce very slow
+ /// queries on big indexes. Default: false.
+ /// </summary>
+ public virtual void SetAllowLeadingWildcard(bool allowLeadingWildcard)
+ {
+ this.allowLeadingWildcard = allowLeadingWildcard;
+ }
+
+ /// <seealso cref="#setAllowLeadingWildcard">
+ /// </seealso>
+ public virtual bool GetAllowLeadingWildcard()
+ {
+ return allowLeadingWildcard;
+ }
+
/// <summary> Sets the boolean operator of the QueryParser.
/// In default mode (<code>OR_OPERATOR</code>) terms without any modifiers
/// are considered optional: for example <code>capital of Hungary</code> is equal to
@@ -253,13 +298,35 @@
}
- /// <seealso cref="SetLowercaseExpandedTerms(boolean)">
+ /// <seealso cref="#SetLowercaseExpandedTerms(boolean)">
/// </seealso>
public virtual bool GetLowercaseExpandedTerms()
{
return lowercaseExpandedTerms;
}
+ /// <summary> By default QueryParser uses new ConstantScoreRangeQuery in preference to RangeQuery
+ /// for range queries. This implementation is generally preferable because it
+ /// a) Runs faster b) Does not have the scarcity of range terms unduly influence score
+ /// c) avoids any "TooManyBooleanClauses" exception.
+ /// However, if your application really needs to use the old-fashioned RangeQuery and the above
+ /// points are not required then set this option to <code>true</code>
+ /// Default is <code>false</code>.
+ /// </summary>
+ public virtual void SetUseOldRangeQuery(bool useOldRangeQuery)
+ {
+ this.useOldRangeQuery = useOldRangeQuery;
+ }
+
+
+ /// <seealso cref="#SetUseOldRangeQuery(boolean)">
+ /// </seealso>
+ public virtual bool GetUseOldRangeQuery()
+ {
+ return useOldRangeQuery;
+ }
+
+
/// <summary> Set locale used by date range parsing.</summary>
public virtual void SetLocale(System.Globalization.CultureInfo locale)
{
@@ -272,6 +339,69 @@
return locale;
}
+ /// <summary> Sets the default date resolution used by RangeQueries for fields for which no
+ /// specific date resolutions has been set. Field specific resolutions can be set
+ /// with {@link #SetDateResolution(String, DateTools.Resolution)}.
+ ///
+ /// </summary>
+ /// <param name="dateResolution">the default date resolution to set
+ /// </param>
+ public virtual void SetDateResolution(DateTools.Resolution dateResolution)
+ {
+ this.dateResolution = dateResolution;
+ }
+
+ /// <summary> Sets the date resolution used by RangeQueries for a specific field.
+ ///
+ /// </summary>
+ /// <param name="field">field for which the date resolution is to be set
+ /// </param>
+ /// <param name="dateResolution">date resolution to set
+ /// </param>
+ public virtual void SetDateResolution(System.String fieldName, DateTools.Resolution dateResolution)
+ {
+ if (fieldName == null)
+ {
+ throw new System.ArgumentException("Field cannot be null.");
+ }
+
+ if (fieldToDateResolution == null)
+ {
+ // lazily initialize HashMap
+ fieldToDateResolution = new System.Collections.Hashtable();
+ }
+
+ fieldToDateResolution[fieldName] = dateResolution;
+ }
+
+ /// <summary> Returns the date resolution that is used by RangeQueries for the given field.
+ /// Returns null, if no default or field specific date resolution has been set
+ /// for the given field.
+ ///
+ /// </summary>
+ public virtual DateTools.Resolution GetDateResolution(System.String fieldName)
+ {
+ if (fieldName == null)
+ {
+ throw new System.ArgumentException("Field cannot be null.");
+ }
+
+ if (fieldToDateResolution == null)
+ {
+ // no field specific date resolutions set; return default date resolution instead
+ return this.dateResolution;
+ }
+
+ DateTools.Resolution resolution = (DateTools.Resolution) fieldToDateResolution[fieldName];
+ if (resolution == null)
+ {
+ // no date resolutions set for the given field; return default date resolution instead
+ resolution = this.dateResolution;
+ }
+
+ return resolution;
+ }
+
protected internal virtual void AddClause(System.Collections.ArrayList clauses, int conj, int mods, Query q)
{
bool required, prohibited;
@@ -330,7 +460,7 @@
}
- /// <exception cref="ParseException">throw in overridden method to disallow
+ /// <exception cref=""> ParseException throw in overridden method to disallow
/// </exception>
protected internal virtual Query GetFieldQuery(System.String field, System.String queryText)
{
@@ -397,8 +527,8 @@
{
// phrase query:
MultiPhraseQuery mpq = new MultiPhraseQuery();
- mpq.SetSlop(phraseSlop);
- System.Collections.ArrayList multiTerms = new System.Collections.ArrayList();
+ mpq.SetSlop(phraseSlop);
+ System.Collections.ArrayList multiTerms = new System.Collections.ArrayList();
for (int i = 0; i < v.Count; i++)
{
t = (Lucene.Net.Analysis.Token) v[i];
@@ -425,14 +555,14 @@
}
}
}
-
+
/// <summary> Base implementation delegates to {@link #GetFieldQuery(String,String)}.
/// This method may be overridden, for example, to return
/// a SpanNearQuery instead of a PhraseQuery.
///
/// </summary>
- /// <exception cref="ParseException">throw in overridden method to disallow
+ /// <exception cref=""> ParseException throw in overridden method to disallow
/// </exception>
protected internal virtual Query GetFieldQuery(System.String field, System.String queryText, int slop)
{
@@ -451,7 +581,7 @@
}
- /// <exception cref="ParseException">throw in overridden method to disallow
+ /// <exception cref=""> ParseException throw in overridden method to disallow
/// </exception>
protected internal virtual Query GetRangeQuery(System.String field, System.String part1, System.String part2, bool inclusive)
{
@@ -494,14 +624,33 @@
d2 = d2.AddSeconds(59 - tempDate.Second);
d2 = d2.AddMilliseconds(999 - tempDate.Millisecond);
}
- part1 = DateField.DateToString(d1);
- part2 = DateField.DateToString(d2);
- }
- catch (System.Exception)
+ DateTools.Resolution resolution = GetDateResolution(field);
+ if (resolution == null)
+ {
+ // no default or field specific date resolution has been set,
+ // use deprecated DateField to maintain compatibilty with
+ // pre-1.9 Lucene versions.
+ part1 = DateField.DateToString(d1);
+ part2 = DateField.DateToString(d2);
+ }
+ else
+ {
+ part1 = DateTools.DateToString(d1, resolution);
+ part2 = DateTools.DateToString(d2, resolution);
+ }
+ }
+ catch (System.Exception e)
{
}
- return new RangeQuery(new Term(field, part1), new Term(field, part2), inclusive);
+ if (useOldRangeQuery)
+ {
+ return new RangeQuery(new Term(field, part1), new Term(field, part2), inclusive);
+ }
+ else
+ {
+ return new ConstantScoreRangeQuery(field, part1, part2, inclusive, inclusive);
+ }
}
/// <summary> Factory method for generating query, given a set of clauses.
@@ -517,7 +666,7 @@
/// </param>
/// <returns> Resulting {@link Query} object.
/// </returns>
- /// <exception cref="ParseException">throw in overridden method to disallow
+ /// <exception cref=""> ParseException throw in overridden method to disallow
/// </exception>
protected internal virtual Query GetBooleanQuery(System.Collections.ArrayList clauses)
{
@@ -539,7 +688,7 @@
/// </param>
/// <returns> Resulting {@link Query} object.
/// </returns>
- /// <exception cref="ParseException">throw in overridden method to disallow
+ /// <exception cref=""> ParseException throw in overridden method to disallow
/// </exception>
protected internal virtual Query GetBooleanQuery(System.Collections.ArrayList clauses, bool disableCoord)
{
@@ -573,10 +722,17 @@
/// </param>
/// <returns> Resulting {@link Query} built for the term
/// </returns>
- /// <exception cref="ParseException">throw in overridden method to disallow
+ /// <exception cref=""> ParseException throw in overridden method to disallow
/// </exception>
protected internal virtual Query GetWildcardQuery(System.String field, System.String termStr)
{
+ if ("*".Equals(field))
+ {
+ if ("*".Equals(termStr))
+ return new MatchAllDocsQuery();
+ }
+ if (!allowLeadingWildcard && (termStr.StartsWith("*") || termStr.StartsWith("?")))
+ throw new ParseException("'*' or '?' not allowed as first character in WildcardQuery");
if (lowercaseExpandedTerms)
{
termStr = termStr.ToLower();
@@ -609,10 +765,12 @@
/// </param>
/// <returns> Resulting {@link Query} built for the term
/// </returns>
- /// <exception cref="ParseException">throw in overridden method to disallow
+ /// <exception cref=""> ParseException throw in overridden method to disallow
/// </exception>
protected internal virtual Query GetPrefixQuery(System.String field, System.String termStr)
{
+ if (!allowLeadingWildcard && termStr.StartsWith("*"))
+ throw new ParseException("'*' not allowed as first character in PrefixQuery");
if (lowercaseExpandedTerms)
{
termStr = termStr.ToLower();
@@ -634,7 +792,7 @@
/// </param>
/// <returns> Resulting {@link Query} built for the term
/// </returns>
- /// <exception cref="ParseException">throw in overridden method to disallow
+ /// <exception cref=""> ParseException throw in overridden method to disallow
/// </exception>
protected internal virtual Query GetFuzzyQuery(System.String field, System.String termStr, float minSimilarity)
{
@@ -648,20 +806,106 @@
/// <summary> Returns a String where the escape char has been
/// removed, or kept only once if there was a double escape.
+ ///
+ /// Supports escaped unicode characters, e. g. translates
+ /// <code>A</code> to <code>A</code>.
+ ///
/// </summary>
private System.String DiscardEscapeChar(System.String input)
{
- char[] caSource = input.ToCharArray();
- char[] caDest = new char[caSource.Length];
- int j = 0;
- for (int i = 0; i < caSource.Length; i++)
+ // Create char array to hold unescaped char sequence
+ char[] output = new char[input.Length];
+
+ // The length of the output can be less than the input
+ // due to discarded escape chars. This variable holds
+ // the actual length of the output
+ int length = 0;
+
+ // We remember whether the last processed character was
+ // an escape character
+ bool lastCharWasEscapeChar = false;
+
+ // The multiplier the current unicode digit must be multiplied with.
+ // E. g. the first digit must be multiplied with 16^3, the second with 16^2...
+ int codePointMultiplier = 0;
+
+ // Used to calculate the codepoint of the escaped unicode character
+ int codePoint = 0;
+
+ for (int i = 0; i < input.Length; i++)
{
- if ((caSource[i] != '\\') || (i > 0 && caSource[i - 1] == '\\'))
+ char curChar = input[i];
+ if (codePointMultiplier > 0)
+ {
+ codePoint += HexToInt(curChar) * codePointMultiplier;
+ codePointMultiplier = SupportClass.Number.URShift(codePointMultiplier, 4);
+ if (codePointMultiplier == 0)
+ {
+ output[length++] = (char) codePoint;
+ codePoint = 0;
+ }
+ }
+ else if (lastCharWasEscapeChar)
+ {
+ if (curChar == 'u')
+ {
+ // found an escaped unicode character
+ codePointMultiplier = 16 * 16 * 16;
+ }
+ else
+ {
+ // this character was escaped
+ output[length] = curChar;
+ length++;
+ }
+ lastCharWasEscapeChar = false;
+ }
+ else
{
- caDest[j++] = caSource[i];
+ if (curChar == '\\')
+ {
+ lastCharWasEscapeChar = true;
+ }
+ else
+ {
+ output[length] = curChar;
+ length++;
+ }
}
}
- return new System.String(caDest, 0, j);
+
+ if (codePointMultiplier > 0)
+ {
+ throw new ParseException("Truncated unicode escape sequence.");
+ }
+
+ if (lastCharWasEscapeChar)
+ {
+ throw new ParseException("Term can not end with escape character.");
+ }
+
+ return new System.String(output, 0, length);
+ }
+
+ /// <summary>Returns the numeric value of the hexadecimal character </summary>
+ private static int HexToInt(char c)
+ {
+ if ('0' <= c && c <= '9')
+ {
+ return c - '0';
+ }
+ else if ('a' <= c && c <= 'f')
+ {
+ return c - 'a' + 10;
+ }
+ else if ('A' <= c && c <= 'F')
+ {
+ return c - 'A' + 10;
+ }
+ else
+ {
+ throw new ParseException("None-hex character in unicode escape sequence: " + c);
+ }
}
/// <summary> Returns a String where those characters that QueryParser
@@ -683,16 +927,16 @@
return sb.ToString();
}
- /// <summary> Command line tool to test QueryParser, using {@link Lucene.Net.analysis.SimpleAnalyzer}.
+ /// <summary> Command line tool to test QueryParser, using {@link Lucene.Net.Analysis.SimpleAnalyzer}.
/// Usage:<br>
- /// <code>java Lucene.Net.queryParser.QueryParser <input></code>
+ /// <code>java Lucene.Net.QueryParsers.QueryParser <input></code>
/// </summary>
[STAThread]
public static void Main(System.String[] args)
{
if (args.Length == 0)
{
- System.Console.Out.WriteLine("Usage: java Lucene.Net.queryParser.QueryParser <input>");
+ System.Console.Out.WriteLine("Usage: java Lucene.Net.QueryParsers.QueryParser <input>");
System.Environment.Exit(0);
}
QueryParser qp = new QueryParser("field", new Lucene.Net.Analysis.SimpleAnalyzer());
@@ -813,6 +1057,7 @@
case Lucene.Net.QueryParsers.QueryParserConstants.PLUS:
case Lucene.Net.QueryParsers.QueryParserConstants.MINUS:
case Lucene.Net.QueryParsers.QueryParserConstants.LPAREN:
+ case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
case Lucene.Net.QueryParsers.QueryParserConstants.QUOTED:
case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
case Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM:
@@ -857,9 +1102,27 @@
Token fieldToken = null, boost = null;
if (Jj_2_1(2))
{
- fieldToken = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.TERM);
- Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON);
- field = DiscardEscapeChar(fieldToken.image);
+ switch ((jj_ntk == - 1)?Jj_ntk():jj_ntk)
+ {
+
+ case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
+ fieldToken = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.TERM);
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON);
+ field = DiscardEscapeChar(fieldToken.image);
+ break;
+
+ case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.STAR);
+ Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON);
+ field = "*";
+ break;
+
+ default:
+ jj_la1[5] = jj_gen;
+ Jj_consume_token(- 1);
+ throw new ParseException();
+
+ }
}
else
{
@@ -868,6 +1131,7 @@
switch ((jj_ntk == - 1) ? Jj_ntk() : jj_ntk)
{
+ case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
case Lucene.Net.QueryParsers.QueryParserConstants.QUOTED:
case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
case Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM:
@@ -891,7 +1155,7 @@
break;
default:
- jj_la1[5] = jj_gen;
+ jj_la1[6] = jj_gen;
;
break;
@@ -899,7 +1163,7 @@
break;
default:
- jj_la1[6] = jj_gen;
+ jj_la1[7] = jj_gen;
Jj_consume_token(- 1);
throw new ParseException();
@@ -934,6 +1198,7 @@
switch ((jj_ntk == - 1) ? Jj_ntk() : jj_ntk)
{
+ case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
case Lucene.Net.QueryParsers.QueryParserConstants.TERM:
case Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM:
case Lucene.Net.QueryParsers.QueryParserConstants.WILDTERM:
@@ -945,6 +1210,11 @@
term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.TERM);
break;
+ case Lucene.Net.QueryParsers.QueryParserConstants.STAR:
+ term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.STAR);
+ wildcard = true;
+ break;
+
case Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM:
term = Jj_consume_token(Lucene.Net.QueryParsers.QueryParserConstants.PREFIXTERM);
prefix = true;
@@ -960,7 +1230,7 @@
break;
default:
- jj_la1[7] = jj_gen;
+ jj_la1[8] = jj_gen;
Jj_consume_token(- 1);
throw new ParseException();
@@ -974,7 +1244,7 @@
break;
default:
- jj_la1[8] = jj_gen;
+ jj_la1[9] = jj_gen;
;
break;
@@ -994,7 +1264,7 @@
break;
default:
- jj_la1[9] = jj_gen;
+ jj_la1[10] = jj_gen;
;
break;
@@ -1002,7 +1272,7 @@
break;
default:
- jj_la1[10] = jj_gen;
+ jj_la1[11] = jj_gen;
;
break;
@@ -1023,7 +1293,7 @@
{
fms = (float) System.Single.Parse(fuzzySlop.image.Substring(1).Replace(".",
System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
- }
+ }
catch (System.Exception ignored)
{
}
@@ -1056,7 +1326,7 @@
break;
default:
- jj_la1[11] = jj_gen;
+ jj_la1[12] = jj_gen;
Jj_consume_token(- 1);
throw new ParseException();
@@ -1069,7 +1339,7 @@
break;
default:
- jj_la1[12] = jj_gen;
+ jj_la1[13] = jj_gen;
;
break;
@@ -1086,7 +1356,7 @@
break;
default:
- jj_la1[13] = jj_gen;
+ jj_la1[14] = jj_gen;
Jj_consume_token(- 1);
throw new ParseException();
@@ -1101,7 +1371,7 @@
break;
default:
- jj_la1[14] = jj_gen;
+ jj_la1[15] = jj_gen;
;
break;
@@ -1110,19 +1380,11 @@
{
goop1.image = goop1.image.Substring(1, (goop1.image.Length - 1) - (1));
}
- else
- {
- goop1.image = DiscardEscapeChar(goop1.image);
- }
if (goop2.kind == Lucene.Net.QueryParsers.QueryParserConstants.RANGEIN_QUOTED)
{
goop2.image = goop2.image.Substring(1, (goop2.image.Length - 1) - (1));
}
- else
- {
- goop2.image = DiscardEscapeChar(goop2.image);
- }
- q = GetRangeQuery(field, goop1.image, goop2.image, true);
+ q = GetRangeQuery(field, DiscardEscapeChar(goop1.image), DiscardEscapeChar(goop2.image), true);
break;
case Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_START:
@@ -1139,7 +1401,7 @@
break;
default:
- jj_la1[15] = jj_gen;
+ jj_la1[16] = jj_gen;
Jj_consume_token(- 1);
throw new ParseException();
@@ -1152,7 +1414,7 @@
break;
default:
- jj_la1[16] = jj_gen;
+ jj_la1[17] = jj_gen;
;
break;
@@ -1169,7 +1431,7 @@
break;
default:
- jj_la1[17] = jj_gen;
+ jj_la1[18] = jj_gen;
Jj_consume_token(- 1);
throw new ParseException();
@@ -1184,7 +1446,7 @@
break;
default:
- jj_la1[18] = jj_gen;
+ jj_la1[19] = jj_gen;
;
break;
@@ -1193,20 +1455,12 @@
{
goop1.image = goop1.image.Substring(1, (goop1.image.Length - 1) - (1));
}
- else
- {
- goop1.image = DiscardEscapeChar(goop1.image);
- }
if (goop2.kind == Lucene.Net.QueryParsers.QueryParserConstants.RANGEEX_QUOTED)
{
goop2.image = goop2.image.Substring(1, (goop2.image.Length - 1) - (1));
}
- else
- {
- goop2.image = DiscardEscapeChar(goop2.image);
- }
- q = GetRangeQuery(field, goop1.image, goop2.image, false);
+ q = GetRangeQuery(field, DiscardEscapeChar(goop1.image), DiscardEscapeChar(goop2.image), false);
break;
case Lucene.Net.QueryParsers.QueryParserConstants.QUOTED:
@@ -1219,7 +1473,7 @@
break;
default:
- jj_la1[19] = jj_gen;
+ jj_la1[20] = jj_gen;
;
break;
@@ -1233,7 +1487,7 @@
break;
default:
- jj_la1[20] = jj_gen;
+ jj_la1[21] = jj_gen;
;
break;
@@ -1250,11 +1504,11 @@
{
}
}
- q = GetFieldQuery(field, term.image.Substring(1, (term.image.Length - 1) - (1)), s);
+ q = GetFieldQuery(field, DiscardEscapeChar(term.image.Substring(1, (term.image.Length - 1) - (1))), s);
break;
default:
- jj_la1[21] = jj_gen;
+ jj_la1[22] = jj_gen;
Jj_consume_token(- 1);
throw new ParseException();
@@ -1303,7 +1557,16 @@
}
}
- private bool Jj_3_1()
+ private bool Jj_3R_3()
+ {
+ if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.STAR))
+ return true;
+ if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.COLON))
+ return true;
+ return false;
+ }
+
+ private bool Jj_3R_2()
{
if (Jj_scan_token(Lucene.Net.QueryParsers.QueryParserConstants.TERM))
return true;
@@ -1312,6 +1575,19 @@
return false;
}
+ private bool Jj_3_1()
+ {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (Jj_3R_2())
+ {
+ jj_scanpos = xsp;
+ if (Jj_3R_3())
+ return true;
+ }
+ return false;
+ }
+
public QueryParserTokenManager token_source;
public Token token, jj_nt;
private int jj_ntk;
@@ -1320,11 +1596,16 @@
public bool lookingAhead = false;
private bool jj_semLA;
private int jj_gen;
- private int[] jj_la1 = new int[22];
+ private int[] jj_la1 = new int[23];
private static uint[] jj_la1_0;
+ private static uint[] jj_la1_1;
private static void Jj_la1_0()
{
- jj_la1_0 = new uint[]{0x180, 0x180, 0xe00, 0xe00, 0xfb1f80, 0x8000, 0xfb1000, 0x9a0000, 0x40000, 0x40000, 0x8000, 0xc000000, 0x1000000, 0xc000000, 0x8000, 0xc0000000, 0x10000000, 0xc0000000, 0x8000, 0x40000, 0x8000, 0xfb0000};
+ jj_la1_0 = new uint[]{0x180, 0x180, 0xe00, 0xe00, 0x1f69f80, 0x48000, 0x10000, 0x1f69000, 0x1348000, 0x80000, 0x80000, 0x10000, 0x18000000, 0x2000000, 0x18000000, 0x10000, 0x80000000, 0x20000000, 0x80000000, 0x10000, 0x80000, 0x10000, 0x1f68000};
+ }
+ private static void Jj_la1_1()
+ {
+ jj_la1_1 = new uint[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0};
}
private JJCalls[] jj_2_rtns;
private bool jj_rescan = false;
@@ -1337,7 +1618,7 @@
token = new Token();
jj_ntk = - 1;
jj_gen = 0;
- for (int i = 0; i < 22; i++)
+ for (int i = 0; i < 23; i++)
jj_la1[i] = - 1;
for (int i = 0; i < jj_2_rtns.Length; i++)
jj_2_rtns[i] = new JJCalls();
@@ -1349,7 +1630,7 @@
token = new Token();
jj_ntk = - 1;
jj_gen = 0;
- for (int i = 0; i < 22; i++)
+ for (int i = 0; i < 23; i++)
jj_la1[i] = - 1;
for (int i = 0; i < jj_2_rtns.Length; i++)
jj_2_rtns[i] = new JJCalls();
@@ -1362,7 +1643,7 @@
token = new Token();
jj_ntk = - 1;
jj_gen = 0;
- for (int i = 0; i < 22; i++)
+ for (int i = 0; i < 23; i++)
jj_la1[i] = - 1;
for (int i = 0; i < jj_2_rtns.Length; i++)
jj_2_rtns[i] = new JJCalls();
@@ -1374,7 +1655,7 @@
token = new Token();
jj_ntk = - 1;
jj_gen = 0;
- for (int i = 0; i < 22; i++)
+ for (int i = 0; i < 23; i++)
jj_la1[i] = - 1;
for (int i = 0; i < jj_2_rtns.Length; i++)
jj_2_rtns[i] = new JJCalls();
@@ -1534,8 +1815,8 @@
public virtual ParseException GenerateParseException()
{
jj_expentries.Clear();
- bool[] la1tokens = new bool[32];
- for (int i = 0; i < 32; i++)
+ bool[] la1tokens = new bool[33];
+ for (int i = 0; i < 33; i++)
{
la1tokens[i] = false;
}
@@ -1544,7 +1825,7 @@
la1tokens[jj_kind] = true;
jj_kind = - 1;
}
- for (int i = 0; i < 22; i++)
+ for (int i = 0; i < 23; i++)
{
if (jj_la1[i] == jj_gen)
{
@@ -1554,10 +1835,14 @@
{
la1tokens[j] = true;
}
+ if ((jj_la1_1[i] & (1 << j)) != 0)
+ {
+ la1tokens[32 + j] = true;
+ }
}
}
}
- for (int i = 0; i < 32; i++)
+ for (int i = 0; i < 33; i++)
{
if (la1tokens[i])
{
@@ -1600,7 +1885,7 @@
{
case 0: Jj_3_1(); break;
- }
+ }
}
p = p.next;
}
@@ -1634,6 +1919,7 @@
{
{
Jj_la1_0();
+ Jj_la1_1();
}
}
}
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserConstants.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/QueryParserConstants.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserConstants.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserConstants.cs Tue May 1 11:45:26 2007
@@ -23,7 +23,7 @@
{
public class QueryParserConstants
- {
+ {
public const int EOF = 0;
public const int _NUM_CHAR = 1;
public const int _ESCAPED_CHAR = 2;
@@ -38,27 +38,28 @@
public const int LPAREN = 12;
public const int RPAREN = 13;
public const int COLON = 14;
- public const int CARAT = 15;
- public const int QUOTED = 16;
- public const int TERM = 17;
- public const int FUZZY_SLOP = 18;
- public const int PREFIXTERM = 19;
- public const int WILDTERM = 20;
- public const int RANGEIN_START = 21;
- public const int RANGEEX_START = 22;
- public const int NUMBER = 23;
- public const int RANGEIN_TO = 24;
- public const int RANGEIN_END = 25;
- public const int RANGEIN_QUOTED = 26;
- public const int RANGEIN_GOOP = 27;
- public const int RANGEEX_TO = 28;
- public const int RANGEEX_END = 29;
- public const int RANGEEX_QUOTED = 30;
- public const int RANGEEX_GOOP = 31;
+ public const int STAR = 15;
+ public const int CARAT = 16;
+ public const int QUOTED = 17;
+ public const int TERM = 18;
+ public const int FUZZY_SLOP = 19;
+ public const int PREFIXTERM = 20;
+ public const int WILDTERM = 21;
+ public const int RANGEIN_START = 22;
+ public const int RANGEEX_START = 23;
+ public const int NUMBER = 24;
+ public const int RANGEIN_TO = 25;
+ public const int RANGEIN_END = 26;
+ public const int RANGEIN_QUOTED = 27;
+ public const int RANGEIN_GOOP = 28;
+ public const int RANGEEX_TO = 29;
+ public const int RANGEEX_END = 30;
+ public const int RANGEEX_QUOTED = 31;
+ public const int RANGEEX_GOOP = 32;
public const int Boost = 0;
public const int RangeEx = 1;
public const int RangeIn = 2;
public const int DEFAULT = 3;
- public static System.String[] tokenImage = new System.String[]{"<EOF>", "<_NUM_CHAR>", "<_ESCAPED_CHAR>", "<_TERM_START_CHAR>", "<_TERM_CHAR>", "<_WHITESPACE>", "<token of kind 6>", "<AND>", "<OR>", "<NOT>", "\"+\"", "\"-\"", "\"(\"", "\")\"", "\":\"", "\"^\"", "<QUOTED>", "<TERM>", "<FUZZY_SLOP>", "<PREFIXTERM>", "<WILDTERM>", "\"[\"", "\"{\"", "<NUMBER>", "\"TO\"", "\"]\"", "<RANGEIN_QUOTED>", "<RANGEIN_GOOP>", "\"TO\"", "\"}\"", "<RANGEEX_QUOTED>", "<RANGEEX_GOOP>"};
+ public static System.String[] tokenImage = new System.String[]{"<EOF>", "<_NUM_CHAR>", "<_ESCAPED_CHAR>", "<_TERM_START_CHAR>", "<_TERM_CHAR>", "<_WHITESPACE>", "<token of kind 6>", "<AND>", "<OR>", "<NOT>", "\"+\"", "\"-\"", "\"(\"", "\")\"", "\":\"", "\"*\"", "\"^\"", "<QUOTED>", "<TERM>", "<FUZZY_SLOP>", "<PREFIXTERM>", "<WILDTERM>", "\"[\"", "\"{\"", "<NUMBER>", "\"TO\"", "\"]\"", "<RANGEIN_QUOTED>", "<RANGEIN_GOOP>", "\"TO\"", "\"}\"", "<RANGEEX_QUOTED>", "<RANGEEX_GOOP>"};
}
}
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/QueryParserTokenManager.cs Tue May 1 11:45:26 2007
@@ -18,9 +18,10 @@
/* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
using System;
+
+using Term = Lucene.Net.Index.Term;
using Lucene.Net.Analysis;
using Lucene.Net.Documents;
-using Term = Lucene.Net.Index.Term;
using Lucene.Net.Search;
using Searchable = Lucene.Net.Search.Searchable;
using Parameter = Lucene.Net.Util.Parameter;
@@ -87,6 +88,9 @@
case (char) (41):
return JjStopAtPos(0, 13);
+ case (char) (42):
+ return JjStartNfaWithStates_3(0, 15, 37);
+
case (char) (43):
return JjStopAtPos(0, 10);
@@ -97,13 +101,13 @@
return JjStopAtPos(0, 14);
case (char) (91):
- return JjStopAtPos(0, 21);
+ return JjStopAtPos(0, 22);
case (char) (94):
- return JjStopAtPos(0, 15);
+ return JjStopAtPos(0, 16);
case (char) (123):
- return JjStopAtPos(0, 22);
+ return JjStopAtPos(0, 23);
default:
return JjMoveNfa_3(0, 0);
@@ -150,7 +154,7 @@
{
int[] nextStates;
int startsAt = 0;
- jjnewStateCnt = 33;
+ jjnewStateCnt = 37;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
@@ -167,12 +171,28 @@
switch (jjstateSet[--i])
{
+ case 37:
+ if ((0xfbfffcf8ffffd9ffL & l) != (ulong) 0L)
+ {
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
+ }
+ if ((0x7bfff8f8ffffd9ffL & l) != (ulong) 0L)
+ JjCheckNAddStates(0, 2);
+ else if (curChar == 42)
+ {
+ if (kind > 20)
+ kind = 20;
+ }
+ break;
+
case 0:
- if ((0x7bffd0f8ffffd9ffL & l) != (ulong) 0L)
+ if ((0xfbffd4f8ffffd9ffL & l) != (ulong) 0L)
{
- if (kind > 17)
- kind = 17;
- JjCheckNAddStates(0, 6);
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
}
else if ((0x100002600L & l) != (ulong) 0L)
{
@@ -180,12 +200,20 @@
kind = 6;
}
else if (curChar == 34)
- JjCheckNAdd(15);
+ JjCheckNAddTwoStates(15, 17);
else if (curChar == 33)
{
if (kind > 9)
kind = 9;
}
+ if ((0x7bffd4f8ffffd9ffL & l) != (ulong) 0L)
+ JjCheckNAddStates(0, 2);
+ if ((0x7bffd0f8ffffd9ffL & l) != (ulong) 0L)
+ {
+ if (kind > 18)
+ kind = 18;
+ JjCheckNAddTwoStates(20, 21);
+ }
if (curChar == 38)
jjstateSet[jjnewStateCnt++] = 4;
break;
@@ -207,93 +235,111 @@
case 14:
if (curChar == 34)
- JjCheckNAdd(15);
+ JjCheckNAddTwoStates(15, 17);
break;
case 15:
if ((0xfffffffbffffffffL & l) != (ulong) 0L)
- JjCheckNAddTwoStates(15, 16);
+ JjCheckNAddStates(3, 5);
break;
case 16:
- if (curChar == 34 && kind > 16)
- kind = 16;
+ if (curChar == 34)
+ JjCheckNAddStates(3, 5);
break;
case 18:
- if ((0x3ff000000000000L & l) == (ulong) 0L)
- break;
- if (kind > 18)
- kind = 18;
- JjAddStates(7, 8);
+ if (curChar == 34 && kind > 17)
+ kind = 17;
break;
case 19:
- if (curChar == 46)
- JjCheckNAdd(20);
- break;
-
- case 20:
- if ((0x3ff000000000000L & l) == (ulong) 0L)
+ if ((0x7bffd0f8ffffd9ffL & l) == (ulong) 0L)
break;
if (kind > 18)
kind = 18;
- JjCheckNAdd(20);
+ JjCheckNAddTwoStates(20, 21);
break;
- case 21:
- if ((0x7bffd0f8ffffd9ffL & l) == (ulong) 0L)
+ case 20:
+ if ((0x7bfff8f8ffffd9ffL & l) == (ulong) 0L)
break;
- if (kind > 17)
- kind = 17;
- JjCheckNAddStates(0, 6);
+ if (kind > 18)
+ kind = 18;
+ JjCheckNAddTwoStates(20, 21);
break;
case 22:
- if ((0x7bfff8f8ffffd9ffL & l) == (ulong) 0L)
+ if ((0x84002f0600000000L & l) == (ulong) 0L)
break;
- if (kind > 17)
- kind = 17;
- JjCheckNAddTwoStates(22, 23);
+ if (kind > 18)
+ kind = 18;
+ JjCheckNAddTwoStates(20, 21);
break;
case 24:
- if ((0x84002f0600000000L & l) == (ulong) 0L)
+ if ((0x3ff000000000000L & l) == (ulong) 0L)
break;
- if (kind > 17)
- kind = 17;
- JjCheckNAddTwoStates(22, 23);
+ if (kind > 19)
+ kind = 19;
+ JjAddStates(6, 7);
break;
case 25:
- if ((0x7bfff8f8ffffd9ffL & l) != (ulong) 0L)
- JjCheckNAddStates(9, 11);
+ if (curChar == 46)
+ JjCheckNAdd(26);
break;
case 26:
- if (curChar == 42 && kind > 19)
+ if ((0x3ff000000000000L & l) == (ulong) 0L)
+ break;
+ if (kind > 19)
kind = 19;
+ JjCheckNAdd(26);
+ break;
+
+ case 27:
+ if ((0x7bffd4f8ffffd9ffL & l) != (ulong) 0L)
+ JjCheckNAddStates(0, 2);
break;
case 28:
- if ((0x84002f0600000000L & l) != (ulong) 0L)
- JjCheckNAddStates(9, 11);
+ if ((0x7bfff8f8ffffd9ffL & l) != (ulong) 0L)
+ JjCheckNAddStates(0, 2);
break;
case 29:
- if ((0xfbfffcf8ffffd9ffL & l) == (ulong) 0L)
- break;
- if (kind > 20)
+ if (curChar == 42 && kind > 20)
kind = 20;
- JjCheckNAddTwoStates(29, 30);
break;
case 31:
+ if ((0x84002f0600000000L & l) != (ulong) 0L)
+ JjCheckNAddStates(0, 2);
+ break;
+
+ case 32:
+ if ((0xfbffd4f8ffffd9ffL & l) == (ulong) 0L)
+ break;
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
+ break;
+
+ case 33:
+ if ((0xfbfffcf8ffffd9ffL & l) == (ulong) 0L)
+ break;
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
+ break;
+
+ case 35:
if ((0x84002f0600000000L & l) == (ulong) 0L)
break;
- if (kind > 20)
- kind = 20;
- JjCheckNAddTwoStates(29, 30);
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
break;
default: break;
@@ -311,21 +357,44 @@
switch (jjstateSet[--i])
{
+ case 37:
+ if ((0x97ffffff97ffffffL & l) != (ulong) 0L)
+ {
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
+ }
+ if ((0x97ffffff97ffffffL & l) != (ulong) 0L)
+ JjCheckNAddStates(0, 2);
+ if (curChar == 92)
+ JjCheckNAddTwoStates(31, 31);
+ if (curChar == 92)
+ JjCheckNAddTwoStates(35, 35);
+ break;
+
case 0:
if ((0x97ffffff97ffffffL & l) != (ulong) 0L)
{
- if (kind > 17)
- kind = 17;
- JjCheckNAddStates(0, 6);
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
}
else if (curChar == 126)
{
+ if (kind > 19)
+ kind = 19;
+ jjstateSet[jjnewStateCnt++] = 24;
+ }
+ if ((0x97ffffff97ffffffL & l) != (ulong) 0L)
+ JjCheckNAddStates(0, 2);
+ if ((0x97ffffff97ffffffL & l) != (ulong) 0L)
+ {
if (kind > 18)
kind = 18;
- jjstateSet[jjnewStateCnt++] = 18;
+ JjCheckNAddTwoStates(20, 21);
}
if (curChar == 92)
- JjCheckNAddStates(12, 14);
+ JjCheckNAddStates(8, 10);
else if (curChar == 78)
jjstateSet[jjnewStateCnt++] = 11;
else if (curChar == 124)
@@ -387,85 +456,96 @@
break;
case 15:
- JjAddStates(15, 16);
+ JjAddStates(3, 5);
break;
case 17:
- if (curChar != 126)
+ if (curChar == 92)
+ jjstateSet[jjnewStateCnt++] = 16;
+ break;
+
+ case 19:
+ case 20:
+ if ((0x97ffffff97ffffffL & l) == (ulong) 0L)
break;
if (kind > 18)
kind = 18;
- jjstateSet[jjnewStateCnt++] = 18;
+ JjCheckNAddTwoStates(20, 21);
break;
case 21:
- if ((0x97ffffff97ffffffL & l) == (ulong) 0L)
- break;
- if (kind > 17)
- kind = 17;
- JjCheckNAddStates(0, 6);
+ if (curChar == 92)
+ JjCheckNAddTwoStates(22, 22);
break;
case 22:
- if ((0x97ffffff97ffffffL & l) == (ulong) 0L)
+ if ((0x6800000078000000L & l) == (ulong) 0L)
break;
- if (kind > 17)
- kind = 17;
- JjCheckNAddTwoStates(22, 23);
+ if (kind > 18)
+ kind = 18;
+ JjCheckNAddTwoStates(20, 21);
break;
case 23:
- if (curChar == 92)
- JjCheckNAddTwoStates(24, 24);
+ if (curChar != 126)
+ break;
+ if (kind > 19)
+ kind = 19;
+ jjstateSet[jjnewStateCnt++] = 24;
break;
- case 24:
- if ((0x6800000078000000L & l) == (ulong) 0L)
- break;
- if (kind > 17)
- kind = 17;
- JjCheckNAddTwoStates(22, 23);
+ case 27:
+ if ((0x97ffffff97ffffffL & l) != (ulong) 0L)
+ JjCheckNAddStates(0, 2);
break;
- case 25:
+ case 28:
if ((0x97ffffff97ffffffL & l) != (ulong) 0L)
- JjCheckNAddStates(9, 11);
+ JjCheckNAddStates(0, 2);
break;
- case 27:
+ case 30:
if (curChar == 92)
- JjCheckNAddTwoStates(28, 28);
+ JjCheckNAddTwoStates(31, 31);
break;
- case 28:
- if ((0x6800000078000000L & l) != (ulong) 0L)
- JjCheckNAddStates(9, 11);
+ case 31:
+ if ((0x6800000078000000L & l) != 0L)
+ JjCheckNAddStates(0, 2);
break;
- case 29:
+ case 32:
if ((0x97ffffff97ffffffL & l) == (ulong) 0L)
break;
- if (kind > 20)
- kind = 20;
- JjCheckNAddTwoStates(29, 30);
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
break;
- case 30:
+ case 33:
+ if ((0x97ffffff97ffffffL & l) == (ulong) 0L)
+ break;
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
+ break;
+
+ case 34:
if (curChar == 92)
- JjCheckNAddTwoStates(31, 31);
+ JjCheckNAddTwoStates(35, 35);
break;
- case 31:
+ case 35:
if ((0x6800000078000000L & l) == (ulong) 0L)
break;
- if (kind > 20)
- kind = 20;
- JjCheckNAddTwoStates(29, 30);
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
break;
- case 32:
+ case 36:
if (curChar == 92)
- JjCheckNAddStates(12, 14);
+ JjCheckNAddStates(8, 10);
break;
default: break;
@@ -487,38 +567,72 @@
switch (jjstateSet[--i])
{
+ case 37:
+ if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
+ JjCheckNAddStates(0, 2);
+ if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
+ {
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
+ }
+ break;
+
case 0:
- if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
- break;
- if (kind > 17)
- kind = 17;
- JjCheckNAddStates(0, 6);
+ if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
+ {
+ if (kind > 18)
+ kind = 18;
+ JjCheckNAddTwoStates(20, 21);
+ }
+ if (JjCanMove_0(hiByte, i1, i2, l1, l2))
+ JjCheckNAddStates(0, 2);
+ if (JjCanMove_0(hiByte, i1, i2, l1, l2))
+ {
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
+ }
break;
case 15:
if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
- JjAddStates(15, 16);
+ JjAddStates(3, 5);
break;
- case 22:
+ case 19:
+ case 20:
if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
break;
- if (kind > 17)
- kind = 17;
- JjCheckNAddTwoStates(22, 23);
+ if (kind > 18)
+ kind = 18;
+ JjCheckNAddTwoStates(20, 21);
break;
- case 25:
+ case 27:
if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
- JjCheckNAddStates(9, 11);
+ JjCheckNAddStates(0, 2);
break;
- case 29:
+ case 28:
+ if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
+ JjCheckNAddStates(0, 2);
+ break;
+
+ case 32:
if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
break;
- if (kind > 20)
- kind = 20;
- JjCheckNAddTwoStates(29, 30);
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
+ break;
+
+ case 33:
+ if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
+ break;
+ if (kind > 21)
+ kind = 21;
+ JjCheckNAddTwoStates(33, 34);
break;
default: break;
@@ -534,7 +648,7 @@
kind = 0x7fffffff;
}
++curPos;
- if ((i = jjnewStateCnt) == (startsAt = 33 - (jjnewStateCnt = startsAt)))
+ if ((i = jjnewStateCnt) == (startsAt = 37 - (jjnewStateCnt = startsAt)))
return curPos;
try
{
@@ -552,10 +666,10 @@
{
case 0:
- if ((active0 & 0x10000000L) != 0L)
+ if ((active0 & 0x20000000L) != 0L)
{
- jjmatchedKind = 31;
- return 4;
+ jjmatchedKind = 32;
+ return 6;
}
return - 1;
@@ -588,10 +702,10 @@
{
case (char) (84):
- return JjMoveStringLiteralDfa1_1((ulong) 0x10000000L);
+ return JjMoveStringLiteralDfa1_1((ulong) 0x20000000L);
case (char) (125):
- return JjStopAtPos(0, 29);
+ return JjStopAtPos(0, 30);
default:
return JjMoveNfa_1(0, 0);
@@ -613,8 +727,8 @@
{
case (char) (79):
- if ((active0 & 0x10000000L) != 0L)
- return JjStartNfaWithStates_1(1, 28, 4);
+ if ((active0 & 0x20000000L) != 0L)
+ return JjStartNfaWithStates_1(1, 29, 6);
break;
default:
@@ -627,7 +741,7 @@
{
int[] nextStates;
int startsAt = 0;
- jjnewStateCnt = 5;
+ jjnewStateCnt = 7;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
@@ -647,9 +761,9 @@
case 0:
if ((0xfffffffeffffffffL & l) != (ulong) 0L)
{
- if (kind > 31)
- kind = 31;
- JjCheckNAdd(4);
+ if (kind > 32)
+ kind = 32;
+ JjCheckNAdd(6);
}
if ((0x100002600L & l) != (ulong) 0L)
{
@@ -657,30 +771,35 @@
kind = 6;
}
else if (curChar == 34)
- JjCheckNAdd(2);
+ JjCheckNAddTwoStates(2, 4);
break;
case 1:
if (curChar == 34)
- JjCheckNAdd(2);
+ JjCheckNAddTwoStates(2, 4);
break;
case 2:
if ((0xfffffffbffffffffL & l) != (ulong) 0L)
- JjCheckNAddTwoStates(2, 3);
+ JjCheckNAddStates(11, 13);
break;
case 3:
- if (curChar == 34 && kind > 30)
- kind = 30;
+ if (curChar == 34)
+ JjCheckNAddStates(11, 13);
break;
- case 4:
+ case 5:
+ if (curChar == 34 && kind > 31)
+ kind = 31;
+ break;
+
+ case 6:
if ((0xfffffffeffffffffL & l) == (ulong) 0L)
break;
- if (kind > 31)
- kind = 31;
- JjCheckNAdd(4);
+ if (kind > 32)
+ kind = 32;
+ JjCheckNAdd(6);
break;
default: break;
@@ -699,16 +818,21 @@
{
case 0:
- case 4:
+ case 6:
if ((0xdfffffffffffffffL & l) == (ulong) 0L)
break;
- if (kind > 31)
- kind = 31;
- JjCheckNAdd(4);
+ if (kind > 32)
+ kind = 32;
+ JjCheckNAdd(6);
break;
case 2:
- JjAddStates(17, 18);
+ JjAddStates(11, 13);
+ break;
+
+ case 4:
+ if (curChar == 92)
+ jjstateSet[jjnewStateCnt++] = 3;
break;
default: break;
@@ -731,17 +855,17 @@
{
case 0:
- case 4:
+ case 6:
if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
break;
- if (kind > 31)
- kind = 31;
- JjCheckNAdd(4);
+ if (kind > 32)
+ kind = 32;
+ JjCheckNAdd(6);
break;
case 2:
if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
- JjAddStates(17, 18);
+ JjAddStates(11, 13);
break;
default: break;
@@ -757,7 +881,7 @@
kind = 0x7fffffff;
}
++curPos;
- if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt)))
+ if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt)))
return curPos;
try
{
@@ -797,9 +921,9 @@
case 0:
if ((0x3ff000000000000L & l) == (ulong) 0L)
break;
- if (kind > 23)
- kind = 23;
- JjAddStates(19, 20);
+ if (kind > 24)
+ kind = 24;
+ JjAddStates(14, 15);
break;
case 1:
@@ -810,8 +934,8 @@
case 2:
if ((0x3ff000000000000L & l) == (ulong) 0L)
break;
- if (kind > 23)
- kind = 23;
+ if (kind > 24)
+ kind = 24;
JjCheckNAdd(2);
break;
@@ -880,10 +1004,10 @@
{
case 0:
- if ((active0 & 0x1000000L) != (ulong) 0L)
+ if ((active0 & 0x2000000L) != (ulong) 0L)
{
- jjmatchedKind = 27;
- return 4;
+ jjmatchedKind = 28;
+ return 6;
}
return - 1;
@@ -916,10 +1040,10 @@
{
case (char) (84):
- return JjMoveStringLiteralDfa1_2((ulong) 0x1000000L);
+ return JjMoveStringLiteralDfa1_2((ulong) 0x2000000L);
case (char) (93):
- return JjStopAtPos(0, 25);
+ return JjStopAtPos(0, 26);
default:
return JjMoveNfa_2(0, 0);
@@ -941,8 +1065,8 @@
{
case (char) (79):
- if ((active0 & 0x1000000L) != (ulong) 0L)
- return JjStartNfaWithStates_2(1, 24, 4);
+ if ((active0 & 0x2000000L) != (ulong) 0L)
+ return JjStartNfaWithStates_2(1, 25, 6);
break;
default:
@@ -955,7 +1079,7 @@
{
int[] nextStates;
int startsAt = 0;
- jjnewStateCnt = 5;
+ jjnewStateCnt = 7;
int i = 1;
jjstateSet[0] = startState;
int j, kind = 0x7fffffff;
@@ -975,9 +1099,9 @@
case 0:
if ((0xfffffffeffffffffL & l) != (ulong) 0L)
{
- if (kind > 27)
- kind = 27;
- JjCheckNAdd(4);
+ if (kind > 28)
+ kind = 28;
+ JjCheckNAdd(6);
}
if ((0x100002600L & l) != (ulong) 0L)
{
@@ -985,30 +1109,35 @@
kind = 6;
}
else if (curChar == 34)
- JjCheckNAdd(2);
+ JjCheckNAddTwoStates(2, 4);
break;
case 1:
if (curChar == 34)
- JjCheckNAdd(2);
+ JjCheckNAddTwoStates(2, 4);
break;
case 2:
if ((0xfffffffbffffffffL & l) != (ulong) 0L)
- JjCheckNAddTwoStates(2, 3);
+ JjCheckNAddStates(11, 13);
break;
case 3:
- if (curChar == 34 && kind > 26)
- kind = 26;
+ if (curChar == 34)
+ JjCheckNAddStates(11, 13);
break;
- case 4:
+ case 5:
+ if (curChar == 34 && kind > 27)
+ kind = 27;
+ break;
+
+ case 6:
if ((0xfffffffeffffffffL & l) == (ulong) 0L)
break;
- if (kind > 27)
- kind = 27;
- JjCheckNAdd(4);
+ if (kind > 28)
+ kind = 28;
+ JjCheckNAdd(6);
break;
default: break;
@@ -1027,16 +1156,21 @@
{
case 0:
- case 4:
+ case 6:
if ((0xffffffffdfffffffL & l) == (ulong) 0L)
break;
- if (kind > 27)
- kind = 27;
- JjCheckNAdd(4);
+ if (kind > 28)
+ kind = 28;
+ JjCheckNAdd(6);
break;
case 2:
- JjAddStates(17, 18);
+ JjAddStates(11, 13);
+ break;
+
+ case 4:
+ if (curChar == 92)
+ jjstateSet[jjnewStateCnt++] = 3;
break;
default: break;
@@ -1059,17 +1193,17 @@
{
case 0:
- case 4:
+ case 6:
if (!JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
break;
- if (kind > 27)
- kind = 27;
- JjCheckNAdd(4);
+ if (kind > 28)
+ kind = 28;
+ JjCheckNAdd(6);
break;
case 2:
if (JjCanMove_0(hiByte, i1, i2, (ulong) l1, (ulong) l2))
- JjAddStates(17, 18);
+ JjAddStates(11, 13);
break;
default: break;
@@ -1085,7 +1219,7 @@
kind = 0x7fffffff;
}
++curPos;
- if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt)))
+ if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt)))
return curPos;
try
{
@@ -1097,7 +1231,7 @@
}
}
}
- internal static readonly int[] jjnextStates = new int[]{22, 25, 26, 29, 30, 27, 23, 18, 19, 25, 26, 27, 24, 28, 31, 15, 16, 2, 3, 0, 1};
+ internal static readonly int[] jjnextStates = new int[]{28, 29, 30, 15, 17, 18, 24, 25, 22, 31, 35, 2, 4, 5, 0, 1};
private static bool JjCanMove_0(int hiByte, int i1, int i2, ulong l1, ulong l2)
{
switch (hiByte)
@@ -1113,14 +1247,14 @@
}
}
- public static readonly System.String[] jjstrLiteralImages = new System.String[]{"", null, null, null, null, null, null, null, null, null, "\x002B", "\x002D", "\x0028", "\x0029", "\x003A", "\x005E", null, null, null, null, null, "\x005B", "\x007B", null, "\x0054\x004F", "\x005D", null, null, "\x0054\x004F", "\x007D", null, null};
+ public static readonly System.String[] jjstrLiteralImages = new System.String[]{"", null, null, null, null, null, null, null, null, null, "\x002B", "\x002D", "\x0028", "\x0029", "\x003A", "\x002A", "\x005E", null, null, null, null, null, "\x005B", "\x007B", null, "\x0054\x004F", "\x005D", null, null, "\x0054\x004F", "\x007D", null, null};
public static readonly System.String[] lexStateNames = new System.String[]{"Boost", "RangeEx", "RangeIn", "DEFAULT"};
- public static readonly int[] jjnewLexState = new int[]{- 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, 0, - 1, - 1, - 1, - 1, - 1, 2, 1, 3, - 1, 3, - 1, - 1, - 1, 3, - 1, - 1};
- internal static readonly ulong[] jjtoToken = new ulong[]{0xffffff81L};
+ public static readonly int[] jjnewLexState = new int[]{- 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, 0, - 1, - 1, - 1, - 1, - 1, 2, 1, 3, - 1, 3, - 1, - 1, - 1, 3, - 1, - 1};
+ internal static readonly ulong[] jjtoToken = new ulong[]{0x1ffffff81L};
internal static readonly long[] jjtoSkip = new long[]{0x40L};
protected internal CharStream input_stream;
- private uint[] jjrounds = new uint[33];
- private int[] jjstateSet = new int[66];
+ private uint[] jjrounds = new uint[37];
+ private int[] jjstateSet = new int[74];
protected internal char curChar;
public QueryParserTokenManager(CharStream stream)
{
@@ -1142,7 +1276,7 @@
{
int i;
jjround = 0x80000001;
- for (i = 33; i-- > 0; )
+ for (i = 37; i-- > 0; )
jjrounds[i] = 0x80000000;
}
public virtual void ReInit(CharStream stream, int lexState)
@@ -1160,7 +1294,7 @@
protected internal virtual Token JjFillToken()
{
- Token t = Token.NewToken(jjmatchedKind);
+ Token t = Token.newToken(jjmatchedKind);
t.kind = jjmatchedKind;
System.String im = jjstrLiteralImages[jjmatchedKind];
t.image = (im == null) ? input_stream.GetImage() : im;
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Token.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/Token.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Token.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/Token.cs Tue May 1 11:45:26 2007
@@ -81,7 +81,7 @@
/// to the following switch statement. Then you can cast matchedToken
/// variable to the appropriate type and use it in your lexical actions.
/// </summary>
- public static Token NewToken(int ofKind)
+ public static Token newToken(int ofKind)
{
switch (ofKind)
{
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/TokenMgrError.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/QueryParser/TokenMgrError.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/TokenMgrError.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/QueryParser/TokenMgrError.cs Tue May 1 11:45:26 2007
@@ -23,7 +23,7 @@
{
[Serializable]
- public class TokenMgrError:System.ApplicationException
+ public class TokenMgrError : System.ApplicationException
{
/// <summary> You can also modify the body of this method to customize your error messages.
/// For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanClause.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/BooleanClause.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanClause.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanClause.cs Tue May 1 11:45:26 2007
@@ -16,6 +16,7 @@
*/
using System;
+
using Parameter = Lucene.Net.Util.Parameter;
namespace Lucene.Net.Search
@@ -26,8 +27,8 @@
public class BooleanClause
{
- /// <summary>Specifies how terms may occur in matching documents. </summary>
- [Serializable]
+ /// <summary>Specifies how clauses are to occur in matching documents. </summary>
+ [Serializable]
public sealed class Occur : Parameter
{
@@ -44,24 +45,24 @@
return "";
}
- /// <summary>Use this operator for terms that <i>must</i> appear in the matching documents. </summary>
+ /// <summary>Use this operator for clauses that <i>must</i> appear in the matching documents. </summary>
public static readonly Occur MUST = new Occur("MUST");
- /// <summary>Use this operator for terms that <i>should</i> appear in the
+ /// <summary>Use this operator for clauses that <i>should</i> appear in the
/// matching documents. For a BooleanQuery with two <code>SHOULD</code>
- /// subqueries, at least one of the queries must appear in the matching documents.
+ /// subqueries, at least one of the clauses must appear in the matching documents.
/// </summary>
public static readonly Occur SHOULD = new Occur("SHOULD");
- /// <summary>Use this operator for terms that <i>must not</i> appear in the matching documents.
+ /// <summary>Use this operator for clauses that <i>must not</i> appear in the matching documents.
/// Note that it is not possible to search for queries that only consist
- /// of a <code>MUST_NOT</code> query.
+ /// of a <code>MUST_NOT</code> clause.
/// </summary>
public static readonly Occur MUST_NOT = new Occur("MUST_NOT");
}
/// <summary>The query whose matching documents are combined by the boolean query.</summary>
- private Query query; // TODO: decrease visibility for Lucene 2.0
+ private Query query;
- private Occur occur = Occur.SHOULD;
+ private Occur occur;
/// <summary>Constructs a BooleanClause.</summary>
@@ -71,17 +72,17 @@
this.occur = occur;
}
- public virtual Occur GetOccur()
- {
- return occur;
- }
-
- public virtual void SetOccur(Occur occur)
- {
- this.occur = occur;
- }
+ public virtual Occur GetOccur()
+ {
+ return occur;
+ }
- public virtual Query GetQuery()
+ public virtual void SetOccur(Occur occur)
+ {
+ this.occur = occur;
+ }
+
+ public virtual Query GetQuery()
{
return query;
}
@@ -91,19 +92,19 @@
this.query = query;
}
- public virtual bool IsProhibited()
- {
- return Occur.MUST_NOT.Equals(occur);
- }
+ public virtual bool IsProhibited()
+ {
+ return Occur.MUST_NOT.Equals(occur);
+ }
- public virtual bool IsRequired()
- {
- return Occur.MUST.Equals(occur);
- }
+ public virtual bool IsRequired()
+ {
+ return Occur.MUST.Equals(occur);
+ }
- /// <summary>Returns true iff <code>o</code> is equal to this. </summary>
+ /// <summary>Returns true iff <code>o</code> is equal to this. </summary>
public override bool Equals(System.Object o)
{
if (!(o is BooleanClause))
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanQuery.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/BooleanQuery.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanQuery.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanQuery.cs Tue May 1 11:45:26 2007
@@ -16,8 +16,10 @@
*/
using System;
+
using IndexReader = Lucene.Net.Index.IndexReader;
using ToStringUtils = Lucene.Net.Util.ToStringUtils;
+using Occur = Lucene.Net.Search.BooleanClause.Occur;
namespace Lucene.Net.Search
{
@@ -65,13 +67,24 @@
[Serializable]
public class TooManyClauses : System.SystemException
{
+ public override System.String Message
+ {
+ get
+ {
+ return "maxClauseCount is set to " + Lucene.Net.Search.BooleanQuery.maxClauseCount;
+ }
+
+ }
+ public TooManyClauses()
+ {
+ }
}
/// <summary>Return the maximum number of clauses permitted, 1024 by default.
/// Attempts to add more than the permitted number of clauses cause {@link
/// TooManyClauses} to be thrown.
/// </summary>
- /// <seealso cref="SetMaxClauseCount(int)">
+ /// <seealso cref="#SetMaxClauseCount(int)">
/// </seealso>
public static int GetMaxClauseCount()
{
@@ -88,7 +101,7 @@
/// Filter. For example instead of a {@link RangeQuery} one can use a
/// {@link RangeFilter}.
/// <p>Normally the buffers are allocated by the JVM. When using for example
- /// {@link Lucene.Net.store.MMapDirectory} the buffering is left to
+ /// {@link Lucene.Net.Store.MMapDirectory} the buffering is left to
/// the operating system.
/// </summary>
public static void SetMaxClauseCount(int maxClauseCount)
@@ -98,7 +111,7 @@
BooleanQuery.maxClauseCount = maxClauseCount;
}
- private System.Collections.ArrayList clauses = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
+ private System.Collections.ArrayList clauses = new System.Collections.ArrayList();
private bool disableCoord;
/// <summary>Constructs an empty boolean query. </summary>
@@ -124,7 +137,7 @@
/// <summary>Returns true iff {@link Similarity#Coord(int,int)} is disabled in
/// scoring for this query instance.
/// </summary>
- /// <seealso cref="BooleanQuery(boolean)">
+ /// <seealso cref="#BooleanQuery(boolean)">
/// </seealso>
public virtual bool IsCoordDisabled()
{
@@ -165,7 +178,7 @@
/// </summary>
/// <param name="min">the number of optional clauses that must match
/// </param>
- /// <seealso cref="setUseScorer14">
+ /// <seealso cref="#setUseScorer14">
/// </seealso>
public virtual void SetMinimumNumberShouldMatch(int min)
{
@@ -185,7 +198,7 @@
///
/// </summary>
/// <throws> TooManyClauses if the new number of clauses exceeds the maximum clause number </throws>
- /// <seealso cref="GetMaxClauseCount()">
+ /// <seealso cref="#GetMaxClauseCount()">
/// </seealso>
public virtual void Add(Query query, BooleanClause.Occur occur)
{
@@ -194,7 +207,7 @@
/// <summary>Adds a clause to a boolean query.</summary>
/// <throws> TooManyClauses if the new number of clauses exceeds the maximum clause number </throws>
- /// <seealso cref="GetMaxClauseCount()">
+ /// <seealso cref="#GetMaxClauseCount()">
/// </seealso>
public virtual void Add(BooleanClause clause)
{
@@ -210,6 +223,12 @@
return (BooleanClause[]) clauses.ToArray(typeof(BooleanClause));
}
+ /// <summary>Returns the list of clauses in this query. </summary>
+ public virtual System.Collections.IList Clauses()
+ {
+ return clauses;
+ }
+
[Serializable]
private class BooleanWeight : Weight
{
@@ -256,8 +275,11 @@
{
BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
Weight w = (Weight) weights[i];
+ // call sumOfSquaredWeights for all clauses in case of side effects
+ float s = w.SumOfSquaredWeights(); // sum sub k
if (!c.IsProhibited())
- sum += w.SumOfSquaredWeights(); // sum sub weights
+ // only add to sum for non-prohibited clauses
+ sum += s;
}
sum *= Enclosing_Instance.GetBoost() * Enclosing_Instance.GetBoost(); // boost each sub-weight
@@ -273,8 +295,8 @@
{
BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
Weight w = (Weight) weights[i];
- if (!c.IsProhibited())
- w.Normalize(norm);
+ // normalize all clauses, (even if prohibited in case of side affects)
+ w.Normalize(norm);
}
}
@@ -333,11 +355,14 @@
public virtual Explanation Explain(IndexReader reader, int doc)
{
- Explanation sumExpl = new Explanation();
+ int minShouldMatch = Enclosing_Instance.GetMinimumNumberShouldMatch();
+ ComplexExplanation sumExpl = new ComplexExplanation();
sumExpl.SetDescription("sum of:");
int coord = 0;
int maxCoord = 0;
float sum = 0.0f;
+ bool fail = false;
+ int shouldMatchCount = 0;
for (int i = 0; i < weights.Count; i++)
{
BooleanClause c = (BooleanClause) Enclosing_Instance.clauses[i];
@@ -345,7 +370,7 @@
Explanation e = w.Explain(reader, doc);
if (!c.IsProhibited())
maxCoord++;
- if (e.GetValue() > 0)
+ if (e.IsMatch())
{
if (!c.IsProhibited())
{
@@ -355,19 +380,41 @@
}
else
{
- return new Explanation(0.0f, "match prohibited");
+ Explanation r = new Explanation(0.0f, "match on prohibited clause (" + c.GetQuery().ToString() + ")");
+ r.AddDetail(e);
+ sumExpl.AddDetail(r);
+ fail = true;
}
+ if (c.GetOccur().Equals(Occur.SHOULD))
+ shouldMatchCount++;
}
else if (c.IsRequired())
{
- return new Explanation(0.0f, "match required");
+ Explanation r = new Explanation(0.0f, "no match on required clause (" + c.GetQuery().ToString() + ")");
+ r.AddDetail(e);
+ sumExpl.AddDetail(r);
+ fail = true;
}
}
- sumExpl.SetValue(sum);
+ if (fail)
+ {
+ System.Boolean tempAux = false;
+ sumExpl.SetMatch(tempAux);
+ sumExpl.SetValue(0.0f);
+ sumExpl.SetDescription("Failure to meet condition(s) of required/prohibited clause(s)");
+ return sumExpl;
+ }
+ else if (shouldMatchCount < minShouldMatch)
+ {
+ System.Boolean tempAux2 = false;
+ sumExpl.SetMatch(tempAux2);
+ sumExpl.SetValue(0.0f);
+ sumExpl.SetDescription("Failure to match minimum number " + "of optional clauses: " + minShouldMatch);
+ return sumExpl;
+ }
- if (coord == 1)
- // only one clause matched
- sumExpl = sumExpl.GetDetails()[0]; // eliminate wrapper
+ sumExpl.SetMatch(0 < coord ? true : false);
+ sumExpl.SetValue(sum);
float coordFactor = similarity.Coord(coord, maxCoord);
if (coordFactor == 1.0f)
@@ -376,11 +423,9 @@
// eliminate wrapper
else
{
- Explanation result = new Explanation();
- result.SetDescription("product of:");
+ ComplexExplanation result = new ComplexExplanation(sumExpl.IsMatch(), sum * coordFactor, "product of:");
result.AddDetail(sumExpl);
result.AddDetail(new Explanation(coordFactor, "coord(" + coord + "/" + maxCoord + ")"));
- result.SetValue(sum * coordFactor);
return result;
}
}
@@ -576,29 +621,29 @@
if (!(o is BooleanQuery))
return false;
BooleanQuery other = (BooleanQuery) o;
- if (this.GetBoost() != other.GetBoost())
- return false;
- if (this.clauses.Count != other.clauses.Count)
- return false;
- for (int i = 0; i < this.clauses.Count; i++)
- {
- if (this.clauses[i].Equals(other.clauses[i]) == false)
- return false;
- }
+ if (this.GetBoost() != other.GetBoost())
+ return false;
+ if (this.clauses.Count != other.clauses.Count)
+ return false;
+ for (int i = 0; i < this.clauses.Count; i++)
+ {
+ if (this.clauses[i].Equals(other.clauses[i]) == false)
+ return false;
+ }
return this.GetMinimumNumberShouldMatch() == other.GetMinimumNumberShouldMatch();
}
/// <summary>Returns a hash code value for this object.</summary>
public override int GetHashCode()
{
- int hashCode = 0;
+ int hashCode = 0;
- for (int i = 0; i < clauses.Count; i++)
- {
- hashCode += clauses[i].GetHashCode();
- }
+ for (int i = 0; i < clauses.Count; i++)
+ {
+ hashCode += clauses[i].GetHashCode();
+ }
return BitConverter.ToInt32(BitConverter.GetBytes(GetBoost()), 0) ^ hashCode + GetMinimumNumberShouldMatch();
- }
+ }
}
}
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer2.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/BooleanScorer2.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer2.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/BooleanScorer2.cs Tue May 1 11:45:26 2007
@@ -48,25 +48,26 @@
private int lastScoredDoc = - 1;
public override float Score()
{
- if (Doc() > lastScoredDoc)
+ if (this.Doc() > lastScoredDoc)
{
- lastScoredDoc = Doc();
+ lastScoredDoc = this.Doc();
Enclosing_Instance.coordinator.nrMatchers += base.nrMatchers;
}
return base.Score();
}
}
-
- private class AnonymousClassConjunctionScorer : ConjunctionScorer
+
+ private class AnonymousClassConjunctionScorer : ConjunctionScorer
{
private void InitBlock(int requiredNrMatchers, BooleanScorer2 enclosingInstance)
{
this.requiredNrMatchers = requiredNrMatchers;
this.enclosingInstance = enclosingInstance;
}
+
private int requiredNrMatchers;
private BooleanScorer2 enclosingInstance;
-
+
public BooleanScorer2 Enclosing_Instance
{
get
@@ -83,9 +84,9 @@
public override float Score()
{
- if (Doc() > lastScoredDoc)
+ if (this.Doc() > lastScoredDoc)
{
- lastScoredDoc = Doc();
+ lastScoredDoc = this.Doc();
Enclosing_Instance.coordinator.nrMatchers += requiredNrMatchers;
}
// All scorers match, so defaultSimilarity super.score() always has 1 as
@@ -166,7 +167,7 @@
/// at least one of the optional scorers will have to
/// match during the search.
/// </param>
- public BooleanScorer2(Similarity similarity, int minNrShouldMatch):base(similarity)
+ public BooleanScorer2(Similarity similarity, int minNrShouldMatch) : base(similarity)
{
if (minNrShouldMatch < 0)
{
@@ -250,9 +251,9 @@
}
public override float Score()
{
- if (Doc() > lastScoredDoc)
+ if (this.Doc() > lastScoredDoc)
{
- lastScoredDoc = Doc();
+ lastScoredDoc = this.Doc();
Enclosing_Instance.coordinator.nrMatchers++;
}
return scorer.Score();
@@ -275,7 +276,7 @@
}
}
- private Scorer CountingDisjunctionSumScorer(System.Collections.IList scorers, int minMrShouldMatch)
+ private Scorer countingDisjunctionSumScorer(System.Collections.IList scorers, int minMrShouldMatch)
// each scorer from the list counted as a single matcher
{
return new AnonymousClassDisjunctionSumScorer(this, scorers, minMrShouldMatch);
@@ -283,7 +284,7 @@
private static Similarity defaultSimilarity = new DefaultSimilarity();
- private Scorer CountingConjunctionSumScorer(System.Collections.IList requiredScorers)
+ private Scorer countingConjunctionSumScorer(System.Collections.IList requiredScorers)
{
// each scorer from the list counted as a single matcher
int requiredNrMatchers = requiredScorers.Count;
@@ -299,7 +300,6 @@
private Scorer DualConjunctionSumScorer(Scorer req1, Scorer req2)
{
// non counting.
- //UPGRADE_NOTE: Final was removed from the declaration of 'requiredNrMatchers '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
int requiredNrMatchers = requiredScorers.Count;
ConjunctionScorer cs = new ConjunctionScorer(defaultSimilarity);
// All scorers match, so defaultSimilarity super.score() always has 1 as
@@ -339,7 +339,7 @@
else
{
// optionalScorers.size() >= nrOptRequired, no required scorers
- Scorer requiredCountingSumScorer = (optionalScorers.Count > nrOptRequired)?CountingDisjunctionSumScorer(optionalScorers, nrOptRequired):((optionalScorers.Count == 1)?new SingleMatchScorer(this, (Scorer) optionalScorers[0]):CountingConjunctionSumScorer(optionalScorers));
+ Scorer requiredCountingSumScorer = (optionalScorers.Count > nrOptRequired)?countingDisjunctionSumScorer(optionalScorers, nrOptRequired):((optionalScorers.Count == 1)?new SingleMatchScorer(this, (Scorer) optionalScorers[0]):countingConjunctionSumScorer(optionalScorers));
return AddProhibitedScorers(requiredCountingSumScorer);
}
}
@@ -357,21 +357,21 @@
// all optional scorers also required.
System.Collections.ArrayList allReq = new System.Collections.ArrayList(requiredScorers);
allReq.AddRange(optionalScorers);
- return AddProhibitedScorers(CountingConjunctionSumScorer(allReq));
+ return AddProhibitedScorers(countingConjunctionSumScorer(allReq));
}
else
{
// optionalScorers.size() > minNrShouldMatch, and at least one required scorer
- Scorer requiredCountingSumScorer = (requiredScorers.Count == 1)?new SingleMatchScorer(this, (Scorer) requiredScorers[0]):CountingConjunctionSumScorer(requiredScorers);
+ Scorer requiredCountingSumScorer = (requiredScorers.Count == 1) ? new SingleMatchScorer(this, (Scorer) requiredScorers[0]) : countingConjunctionSumScorer(requiredScorers);
if (minNrShouldMatch > 0)
{
// use a required disjunction scorer over the optional scorers
- return AddProhibitedScorers(DualConjunctionSumScorer(requiredCountingSumScorer, CountingDisjunctionSumScorer(optionalScorers, minNrShouldMatch)));
+ return AddProhibitedScorers(DualConjunctionSumScorer(requiredCountingSumScorer, countingDisjunctionSumScorer(optionalScorers, minNrShouldMatch)));
}
else
{
// minNrShouldMatch == 0
- return new ReqOptSumScorer(AddProhibitedScorers(requiredCountingSumScorer), ((optionalScorers.Count == 1)?new SingleMatchScorer(this, (Scorer) optionalScorers[0]):CountingDisjunctionSumScorer(optionalScorers, 1))); // require 1 in combined, optional scorer.
+ return new ReqOptSumScorer(AddProhibitedScorers(requiredCountingSumScorer), ((optionalScorers.Count == 1) ? new SingleMatchScorer(this, (Scorer) optionalScorers[0]):countingDisjunctionSumScorer(optionalScorers, 1))); // require 1 in combined, optional scorer.
}
}
}
@@ -383,7 +383,7 @@
/// </param>
private Scorer AddProhibitedScorers(Scorer requiredCountingSumScorer)
{
- return (prohibitedScorers.Count == 0)?requiredCountingSumScorer:new ReqExclScorer(requiredCountingSumScorer, ((prohibitedScorers.Count == 1)?(Scorer) prohibitedScorers[0]:new DisjunctionSumScorer(prohibitedScorers)));
+ return (prohibitedScorers.Count == 0) ? requiredCountingSumScorer : new ReqExclScorer(requiredCountingSumScorer, ((prohibitedScorers.Count == 1) ? (Scorer) prohibitedScorers[0] : new DisjunctionSumScorer(prohibitedScorers)));
}
/// <summary>Scores and collects all matching documents.</summary>
@@ -416,7 +416,7 @@
/// </returns>
protected internal override bool Score(HitCollector hc, int max)
{
- // null pointer exception when Next() was not called before:
+ // null pointer exception when next() was not called before:
int docNr = countingSumScorer.Doc();
while (docNr < max)
{
Modified: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/CachingWrapperFilter.cs?view=diff&rev=534192&r1=534191&r2=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingWrapperFilter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/CachingWrapperFilter.cs Tue May 1 11:45:26 2007
@@ -16,6 +16,7 @@
*/
using System;
+
using System.Runtime.InteropServices;
using IndexReader = Lucene.Net.Index.IndexReader;
@@ -28,7 +29,7 @@
/// caching, keeping the two concerns decoupled yet composable.
/// </summary>
[Serializable]
- public class CachingWrapperFilter:Filter
+ public class CachingWrapperFilter : Filter
{
private Filter filter;
Added: incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ComplexExplanation.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Lucene.Net/Search/ComplexExplanation.cs?view=auto&rev=534192
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ComplexExplanation.cs (added)
+++ incubator/lucene.net/trunk/C#/src/Lucene.Net/Search/ComplexExplanation.cs Tue May 1 11:45:26 2007
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Lucene.Net.Search
+{
+
+ /// <summary>Expert: Describes the score computation for document and query, andcan distinguish a match independent of a positive value. </summary>
+ [Serializable]
+ public class ComplexExplanation : Explanation
+ {
+ private System.Boolean match;
+ private bool isMatchSet;
+
+ public ComplexExplanation() : base()
+ {
+ }
+
+ public ComplexExplanation(bool match, float value_Renamed, System.String description) : base(value_Renamed, description)
+ {
+ this.match = match;
+ this.isMatchSet = true;
+ }
+
+ /// <summary> The match status of this explanation node.</summary>
+ /// <returns> May be null if match status is unknown
+ /// </returns>
+ public virtual System.Boolean GetMatch()
+ {
+ return match;
+ }
+ /// <summary> Sets the match status assigned to this explanation node.</summary>
+ /// <param name="match">May be null if match status is unknown
+ /// </param>
+ public virtual void SetMatch(System.Boolean match)
+ {
+ this.match = match;
+ this.isMatchSet = true;
+ }
+ /// <summary> Indicates wether or not this Explanation models a good match.
+ ///
+ /// <p>
+ /// If the match statis is explicitly set (ie: not null) this method
+ /// uses it; otherwise it defers to the superclass.
+ /// </p>
+ /// </summary>
+ /// <seealso cref="#GetMatch">
+ /// </seealso>
+ public override bool IsMatch()
+ {
+ System.Boolean m = GetMatch();
+ return (isMatchSet ? m : base.IsMatch());
+ }
+
+ protected internal override System.String GetSummary()
+ {
+ if (isMatchSet == false)
+ return base.GetSummary();
+
+ return GetValue() + " = " + (IsMatch() ? "(MATCH) " : "(NON-MATCH) ") + GetDescription();
+ }
+ }
+}
\ No newline at end of file