lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1344556 [2/3] - in /incubator/lucene.net/trunk: lib/NUnit.org/NUnit/2.5.9/samples/Extensibility/Core/Minimal/ lib/NUnit.org/NUnit/2.5.9/samples/Extensibility/Core/SampleFixtureExtension/ lib/NUnit.org/NUnit/2.5.9/samples/Extensibility/Core...
Date Thu, 31 May 2012 04:12:44 GMT
Modified: incubator/lucene.net/trunk/src/contrib/Highlighter/WeightedSpanTermExtractor.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Highlighter/WeightedSpanTermExtractor.cs?rev=1344556&r1=1344555&r2=1344556&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/contrib/Highlighter/WeightedSpanTermExtractor.cs (original)
+++ incubator/lucene.net/trunk/src/contrib/Highlighter/WeightedSpanTermExtractor.cs Thu May 31 04:12:43 2012
@@ -1,650 +1,650 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using Lucene.Net.Analysis;
-using Lucene.Net.Index;
-using Lucene.Net.Index.Memory;
-using Lucene.Net.Search.Spans;
-using Lucene.Net.Store;
-using Lucene.Net.Support;
-using Lucene.Net.Util;
-
-namespace Lucene.Net.Search.Highlight
-{
-    /// <summary>
-    /// Class used to extract <see cref="WeightedSpanTerm"/>s from a <see cref="Query"/> based on whether 
-    /// <see cref="Term"/>s from the <see cref="Query"/> are contained in a supplied <see cref="TokenStream"/>.
-    /// </summary>
-    public class WeightedSpanTermExtractor
-    {
-        private String fieldName;
-        private TokenStream tokenStream;
-        private IDictionary<String, IndexReader> readers = new HashMap<String, IndexReader>(10);
-        private String defaultField;
-        private bool expandMultiTermQuery;
-        private bool cachedTokenStream;
-        private bool wrapToCaching = true;
-
-        public WeightedSpanTermExtractor()
-        {
-        }
-
-        public WeightedSpanTermExtractor(String defaultField)
-        {
-            if (defaultField != null)
-            {
-                this.defaultField = StringHelper.Intern(defaultField);
-            }
-        }
-
-        private void CloseReaders()
-        {
-            ICollection<IndexReader> readerSet = readers.Values;
-
-            foreach (IndexReader reader in readerSet)
-            {
-                try
-                {
-                    reader.Close();
-                }
-                catch (IOException e)
-                {
-                    // alert?
-                }
-            }
-        }
-
-        /// <summary>
-        /// Fills a <c>Map</c> with <see cref="WeightedSpanTerm"/>s using the terms from the supplied <c>Query</c>.
-        /// </summary>
-        /// <param name="query">Query to extract Terms from</param>
-        /// <param name="terms">Map to place created WeightedSpanTerms in</param>
-        private void Extract(Query query, IDictionary<String, WeightedSpanTerm> terms)
-        {
-            if (query is BooleanQuery)
-            {
-                BooleanClause[] queryClauses = ((BooleanQuery) query).GetClauses();
-
-                for (int i = 0; i < queryClauses.Length; i++)
-                {
-                    if (!queryClauses[i].IsProhibited)
-                    {
-                        Extract(queryClauses[i].Query, terms);
-                    }
-                }
-            }
-            else if (query is PhraseQuery)
-            {
-                PhraseQuery phraseQuery = ((PhraseQuery) query);
-                Term[] phraseQueryTerms = phraseQuery.GetTerms();
-                SpanQuery[] clauses = new SpanQuery[phraseQueryTerms.Length];
-                for (int i = 0; i < phraseQueryTerms.Length; i++)
-                {
-                    clauses[i] = new SpanTermQuery(phraseQueryTerms[i]);
-                }
-                int slop = phraseQuery.Slop;
-                int[] positions = phraseQuery.GetPositions();
-                // add largest position increment to slop
-                if (positions.Length > 0)
-                {
-                    int lastPos = positions[0];
-                    int largestInc = 0;
-                    int sz = positions.Length;
-                    for (int i = 1; i < sz; i++)
-                    {
-                        int pos = positions[i];
-                        int inc = pos - lastPos;
-                        if (inc > largestInc)
-                        {
-                            largestInc = inc;
-                        }
-                        lastPos = pos;
-                    }
-                    if (largestInc > 1)
-                    {
-                        slop += largestInc;
-                    }
-                }
-
-                bool inorder = slop == 0;
-
-                SpanNearQuery sp = new SpanNearQuery(clauses, slop, inorder);
-                sp.Boost = query.Boost;
-                ExtractWeightedSpanTerms(terms, sp);
-            }
-            else if (query is TermQuery)
-            {
-                ExtractWeightedTerms(terms, query);
-            }
-            else if (query is SpanQuery)
-            {
-                ExtractWeightedSpanTerms(terms, (SpanQuery) query);
-            }
-            else if (query is FilteredQuery)
-            {
-                Extract(((FilteredQuery) query).Query, terms);
-            }
-            else if (query is DisjunctionMaxQuery)
-            {
-                foreach (var q in ((DisjunctionMaxQuery) query))
-                {
-                    Extract(q, terms);
-                }
-            }
-            else if (query is MultiTermQuery && expandMultiTermQuery)
-            {
-                MultiTermQuery mtq = ((MultiTermQuery) query);
-                if (mtq.RewriteMethod != MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE)
-                {
-                    mtq = (MultiTermQuery) mtq.Clone();
-                    mtq.RewriteMethod = MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE;
-                    query = mtq;
-                }
-                FakeReader fReader = new FakeReader();
-                MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE.Rewrite(fReader, mtq);
-                if (fReader.Field != null)
-                {
-                    IndexReader ir = GetReaderForField(fReader.Field);
-                    Extract(query.Rewrite(ir), terms);
-                }
-            }
-            else if (query is MultiPhraseQuery)
-            {
-                MultiPhraseQuery mpq = (MultiPhraseQuery) query;
-                IList<Term[]> termArrays = mpq.GetTermArrays();
-                int[] positions = mpq.GetPositions();
-                if (positions.Length > 0)
-                {
-
-                    int maxPosition = positions[positions.Length - 1];
-                    for (int i = 0; i < positions.Length - 1; ++i)
-                    {
-                        if (positions[i] > maxPosition)
-                        {
-                            maxPosition = positions[i];
-                        }
-                    }
-
-                    var disjunctLists = new List<SpanQuery>[maxPosition + 1];
-                    int distinctPositions = 0;
-
-                    for (int i = 0; i < termArrays.Count; ++i)
-                    {
-                        Term[] termArray = termArrays[i];
-                        List<SpanQuery> disjuncts = disjunctLists[positions[i]];
-                        if (disjuncts == null)
-                        {
-                            disjuncts = (disjunctLists[positions[i]] = new List<SpanQuery>(termArray.Length));
-                            ++distinctPositions;
-                        }
-                        for (int j = 0; j < termArray.Length; ++j)
-                        {
-                            disjuncts.Add(new SpanTermQuery(termArray[j]));
-                        }
-                    }
-
-                    int positionGaps = 0;
-                    int position = 0;
-                    SpanQuery[] clauses = new SpanQuery[distinctPositions];
-                    for (int i = 0; i < disjunctLists.Length; ++i)
-                    {
-                        List<SpanQuery> disjuncts = disjunctLists[i];
-                        if (disjuncts != null)
-                        {
-                            clauses[position++] = new SpanOrQuery(disjuncts.ToArray());
-                        }
-                        else
-                        {
-                            ++positionGaps;
-                        }
-                    }
-
-                    int slop = mpq.Slop;
-                    bool inorder = (slop == 0);
-
-                    SpanNearQuery sp = new SpanNearQuery(clauses, slop + positionGaps, inorder);
-                    sp.Boost = query.Boost;
-                    ExtractWeightedSpanTerms(terms, sp);
-                }
-            }
-        }
-
-        /// <summary>
-        /// Fills a <c>Map</c> with <see cref="WeightedSpanTerm"/>s using the terms from the supplied <c>SpanQuery</c>.
-        /// </summary>
-        /// <param name="terms">Map to place created WeightedSpanTerms in</param>
-        /// <param name="spanQuery">SpanQuery to extract Terms from</param>
-        private void ExtractWeightedSpanTerms(IDictionary<String, WeightedSpanTerm> terms, SpanQuery spanQuery)
-        {
-            HashSet<String> fieldNames;
-
-            if (fieldName == null)
-            {
-                fieldNames = new HashSet<String>();
-                CollectSpanQueryFields(spanQuery, fieldNames);
-            }
-            else
-            {
-                fieldNames = new HashSet<String>();
-                fieldNames.Add(fieldName);
-            }
-            // To support the use of the default field name
-            if (defaultField != null)
-            {
-                fieldNames.Add(defaultField);
-            }
-
-            IDictionary<String, SpanQuery> queries = new HashMap<String, SpanQuery>();
-
-            HashSet<Term> nonWeightedTerms = new HashSet<Term>();
-            bool mustRewriteQuery = MustRewriteQuery(spanQuery);
-            if (mustRewriteQuery)
-            {
-                foreach (String field in fieldNames)
-                {
-                    SpanQuery rewrittenQuery = (SpanQuery) spanQuery.Rewrite(GetReaderForField(field));
-                    queries[field] = rewrittenQuery;
-                    rewrittenQuery.ExtractTerms(nonWeightedTerms);
-                }
-            }
-            else
-            {
-                spanQuery.ExtractTerms(nonWeightedTerms);
-            }
-
-            List<PositionSpan> spanPositions = new List<PositionSpan>();
-
-            foreach (String field in fieldNames)
-            {
-
-                IndexReader reader = GetReaderForField(field);
-                Spans.Spans spans;
-                if (mustRewriteQuery)
-                {
-                    spans = queries[field].GetSpans(reader);
-                }
-                else
-                {
-                    spans = spanQuery.GetSpans(reader);
-                }
-
-
-                // collect span positions
-                while (spans.Next())
-                {
-                    spanPositions.Add(new PositionSpan(spans.Start(), spans.End() - 1));
-                }
-
-            }
-
-            if (spanPositions.Count == 0)
-            {
-                // no spans found
-                return;
-            }
-
-            foreach (Term queryTerm in nonWeightedTerms)
-            {
-
-                if (FieldNameComparator(queryTerm.Field))
-                {
-                    WeightedSpanTerm weightedSpanTerm = terms[queryTerm.Text];
-
-                    if (weightedSpanTerm == null)
-                    {
-                        weightedSpanTerm = new WeightedSpanTerm(spanQuery.Boost, queryTerm.Text);
-                        weightedSpanTerm.AddPositionSpans(spanPositions);
-                        weightedSpanTerm.SetPositionSensitive(true);
-                        terms[queryTerm.Text] = weightedSpanTerm;
-                    }
-                    else
-                    {
-                        if (spanPositions.Count > 0)
-                        {
-                            weightedSpanTerm.AddPositionSpans(spanPositions);
-                        }
-                    }
-                }
-            }
-        }
-
-        /// <summary>
-        /// Fills a <c>Map</c> with <see cref="WeightedSpanTerm"/>s using the terms from the supplied <c>Query</c>.
-        /// </summary>
-        /// <param name="terms"></param>
-        /// <param name="query"></param>
-        private void ExtractWeightedTerms(IDictionary<String, WeightedSpanTerm> terms, Query query)
-        {
-            HashSet<Term> nonWeightedTerms = new HashSet<Term>();
-            query.ExtractTerms(nonWeightedTerms);
-
-            foreach (Term queryTerm in nonWeightedTerms)
-            {
-
-                if (FieldNameComparator(queryTerm.Field))
-                {
-                    WeightedSpanTerm weightedSpanTerm = new WeightedSpanTerm(query.Boost, queryTerm.Text);
-                    terms[queryTerm.Text] = weightedSpanTerm;
-                }
-            }
-        }
-
-        /// <summary>
-        /// Necessary to implement matches for queries against <code>defaultField</code>
-        /// </summary>
-        private bool FieldNameComparator(String fieldNameToCheck)
-        {
-            bool rv = fieldName == null || fieldNameToCheck == fieldName
-                      || fieldNameToCheck == defaultField;
-            return rv;
-        }
-
-        private IndexReader GetReaderForField(String field)
-        {
-            if (wrapToCaching && !cachedTokenStream && !(tokenStream is CachingTokenFilter))
-            {
-                tokenStream = new CachingTokenFilter(tokenStream);
-                cachedTokenStream = true;
-            }
-            IndexReader reader = readers[field];
-            if (reader == null)
-            {
-                MemoryIndex indexer = new MemoryIndex();
-                indexer.AddField(field, tokenStream);
-                tokenStream.Reset();
-                IndexSearcher searcher = indexer.CreateSearcher();
-                reader = searcher.IndexReader;
-                readers[field] = reader;
-            }
-
-            return reader;
-        }
-
-        /// <summary>
-        /// Creates a Map of <c>WeightedSpanTerms</c> from the given <c>Query</c> and <c>TokenStream</c>.
-        /// </summary>
-        /// <param name="query">query that caused hit</param>
-        /// <param name="tokenStream">TokenStream of text to be highlighted</param>
-        /// <returns>Map containing WeightedSpanTerms</returns>
-        public IDictionary<String, WeightedSpanTerm> GetWeightedSpanTerms(Query query, TokenStream tokenStream)
-        {
-            return GetWeightedSpanTerms(query, tokenStream, null);
-        }
-
-
-        /// <summary>
-        /// Creates a Map of <c>WeightedSpanTerms</c> from the given <c>Query</c> and <c>TokenStream</c>.
-        /// </summary>
-        /// <param name="query">query that caused hit</param>
-        /// <param name="tokenStream">tokenStream of text to be highlighted</param>
-        /// <param name="fieldName">restricts Term's used based on field name</param>
-        /// <returns>Map containing WeightedSpanTerms</returns>
-        public IDictionary<String, WeightedSpanTerm> GetWeightedSpanTerms(Query query, TokenStream tokenStream,
-                                                                          String fieldName)
-        {
-            if (fieldName != null)
-            {
-                this.fieldName = StringHelper.Intern(fieldName);
-            }
-            else
-            {
-                this.fieldName = null;
-            }
-
-            IDictionary<String, WeightedSpanTerm> terms = new PositionCheckingMap<String>();
-            this.tokenStream = tokenStream;
-            try
-            {
-                Extract(query, terms);
-            }
-            finally
-            {
-                CloseReaders();
-            }
-
-            return terms;
-        }
-
-        /// <summary>
-        /// Creates a Map of <c>WeightedSpanTerms</c> from the given <c>Query</c> and <c>TokenStream</c>. Uses a supplied
-        /// <c>IndexReader</c> to properly Weight terms (for gradient highlighting).
-        /// </summary>
-        /// <param name="query">Query that caused hit</param>
-        /// <param name="tokenStream">Tokenstream of text to be highlighted</param>
-        /// <param name="fieldName">restricts Term's used based on field name</param>
-        /// <param name="reader">to use for scoring</param>
-        /// <returns>Map of WeightedSpanTerms with quasi tf/idf scores</returns>
-        public IDictionary<String, WeightedSpanTerm> GetWeightedSpanTermsWithScores(Query query, TokenStream tokenStream,
-                                                                                    String fieldName, IndexReader reader)
-        {
-            if (fieldName != null)
-            {
-                this.fieldName = StringHelper.Intern(fieldName);
-            }
-            else
-            {
-                this.fieldName = null;
-            }
-            this.tokenStream = tokenStream;
-
-            IDictionary<String, WeightedSpanTerm> terms = new PositionCheckingMap<String>();
-            Extract(query, terms);
-
-            int totalNumDocs = reader.NumDocs();
-            var weightedTerms = terms.Keys;
-
-            try
-            {
-                foreach (var wt in weightedTerms)
-                {
-                    WeightedSpanTerm weightedSpanTerm = terms[wt];
-                    int docFreq = reader.DocFreq(new Term(fieldName, weightedSpanTerm.Term));
-                    // docFreq counts deletes
-                    if (totalNumDocs < docFreq)
-                    {
-                        docFreq = totalNumDocs;
-                    }
-                    // IDF algorithm taken from DefaultSimilarity class
-                    float idf = (float) (Math.Log((float) totalNumDocs/(double) (docFreq + 1)) + 1.0);
-                    weightedSpanTerm.Weight *= idf;
-                }
-            }
-            finally
-            {
-
-                CloseReaders();
-            }
-
-            return terms;
-        }
-
-        private void CollectSpanQueryFields(SpanQuery spanQuery, HashSet<String> fieldNames)
-        {
-            if (spanQuery is FieldMaskingSpanQuery)
-            {
-                CollectSpanQueryFields(((FieldMaskingSpanQuery) spanQuery).MaskedQuery, fieldNames);
-            }
-            else if (spanQuery is SpanFirstQuery)
-            {
-                CollectSpanQueryFields(((SpanFirstQuery) spanQuery).Match, fieldNames);
-            }
-            else if (spanQuery is SpanNearQuery)
-            {
-                foreach (SpanQuery clause in ((SpanNearQuery) spanQuery).GetClauses())
-                {
-                    CollectSpanQueryFields(clause, fieldNames);
-                }
-            }
-            else if (spanQuery is SpanNotQuery)
-            {
-                CollectSpanQueryFields(((SpanNotQuery) spanQuery).Include, fieldNames);
-            }
-            else if (spanQuery is SpanOrQuery)
-            {
-                foreach (SpanQuery clause in ((SpanOrQuery) spanQuery).GetClauses())
-                {
-                    CollectSpanQueryFields(clause, fieldNames);
-                }
-            }
-            else
-            {
-                fieldNames.Add(spanQuery.Field);
-            }
-        }
-
-        private bool MustRewriteQuery(SpanQuery spanQuery)
-        {
-            if (!expandMultiTermQuery)
-            {
-                return false; // Will throw UnsupportedOperationException in case of a SpanRegexQuery.
-            }
-            else if (spanQuery is FieldMaskingSpanQuery)
-            {
-                return MustRewriteQuery(((FieldMaskingSpanQuery)spanQuery).MaskedQuery);
-            }
-            else if (spanQuery is SpanFirstQuery)
-            {
-                return MustRewriteQuery(((SpanFirstQuery)spanQuery).Match);
-            }
-            else if (spanQuery is SpanNearQuery)
-            {
-                foreach (SpanQuery clause in ((SpanNearQuery) spanQuery).GetClauses())
-                {
-                    if (MustRewriteQuery(clause))
-                    {
-                        return true;
-                    }
-                }
-                return false;
-            }
-            else if (spanQuery is SpanNotQuery)
-            {
-                SpanNotQuery spanNotQuery = (SpanNotQuery) spanQuery;
-                return MustRewriteQuery(spanNotQuery.Include) || MustRewriteQuery(spanNotQuery.Exclude);
-            }
-            else if (spanQuery is SpanOrQuery)
-            {
-                foreach (SpanQuery clause in ((SpanOrQuery) spanQuery).GetClauses())
-                {
-                    if (MustRewriteQuery(clause))
-                    {
-                        return true;
-                    }
-                }
-                return false;
-            }
-            else if (spanQuery is SpanTermQuery)
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
-
-        
-        /// <summary>
-        /// This class makes sure that if both position sensitive and insensitive
-        /// versions of the same term are added, the position insensitive one wins.
-        /// </summary>
-        /// <typeparam name="K"></typeparam>
-        private class PositionCheckingMap<K> : HashMap<K, WeightedSpanTerm>
-        {
-            public PositionCheckingMap()
-            {
-
-            }
-
-            public PositionCheckingMap(IEnumerable<KeyValuePair<K, WeightedSpanTerm>> m)
-            {
-                PutAll(m);
-            }
-
-            public void PutAll(IEnumerable<KeyValuePair<K, WeightedSpanTerm>> m)
-            {
-                foreach (var entry in m)
-                {
-                    Add(entry.Key, entry.Value);
-                }
-            }
-
-            public override void Add(K key, WeightedSpanTerm value)
-            {
-                base.Add(key, value);
-                WeightedSpanTerm prev = this[key];
-
-                if (prev == null) return;
-
-                WeightedSpanTerm prevTerm = prev;
-                WeightedSpanTerm newTerm = value;
-                if (!prevTerm.IsPositionSensitive())
-                {
-                    newTerm.SetPositionSensitive(false);
-                }
-            }
-
-        }
-
-        public bool GetExpandMultiTermQuery()
-        {
-            return expandMultiTermQuery;
-        }
-
-        public void SetExpandMultiTermQuery(bool expandMultiTermQuery)
-        {
-            this.expandMultiTermQuery = expandMultiTermQuery;
-        }
-
-        public bool IsCachedTokenStream()
-        {
-            return cachedTokenStream;
-        }
-
-        public TokenStream GetTokenStream()
-        {
-            return tokenStream;
-        }
-
-
-        /// <summary>
-        /// By default, <see cref="TokenStream"/>s that are not of the type
-        /// <see cref="CachingTokenFilter"/> are wrapped in a <see cref="CachingTokenFilter"/> to
-        /// <see cref="TokenStream"/> impl and you don't want it to be wrapped, set this to
-        /// false.
-        /// </summary>
-        public void SetWrapIfNotCachingTokenFilter(bool wrap)
-        {
-            this.wrapToCaching = wrap;
-        }
-
-        /// <summary>
-        /// A fake IndexReader class to extract the field from a MultiTermQuery
-        /// </summary>
-        protected internal sealed class FakeReader : FilterIndexReader
-        {
-
-            private static IndexReader EMPTY_MEMORY_INDEX_READER = new MemoryIndex().CreateSearcher().IndexReader;
-
-            public String Field { get; private set; }
-
-            protected internal FakeReader()
-                : base(EMPTY_MEMORY_INDEX_READER)
-            {
-
-            }
-
-            public override TermEnum Terms(Term t)
-            {
-                // only set first fieldname, maybe use a Set?
-                if (t != null && Field == null)
-                    Field = t.Field;
-                return base.Terms(t);
-            }
-
-
-        }
-    }
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Lucene.Net.Analysis;
+using Lucene.Net.Index;
+using Lucene.Net.Index.Memory;
+using Lucene.Net.Search.Spans;
+using Lucene.Net.Store;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Search.Highlight
+{
+    /// <summary>
+    /// Class used to extract <see cref="WeightedSpanTerm"/>s from a <see cref="Query"/> based on whether 
+    /// <see cref="Term"/>s from the <see cref="Query"/> are contained in a supplied <see cref="TokenStream"/>.
+    /// </summary>
+    public class WeightedSpanTermExtractor
+    {
+        private String fieldName;
+        private TokenStream tokenStream;
+        private IDictionary<String, IndexReader> readers = new HashMap<String, IndexReader>(10);
+        private String defaultField;
+        private bool expandMultiTermQuery;
+        private bool cachedTokenStream;
+        private bool wrapToCaching = true;
+
+        public WeightedSpanTermExtractor()
+        {
+        }
+
+        public WeightedSpanTermExtractor(String defaultField)
+        {
+            if (defaultField != null)
+            {
+                this.defaultField = StringHelper.Intern(defaultField);
+            }
+        }
+
+        private void CloseReaders()
+        {
+            ICollection<IndexReader> readerSet = readers.Values;
+
+            foreach (IndexReader reader in readerSet)
+            {
+                try
+                {
+                    reader.Close();
+                }
+                catch (IOException e)
+                {
+                    // alert?
+                }
+            }
+        }
+
+        /// <summary>
+        /// Fills a <c>Map</c> with <see cref="WeightedSpanTerm"/>s using the terms from the supplied <c>Query</c>.
+        /// </summary>
+        /// <param name="query">Query to extract Terms from</param>
+        /// <param name="terms">Map to place created WeightedSpanTerms in</param>
+        private void Extract(Query query, IDictionary<String, WeightedSpanTerm> terms)
+        {
+            if (query is BooleanQuery)
+            {
+                BooleanClause[] queryClauses = ((BooleanQuery) query).GetClauses();
+
+                for (int i = 0; i < queryClauses.Length; i++)
+                {
+                    if (!queryClauses[i].IsProhibited)
+                    {
+                        Extract(queryClauses[i].Query, terms);
+                    }
+                }
+            }
+            else if (query is PhraseQuery)
+            {
+                PhraseQuery phraseQuery = ((PhraseQuery) query);
+                Term[] phraseQueryTerms = phraseQuery.GetTerms();
+                SpanQuery[] clauses = new SpanQuery[phraseQueryTerms.Length];
+                for (int i = 0; i < phraseQueryTerms.Length; i++)
+                {
+                    clauses[i] = new SpanTermQuery(phraseQueryTerms[i]);
+                }
+                int slop = phraseQuery.Slop;
+                int[] positions = phraseQuery.GetPositions();
+                // add largest position increment to slop
+                if (positions.Length > 0)
+                {
+                    int lastPos = positions[0];
+                    int largestInc = 0;
+                    int sz = positions.Length;
+                    for (int i = 1; i < sz; i++)
+                    {
+                        int pos = positions[i];
+                        int inc = pos - lastPos;
+                        if (inc > largestInc)
+                        {
+                            largestInc = inc;
+                        }
+                        lastPos = pos;
+                    }
+                    if (largestInc > 1)
+                    {
+                        slop += largestInc;
+                    }
+                }
+
+                bool inorder = slop == 0;
+
+                SpanNearQuery sp = new SpanNearQuery(clauses, slop, inorder);
+                sp.Boost = query.Boost;
+                ExtractWeightedSpanTerms(terms, sp);
+            }
+            else if (query is TermQuery)
+            {
+                ExtractWeightedTerms(terms, query);
+            }
+            else if (query is SpanQuery)
+            {
+                ExtractWeightedSpanTerms(terms, (SpanQuery) query);
+            }
+            else if (query is FilteredQuery)
+            {
+                Extract(((FilteredQuery) query).Query, terms);
+            }
+            else if (query is DisjunctionMaxQuery)
+            {
+                foreach (var q in ((DisjunctionMaxQuery) query))
+                {
+                    Extract(q, terms);
+                }
+            }
+            else if (query is MultiTermQuery && expandMultiTermQuery)
+            {
+                MultiTermQuery mtq = ((MultiTermQuery) query);
+                if (mtq.RewriteMethod != MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE)
+                {
+                    mtq = (MultiTermQuery) mtq.Clone();
+                    mtq.RewriteMethod = MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE;
+                    query = mtq;
+                }
+                FakeReader fReader = new FakeReader();
+                MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE.Rewrite(fReader, mtq);
+                if (fReader.Field != null)
+                {
+                    IndexReader ir = GetReaderForField(fReader.Field);
+                    Extract(query.Rewrite(ir), terms);
+                }
+            }
+            else if (query is MultiPhraseQuery)
+            {
+                MultiPhraseQuery mpq = (MultiPhraseQuery) query;
+                IList<Term[]> termArrays = mpq.GetTermArrays();
+                int[] positions = mpq.GetPositions();
+                if (positions.Length > 0)
+                {
+
+                    int maxPosition = positions[positions.Length - 1];
+                    for (int i = 0; i < positions.Length - 1; ++i)
+                    {
+                        if (positions[i] > maxPosition)
+                        {
+                            maxPosition = positions[i];
+                        }
+                    }
+
+                    var disjunctLists = new List<SpanQuery>[maxPosition + 1];
+                    int distinctPositions = 0;
+
+                    for (int i = 0; i < termArrays.Count; ++i)
+                    {
+                        Term[] termArray = termArrays[i];
+                        List<SpanQuery> disjuncts = disjunctLists[positions[i]];
+                        if (disjuncts == null)
+                        {
+                            disjuncts = (disjunctLists[positions[i]] = new List<SpanQuery>(termArray.Length));
+                            ++distinctPositions;
+                        }
+                        for (int j = 0; j < termArray.Length; ++j)
+                        {
+                            disjuncts.Add(new SpanTermQuery(termArray[j]));
+                        }
+                    }
+
+                    int positionGaps = 0;
+                    int position = 0;
+                    SpanQuery[] clauses = new SpanQuery[distinctPositions];
+                    for (int i = 0; i < disjunctLists.Length; ++i)
+                    {
+                        List<SpanQuery> disjuncts = disjunctLists[i];
+                        if (disjuncts != null)
+                        {
+                            clauses[position++] = new SpanOrQuery(disjuncts.ToArray());
+                        }
+                        else
+                        {
+                            ++positionGaps;
+                        }
+                    }
+
+                    int slop = mpq.Slop;
+                    bool inorder = (slop == 0);
+
+                    SpanNearQuery sp = new SpanNearQuery(clauses, slop + positionGaps, inorder);
+                    sp.Boost = query.Boost;
+                    ExtractWeightedSpanTerms(terms, sp);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Fills a <c>Map</c> with <see cref="WeightedSpanTerm"/>s using the terms from the supplied <c>SpanQuery</c>.
+        /// </summary>
+        /// <param name="terms">Map to place created WeightedSpanTerms in</param>
+        /// <param name="spanQuery">SpanQuery to extract Terms from</param>
+        private void ExtractWeightedSpanTerms(IDictionary<String, WeightedSpanTerm> terms, SpanQuery spanQuery)
+        {
+            HashSet<String> fieldNames;
+
+            if (fieldName == null)
+            {
+                fieldNames = new HashSet<String>();
+                CollectSpanQueryFields(spanQuery, fieldNames);
+            }
+            else
+            {
+                fieldNames = new HashSet<String>();
+                fieldNames.Add(fieldName);
+            }
+            // To support the use of the default field name
+            if (defaultField != null)
+            {
+                fieldNames.Add(defaultField);
+            }
+
+            IDictionary<String, SpanQuery> queries = new HashMap<String, SpanQuery>();
+
+            HashSet<Term> nonWeightedTerms = new HashSet<Term>();
+            bool mustRewriteQuery = MustRewriteQuery(spanQuery);
+            if (mustRewriteQuery)
+            {
+                foreach (String field in fieldNames)
+                {
+                    SpanQuery rewrittenQuery = (SpanQuery) spanQuery.Rewrite(GetReaderForField(field));
+                    queries[field] = rewrittenQuery;
+                    rewrittenQuery.ExtractTerms(nonWeightedTerms);
+                }
+            }
+            else
+            {
+                spanQuery.ExtractTerms(nonWeightedTerms);
+            }
+
+            List<PositionSpan> spanPositions = new List<PositionSpan>();
+
+            foreach (String field in fieldNames)
+            {
+
+                IndexReader reader = GetReaderForField(field);
+                Spans.Spans spans;
+                if (mustRewriteQuery)
+                {
+                    spans = queries[field].GetSpans(reader);
+                }
+                else
+                {
+                    spans = spanQuery.GetSpans(reader);
+                }
+
+
+                // collect span positions
+                while (spans.Next())
+                {
+                    spanPositions.Add(new PositionSpan(spans.Start(), spans.End() - 1));
+                }
+
+            }
+
+            if (spanPositions.Count == 0)
+            {
+                // no spans found
+                return;
+            }
+
+            foreach (Term queryTerm in nonWeightedTerms)
+            {
+
+                if (FieldNameComparator(queryTerm.Field))
+                {
+                    WeightedSpanTerm weightedSpanTerm = terms[queryTerm.Text];
+
+                    if (weightedSpanTerm == null)
+                    {
+                        weightedSpanTerm = new WeightedSpanTerm(spanQuery.Boost, queryTerm.Text);
+                        weightedSpanTerm.AddPositionSpans(spanPositions);
+                        weightedSpanTerm.SetPositionSensitive(true);
+                        terms[queryTerm.Text] = weightedSpanTerm;
+                    }
+                    else
+                    {
+                        if (spanPositions.Count > 0)
+                        {
+                            weightedSpanTerm.AddPositionSpans(spanPositions);
+                        }
+                    }
+                }
+            }
+        }
+
+        /// <summary>
+        /// Fills a <c>Map</c> with <see cref="WeightedSpanTerm"/>s using the terms from the supplied <c>Query</c>.
+        /// </summary>
+        /// <param name="terms"></param>
+        /// <param name="query"></param>
+        private void ExtractWeightedTerms(IDictionary<String, WeightedSpanTerm> terms, Query query)
+        {
+            HashSet<Term> nonWeightedTerms = new HashSet<Term>();
+            query.ExtractTerms(nonWeightedTerms);
+
+            foreach (Term queryTerm in nonWeightedTerms)
+            {
+
+                if (FieldNameComparator(queryTerm.Field))
+                {
+                    WeightedSpanTerm weightedSpanTerm = new WeightedSpanTerm(query.Boost, queryTerm.Text);
+                    terms[queryTerm.Text] = weightedSpanTerm;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Necessary to implement matches for queries against <code>defaultField</code>
+        /// </summary>
+        private bool FieldNameComparator(String fieldNameToCheck)
+        {
+            bool rv = fieldName == null || fieldNameToCheck == fieldName
+                      || fieldNameToCheck == defaultField;
+            return rv;
+        }
+
+        private IndexReader GetReaderForField(String field)
+        {
+            if (wrapToCaching && !cachedTokenStream && !(tokenStream is CachingTokenFilter))
+            {
+                tokenStream = new CachingTokenFilter(tokenStream);
+                cachedTokenStream = true;
+            }
+            IndexReader reader = readers[field];
+            if (reader == null)
+            {
+                MemoryIndex indexer = new MemoryIndex();
+                indexer.AddField(field, tokenStream);
+                tokenStream.Reset();
+                IndexSearcher searcher = indexer.CreateSearcher();
+                reader = searcher.IndexReader;
+                readers[field] = reader;
+            }
+
+            return reader;
+        }
+
+        /// <summary>
+        /// Creates a Map of <c>WeightedSpanTerms</c> from the given <c>Query</c> and <c>TokenStream</c>.
+        /// </summary>
+        /// <param name="query">query that caused hit</param>
+        /// <param name="tokenStream">TokenStream of text to be highlighted</param>
+        /// <returns>Map containing WeightedSpanTerms</returns>
+        public IDictionary<String, WeightedSpanTerm> GetWeightedSpanTerms(Query query, TokenStream tokenStream)
+        {
+            return GetWeightedSpanTerms(query, tokenStream, null);
+        }
+
+
+        /// <summary>
+        /// Creates a Map of <c>WeightedSpanTerms</c> from the given <c>Query</c> and <c>TokenStream</c>.
+        /// </summary>
+        /// <param name="query">query that caused hit</param>
+        /// <param name="tokenStream">tokenStream of text to be highlighted</param>
+        /// <param name="fieldName">restricts Term's used based on field name</param>
+        /// <returns>Map containing WeightedSpanTerms</returns>
+        public IDictionary<String, WeightedSpanTerm> GetWeightedSpanTerms(Query query, TokenStream tokenStream,
+                                                                          String fieldName)
+        {
+            if (fieldName != null)
+            {
+                this.fieldName = StringHelper.Intern(fieldName);
+            }
+            else
+            {
+                this.fieldName = null;
+            }
+
+            IDictionary<String, WeightedSpanTerm> terms = new PositionCheckingMap<String>();
+            this.tokenStream = tokenStream;
+            try
+            {
+                Extract(query, terms);
+            }
+            finally
+            {
+                CloseReaders();
+            }
+
+            return terms;
+        }
+
+        /// <summary>
+        /// Creates a Map of <c>WeightedSpanTerms</c> from the given <c>Query</c> and <c>TokenStream</c>. Uses a supplied
+        /// <c>IndexReader</c> to properly Weight terms (for gradient highlighting).
+        /// </summary>
+        /// <param name="query">Query that caused hit</param>
+        /// <param name="tokenStream">Tokenstream of text to be highlighted</param>
+        /// <param name="fieldName">restricts Term's used based on field name</param>
+        /// <param name="reader">to use for scoring</param>
+        /// <returns>Map of WeightedSpanTerms with quasi tf/idf scores</returns>
+        public IDictionary<String, WeightedSpanTerm> GetWeightedSpanTermsWithScores(Query query, TokenStream tokenStream,
+                                                                                    String fieldName, IndexReader reader)
+        {
+            if (fieldName != null)
+            {
+                this.fieldName = StringHelper.Intern(fieldName);
+            }
+            else
+            {
+                this.fieldName = null;
+            }
+            this.tokenStream = tokenStream;
+
+            IDictionary<String, WeightedSpanTerm> terms = new PositionCheckingMap<String>();
+            Extract(query, terms);
+
+            int totalNumDocs = reader.NumDocs();
+            var weightedTerms = terms.Keys;
+
+            try
+            {
+                foreach (var wt in weightedTerms)
+                {
+                    WeightedSpanTerm weightedSpanTerm = terms[wt];
+                    int docFreq = reader.DocFreq(new Term(fieldName, weightedSpanTerm.Term));
+                    // docFreq counts deletes
+                    if (totalNumDocs < docFreq)
+                    {
+                        docFreq = totalNumDocs;
+                    }
+                    // IDF algorithm taken from DefaultSimilarity class
+                    float idf = (float) (Math.Log((float) totalNumDocs/(double) (docFreq + 1)) + 1.0);
+                    weightedSpanTerm.Weight *= idf;
+                }
+            }
+            finally
+            {
+
+                CloseReaders();
+            }
+
+            return terms;
+        }
+
+        private void CollectSpanQueryFields(SpanQuery spanQuery, HashSet<String> fieldNames)
+        {
+            if (spanQuery is FieldMaskingSpanQuery)
+            {
+                CollectSpanQueryFields(((FieldMaskingSpanQuery) spanQuery).MaskedQuery, fieldNames);
+            }
+            else if (spanQuery is SpanFirstQuery)
+            {
+                CollectSpanQueryFields(((SpanFirstQuery) spanQuery).Match, fieldNames);
+            }
+            else if (spanQuery is SpanNearQuery)
+            {
+                foreach (SpanQuery clause in ((SpanNearQuery) spanQuery).GetClauses())
+                {
+                    CollectSpanQueryFields(clause, fieldNames);
+                }
+            }
+            else if (spanQuery is SpanNotQuery)
+            {
+                CollectSpanQueryFields(((SpanNotQuery) spanQuery).Include, fieldNames);
+            }
+            else if (spanQuery is SpanOrQuery)
+            {
+                foreach (SpanQuery clause in ((SpanOrQuery) spanQuery).GetClauses())
+                {
+                    CollectSpanQueryFields(clause, fieldNames);
+                }
+            }
+            else
+            {
+                fieldNames.Add(spanQuery.Field);
+            }
+        }
+
+        private bool MustRewriteQuery(SpanQuery spanQuery)
+        {
+            if (!expandMultiTermQuery)
+            {
+                return false; // Will throw UnsupportedOperationException in case of a SpanRegexQuery.
+            }
+            else if (spanQuery is FieldMaskingSpanQuery)
+            {
+                return MustRewriteQuery(((FieldMaskingSpanQuery)spanQuery).MaskedQuery);
+            }
+            else if (spanQuery is SpanFirstQuery)
+            {
+                return MustRewriteQuery(((SpanFirstQuery)spanQuery).Match);
+            }
+            else if (spanQuery is SpanNearQuery)
+            {
+                foreach (SpanQuery clause in ((SpanNearQuery) spanQuery).GetClauses())
+                {
+                    if (MustRewriteQuery(clause))
+                    {
+                        return true;
+                    }
+                }
+                return false;
+            }
+            else if (spanQuery is SpanNotQuery)
+            {
+                SpanNotQuery spanNotQuery = (SpanNotQuery) spanQuery;
+                return MustRewriteQuery(spanNotQuery.Include) || MustRewriteQuery(spanNotQuery.Exclude);
+            }
+            else if (spanQuery is SpanOrQuery)
+            {
+                foreach (SpanQuery clause in ((SpanOrQuery) spanQuery).GetClauses())
+                {
+                    if (MustRewriteQuery(clause))
+                    {
+                        return true;
+                    }
+                }
+                return false;
+            }
+            else if (spanQuery is SpanTermQuery)
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+
+        
+        /// <summary>
+        /// This class makes sure that if both position sensitive and insensitive
+        /// versions of the same term are added, the position insensitive one wins.
+        /// </summary>
+        /// <typeparam name="K"></typeparam>
+        private class PositionCheckingMap<K> : HashMap<K, WeightedSpanTerm>
+        {
+            public PositionCheckingMap()
+            {
+
+            }
+
+            public PositionCheckingMap(IEnumerable<KeyValuePair<K, WeightedSpanTerm>> m)
+            {
+                PutAll(m);
+            }
+
+            public void PutAll(IEnumerable<KeyValuePair<K, WeightedSpanTerm>> m)
+            {
+                foreach (var entry in m)
+                {
+                    Add(entry.Key, entry.Value);
+                }
+            }
+
+            public override void Add(K key, WeightedSpanTerm value)
+            {
+                base.Add(key, value);
+                WeightedSpanTerm prev = this[key];
+
+                if (prev == null) return;
+
+                WeightedSpanTerm prevTerm = prev;
+                WeightedSpanTerm newTerm = value;
+                if (!prevTerm.IsPositionSensitive())
+                {
+                    newTerm.SetPositionSensitive(false);
+                }
+            }
+
+        }
+
+        public bool GetExpandMultiTermQuery()
+        {
+            return expandMultiTermQuery;
+        }
+
+        public void SetExpandMultiTermQuery(bool expandMultiTermQuery)
+        {
+            this.expandMultiTermQuery = expandMultiTermQuery;
+        }
+
+        public bool IsCachedTokenStream()
+        {
+            return cachedTokenStream;
+        }
+
+        public TokenStream GetTokenStream()
+        {
+            return tokenStream;
+        }
+
+
+        /// <summary>
+        /// By default, <see cref="TokenStream"/>s that are not of the type
+        /// <see cref="CachingTokenFilter"/> are wrapped in a <see cref="CachingTokenFilter"/> to
+        /// <see cref="TokenStream"/> impl and you don't want it to be wrapped, set this to
+        /// false.
+        /// </summary>
+        public void SetWrapIfNotCachingTokenFilter(bool wrap)
+        {
+            this.wrapToCaching = wrap;
+        }
+
+        /// <summary>
+        /// A fake IndexReader class to extract the field from a MultiTermQuery
+        /// </summary>
+        protected internal sealed class FakeReader : FilterIndexReader
+        {
+
+            private static IndexReader EMPTY_MEMORY_INDEX_READER = new MemoryIndex().CreateSearcher().IndexReader;
+
+            public String Field { get; private set; }
+
+            protected internal FakeReader()
+                : base(EMPTY_MEMORY_INDEX_READER)
+            {
+
+            }
+
+            public override TermEnum Terms(Term t)
+            {
+                // only set first fieldname, maybe use a Set?
+                if (t != null && Field == null)
+                    Field = t.Field;
+                return base.Terms(t);
+            }
+
+
+        }
+    }
 }
\ No newline at end of file

Propchange: incubator/lucene.net/trunk/src/contrib/Highlighter/WeightedSpanTermExtractor.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/lucene.net/trunk/src/contrib/Memory/Contrib.Memory.csproj
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/contrib/Memory/Contrib.Memory.csproj?rev=1344556&r1=1344555&r2=1344556&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/contrib/Memory/Contrib.Memory.csproj (original)
+++ incubator/lucene.net/trunk/src/contrib/Memory/Contrib.Memory.csproj Thu May 31 04:12:43 2012
@@ -1,97 +1,97 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-
- 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.
-
--->
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{112B9A7C-29CC-4539-8F5A-45669C07CD4D}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>Lucene.Net.Index.Memory</RootNamespace>
-    <AssemblyName>Lucene.Net.Contrib.Memory</AssemblyName>
-    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <TargetFrameworkProfile />
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <OutputPath>..\..\..\build\bin\contrib\Memory\Debug\</OutputPath>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <OutputPath>..\..\..\build\bin\contrib\Memory\Release\</OutputPath>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <DefineConstants>TRACE</DefineConstants>
-    <DocumentationFile>..\..\..build\bin\contrib\Memory\Release\Lucene.Net.Contrib.Memory.XML</DocumentationFile>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup>
-    <SignAssembly>true</SignAssembly>
-  </PropertyGroup>
-  <PropertyGroup>
-    <AssemblyOriginatorKeyFile>Lucene.Net.snk</AssemblyOriginatorKeyFile>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="CollectionsHelper.cs" />
-    <Compile Include="EmptyCollector.cs" />
-    <Compile Include="KeywordTokenStream.cs" />
-    <Compile Include="MemoryIndex.cs" />
-    <Compile Include="MemoryTermPositionVector.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="TermComparer.cs" />
-    <Compile Include="MemoryTermEnum.cs" />
-    <Compile Include="MemoryTermPositions.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\core\Lucene.Net.csproj">
-      <Project>{5d4ad9be-1ffb-41ab-9943-25737971bf57}</Project>
-      <Name>Lucene.Net</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="Lucene.Net.snk" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ 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.
+
+-->
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{112B9A7C-29CC-4539-8F5A-45669C07CD4D}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Lucene.Net.Index.Memory</RootNamespace>
+    <AssemblyName>Lucene.Net.Contrib.Memory</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <OutputPath>..\..\..\build\bin\contrib\Memory\Debug\</OutputPath>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <OutputPath>..\..\..\build\bin\contrib\Memory\Release\</OutputPath>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <DefineConstants>TRACE</DefineConstants>
+    <DocumentationFile>..\..\..build\bin\contrib\Memory\Release\Lucene.Net.Contrib.Memory.XML</DocumentationFile>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <SignAssembly>true</SignAssembly>
+  </PropertyGroup>
+  <PropertyGroup>
+    <AssemblyOriginatorKeyFile>Lucene.Net.snk</AssemblyOriginatorKeyFile>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CollectionsHelper.cs" />
+    <Compile Include="EmptyCollector.cs" />
+    <Compile Include="KeywordTokenStream.cs" />
+    <Compile Include="MemoryIndex.cs" />
+    <Compile Include="MemoryTermPositionVector.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="TermComparer.cs" />
+    <Compile Include="MemoryTermEnum.cs" />
+    <Compile Include="MemoryTermPositions.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\core\Lucene.Net.csproj">
+      <Project>{5d4ad9be-1ffb-41ab-9943-25737971bf57}</Project>
+      <Name>Lucene.Net</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Lucene.Net.snk" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
 </Project>
\ No newline at end of file

Propchange: incubator/lucene.net/trunk/src/contrib/Memory/Contrib.Memory.csproj
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs?rev=1344556&r1=1344555&r2=1344556&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs Thu May 31 04:12:43 2012
@@ -1,41 +1,41 @@
-/* 
- * 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;
-using Lucene.Net.Util;
-using Tokenizer = Lucene.Net.Analysis.Tokenizer;
-
-namespace Lucene.Net.Analysis.Tokenattributes
-{
-	
-	/// <summary> This attribute can be used to pass different flags down the <see cref="Tokenizer" /> chain,
-	/// eg from one TokenFilter to another one. 
-	/// </summary>
-	public interface IFlagsAttribute:IAttribute
-	{
-	    /// <summary> EXPERIMENTAL:  While we think this is here to stay, we may want to change it to be a long.
-	    /// <p/>
-	    /// 
-	    /// Get the bitset for any bits that have been set.  This is completely distinct from <see cref="ITypeAttribute.Type()" />, although they do share similar purposes.
-	    /// The flags can be used to encode information about the token for use by other <see cref="Lucene.Net.Analysis.TokenFilter" />s.
-	    /// 
-	    /// 
-	    /// </summary>
-	    /// <value> The bits </value>
-	    int Flags { get; set; }
-	}
+/* 
+ * 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;
+using Lucene.Net.Util;
+using Tokenizer = Lucene.Net.Analysis.Tokenizer;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> This attribute can be used to pass different flags down the <see cref="Tokenizer" /> chain,
+	/// eg from one TokenFilter to another one. 
+	/// </summary>
+	public interface IFlagsAttribute:IAttribute
+	{
+	    /// <summary> EXPERIMENTAL:  While we think this is here to stay, we may want to change it to be a long.
+	    /// <p/>
+	    /// 
+	    /// Get the bitset for any bits that have been set.  This is completely distinct from <see cref="ITypeAttribute.Type()" />, although they do share similar purposes.
+	    /// The flags can be used to encode information about the token for use by other <see cref="Lucene.Net.Analysis.TokenFilter" />s.
+	    /// 
+	    /// 
+	    /// </summary>
+	    /// <value> The bits </value>
+	    int Flags { get; set; }
+	}
 }
\ No newline at end of file

Propchange: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IFlagsAttribute.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs?rev=1344556&r1=1344555&r2=1344556&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs Thu May 31 04:12:43 2012
@@ -1,48 +1,48 @@
-/* 
- * 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;
-using Lucene.Net.Util;
-
-namespace Lucene.Net.Analysis.Tokenattributes
-{
-	
-	/// <summary> The start and end character offset of a Token. </summary>
-	public interface IOffsetAttribute : IAttribute
-	{
-	    /// <summary>Returns this Token's starting offset, the position of the first character
-	    /// corresponding to this token in the source text.
-	    /// Note that the difference between endOffset() and startOffset() may not be
-	    /// equal to termText.length(), as the term text may have been altered by a
-	    /// stemmer or some other filter. 
-	    /// </summary>
-	    int StartOffset { get; }
-
-
-	    /// <summary>Set the starting and ending offset.
-        /// See StartOffset() and EndOffset()
-        /// </summary>
-		void  SetOffset(int startOffset, int endOffset);
-
-
-	    /// <summary>Returns this Token's ending offset, one greater than the position of the
-	    /// last character corresponding to this token in the source text. The length
-	    /// of the token in the source text is (endOffset - startOffset). 
-	    /// </summary>
-	    int EndOffset { get; }
-	}
+/* 
+ * 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;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> The start and end character offset of a Token. </summary>
+	public interface IOffsetAttribute : IAttribute
+	{
+	    /// <summary>Returns this Token's starting offset, the position of the first character
+	    /// corresponding to this token in the source text.
+	    /// Note that the difference between endOffset() and startOffset() may not be
+	    /// equal to termText.length(), as the term text may have been altered by a
+	    /// stemmer or some other filter. 
+	    /// </summary>
+	    int StartOffset { get; }
+
+
+	    /// <summary>Set the starting and ending offset.
+        /// See StartOffset() and EndOffset()
+        /// </summary>
+		void  SetOffset(int startOffset, int endOffset);
+
+
+	    /// <summary>Returns this Token's ending offset, one greater than the position of the
+	    /// last character corresponding to this token in the source text. The length
+	    /// of the token in the source text is (endOffset - startOffset). 
+	    /// </summary>
+	    int EndOffset { get; }
+	}
 }
\ No newline at end of file

Propchange: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IOffsetAttribute.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs?rev=1344556&r1=1344555&r2=1344556&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs Thu May 31 04:12:43 2012
@@ -1,31 +1,31 @@
-/* 
- * 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;
-using Lucene.Net.Util;
-using Payload = Lucene.Net.Index.Payload;
-
-namespace Lucene.Net.Analysis.Tokenattributes
-{
-	
-	/// <summary> The payload of a Token. See also <see cref="Payload" />.</summary>
-	public interface IPayloadAttribute:IAttribute
-	{
-	    /// <summary> Returns this Token's payload.</summary>
-	    Payload Payload { get; set; }
-	}
+/* 
+ * 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;
+using Lucene.Net.Util;
+using Payload = Lucene.Net.Index.Payload;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> The payload of a Token. See also <see cref="Payload" />.</summary>
+	public interface IPayloadAttribute:IAttribute
+	{
+	    /// <summary> Returns this Token's payload.</summary>
+	    Payload Payload { get; set; }
+	}
 }
\ No newline at end of file

Propchange: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPayloadAttribute.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs?rev=1344556&r1=1344555&r2=1344556&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs Thu May 31 04:12:43 2012
@@ -1,59 +1,59 @@
-/* 
- * 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;
-using Lucene.Net.Util;
-
-namespace Lucene.Net.Analysis.Tokenattributes
-{
-	
-	/// <summary>The positionIncrement determines the position of this token
-	/// relative to the previous Token in a TokenStream, used in phrase
-	/// searching.
-	/// 
-	/// <p/>The default value is one.
-	/// 
-	/// <p/>Some common uses for this are:<list>
-	/// 
-	/// <item>Set it to zero to put multiple terms in the same position.  This is
-	/// useful if, e.g., a word has multiple stems.  Searches for phrases
-	/// including either stem will match.  In this case, all but the first stem's
-	/// increment should be set to zero: the increment of the first instance
-	/// should be one.  Repeating a token with an increment of zero can also be
-	/// used to boost the scores of matches on that token.</item>
-	/// 
-	/// <item>Set it to values greater than one to inhibit exact phrase matches.
-	/// If, for example, one does not want phrases to match across removed stop
-	/// words, then one could build a stop word filter that removes stop words and
-	/// also sets the increment to the number of stop words removed before each
-	/// non-stop word.  Then exact phrase queries will only match when the terms
-	/// occur with no intervening stop words.</item>
-	/// 
-	/// </list>
-	/// 
-	/// </summary>
-	/// <seealso cref="Lucene.Net.Index.TermPositions">
-	/// </seealso>
-	public interface IPositionIncrementAttribute:IAttribute
-	{
-	    /// <summary>Gets or sets the position increment. The default value is one.
-	    /// 
-	    /// </summary>
-	    /// <value> the distance from the prior term </value>
-	    int PositionIncrement { set; get; }
-	}
+/* 
+ * 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;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary>The positionIncrement determines the position of this token
+	/// relative to the previous Token in a TokenStream, used in phrase
+	/// searching.
+	/// 
+	/// <p/>The default value is one.
+	/// 
+	/// <p/>Some common uses for this are:<list>
+	/// 
+	/// <item>Set it to zero to put multiple terms in the same position.  This is
+	/// useful if, e.g., a word has multiple stems.  Searches for phrases
+	/// including either stem will match.  In this case, all but the first stem's
+	/// increment should be set to zero: the increment of the first instance
+	/// should be one.  Repeating a token with an increment of zero can also be
+	/// used to boost the scores of matches on that token.</item>
+	/// 
+	/// <item>Set it to values greater than one to inhibit exact phrase matches.
+	/// If, for example, one does not want phrases to match across removed stop
+	/// words, then one could build a stop word filter that removes stop words and
+	/// also sets the increment to the number of stop words removed before each
+	/// non-stop word.  Then exact phrase queries will only match when the terms
+	/// occur with no intervening stop words.</item>
+	/// 
+	/// </list>
+	/// 
+	/// </summary>
+	/// <seealso cref="Lucene.Net.Index.TermPositions">
+	/// </seealso>
+	public interface IPositionIncrementAttribute:IAttribute
+	{
+	    /// <summary>Gets or sets the position increment. The default value is one.
+	    /// 
+	    /// </summary>
+	    /// <value> the distance from the prior term </value>
+	    int PositionIncrement { set; get; }
+	}
 }
\ No newline at end of file

Propchange: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/IPositionIncrementAttribute.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs?rev=1344556&r1=1344555&r2=1344556&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs Thu May 31 04:12:43 2012
@@ -1,104 +1,104 @@
-/* 
- * 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;
-using Lucene.Net.Util;
-
-namespace Lucene.Net.Analysis.Tokenattributes
-{
-	
-	/// <summary> The term text of a Token.</summary>
-	public interface ITermAttribute:IAttribute
-	{
-		/// <summary>Returns the Token's term text.
-		/// 
-		/// This method has a performance penalty
-		/// because the text is stored internally in a char[].  If
-		/// possible, use <see cref="TermBuffer()" /> and <see cref="TermLength()" />
-		/// directly instead.  If you really need a
-		/// String, use this method, which is nothing more than
-		/// a convenience call to <b>new String(token.termBuffer(), 0, token.termLength())</b>
-		/// </summary>
-		System.String Term();
-		
-		/// <summary>Copies the contents of buffer, starting at offset for
-		/// length characters, into the termBuffer array.
-		/// </summary>
-		/// <param name="buffer">the buffer to copy
-		/// </param>
-		/// <param name="offset">the index in the buffer of the first character to copy
-		/// </param>
-		/// <param name="length">the number of characters to copy
-		/// </param>
-		void  SetTermBuffer(char[] buffer, int offset, int length);
-		
-		/// <summary>Copies the contents of buffer into the termBuffer array.</summary>
-		/// <param name="buffer">the buffer to copy
-		/// </param>
-		void  SetTermBuffer(System.String buffer);
-		
-		/// <summary>Copies the contents of buffer, starting at offset and continuing
-		/// for length characters, into the termBuffer array.
-		/// </summary>
-		/// <param name="buffer">the buffer to copy
-		/// </param>
-		/// <param name="offset">the index in the buffer of the first character to copy
-		/// </param>
-		/// <param name="length">the number of characters to copy
-		/// </param>
-		void  SetTermBuffer(System.String buffer, int offset, int length);
-		
-		/// <summary>Returns the internal termBuffer character array which
-		/// you can then directly alter.  If the array is too
-		/// small for your token, use <see cref="ResizeTermBuffer(int)" />
-		/// to increase it.  After
-		/// altering the buffer be sure to call <see cref="SetTermLength" />
-		/// to record the number of valid
-		/// characters that were placed into the termBuffer. 
-		/// </summary>
-		char[] TermBuffer();
-		
-		/// <summary>Grows the termBuffer to at least size newSize, preserving the
-		/// existing content. Note: If the next operation is to change
-		/// the contents of the term buffer use
-		/// <see cref="SetTermBuffer(char[], int, int)" />,
-		/// <see cref="SetTermBuffer(String)" />, or
-		/// <see cref="SetTermBuffer(String, int, int)" />
-		/// to optimally combine the resize with the setting of the termBuffer.
-		/// </summary>
-		/// <param name="newSize">minimum size of the new termBuffer
-		/// </param>
-		/// <returns> newly created termBuffer with length >= newSize
-		/// </returns>
-		char[] ResizeTermBuffer(int newSize);
-		
-		/// <summary>Return number of valid characters (length of the term)
-		/// in the termBuffer array. 
-		/// </summary>
-		int TermLength();
-		
-		/// <summary>Set number of valid characters (length of the term) in
-		/// the termBuffer array. Use this to truncate the termBuffer
-		/// or to synchronize with external manipulation of the termBuffer.
-		/// Note: to grow the size of the array,
-		/// use <see cref="ResizeTermBuffer(int)" /> first.
-		/// </summary>
-		/// <param name="length">the truncated length
-		/// </param>
-		void  SetTermLength(int length);
-	}
+/* 
+ * 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;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> The term text of a Token.</summary>
+	public interface ITermAttribute:IAttribute
+	{
+		/// <summary>Returns the Token's term text.
+		/// 
+		/// This method has a performance penalty
+		/// because the text is stored internally in a char[].  If
+		/// possible, use <see cref="TermBuffer()" /> and <see cref="TermLength()" />
+		/// directly instead.  If you really need a
+		/// String, use this method, which is nothing more than
+		/// a convenience call to <b>new String(token.termBuffer(), 0, token.termLength())</b>
+		/// </summary>
+		System.String Term();
+		
+		/// <summary>Copies the contents of buffer, starting at offset for
+		/// length characters, into the termBuffer array.
+		/// </summary>
+		/// <param name="buffer">the buffer to copy
+		/// </param>
+		/// <param name="offset">the index in the buffer of the first character to copy
+		/// </param>
+		/// <param name="length">the number of characters to copy
+		/// </param>
+		void  SetTermBuffer(char[] buffer, int offset, int length);
+		
+		/// <summary>Copies the contents of buffer into the termBuffer array.</summary>
+		/// <param name="buffer">the buffer to copy
+		/// </param>
+		void  SetTermBuffer(System.String buffer);
+		
+		/// <summary>Copies the contents of buffer, starting at offset and continuing
+		/// for length characters, into the termBuffer array.
+		/// </summary>
+		/// <param name="buffer">the buffer to copy
+		/// </param>
+		/// <param name="offset">the index in the buffer of the first character to copy
+		/// </param>
+		/// <param name="length">the number of characters to copy
+		/// </param>
+		void  SetTermBuffer(System.String buffer, int offset, int length);
+		
+		/// <summary>Returns the internal termBuffer character array which
+		/// you can then directly alter.  If the array is too
+		/// small for your token, use <see cref="ResizeTermBuffer(int)" />
+		/// to increase it.  After
+		/// altering the buffer be sure to call <see cref="SetTermLength" />
+		/// to record the number of valid
+		/// characters that were placed into the termBuffer. 
+		/// </summary>
+		char[] TermBuffer();
+		
+		/// <summary>Grows the termBuffer to at least size newSize, preserving the
+		/// existing content. Note: If the next operation is to change
+		/// the contents of the term buffer use
+		/// <see cref="SetTermBuffer(char[], int, int)" />,
+		/// <see cref="SetTermBuffer(String)" />, or
+		/// <see cref="SetTermBuffer(String, int, int)" />
+		/// to optimally combine the resize with the setting of the termBuffer.
+		/// </summary>
+		/// <param name="newSize">minimum size of the new termBuffer
+		/// </param>
+		/// <returns> newly created termBuffer with length >= newSize
+		/// </returns>
+		char[] ResizeTermBuffer(int newSize);
+		
+		/// <summary>Return number of valid characters (length of the term)
+		/// in the termBuffer array. 
+		/// </summary>
+		int TermLength();
+		
+		/// <summary>Set number of valid characters (length of the term) in
+		/// the termBuffer array. Use this to truncate the termBuffer
+		/// or to synchronize with external manipulation of the termBuffer.
+		/// Note: to grow the size of the array,
+		/// use <see cref="ResizeTermBuffer(int)" /> first.
+		/// </summary>
+		/// <param name="length">the truncated length
+		/// </param>
+		void  SetTermLength(int length);
+	}
 }
\ No newline at end of file

Propchange: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITermAttribute.cs
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs?rev=1344556&r1=1344555&r2=1344556&view=diff
==============================================================================
--- incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs (original)
+++ incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs Thu May 31 04:12:43 2012
@@ -1,30 +1,30 @@
-/* 
- * 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;
-using Lucene.Net.Util;
-
-namespace Lucene.Net.Analysis.Tokenattributes
-{
-	
-	/// <summary> A Token's lexical type. The Default value is "word". </summary>
-	public interface ITypeAttribute:IAttribute
-	{
-	    /// <summary>Gets or sets this Token's lexical type.  Defaults to "word". </summary>
-	    string Type { get; set; }
-	}
+/* 
+ * 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;
+using Lucene.Net.Util;
+
+namespace Lucene.Net.Analysis.Tokenattributes
+{
+	
+	/// <summary> A Token's lexical type. The Default value is "word". </summary>
+	public interface ITypeAttribute:IAttribute
+	{
+	    /// <summary>Gets or sets this Token's lexical type.  Defaults to "word". </summary>
+	    string Type { get; set; }
+	}
 }
\ No newline at end of file

Propchange: incubator/lucene.net/trunk/src/core/Analysis/Tokenattributes/ITypeAttribute.cs
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message