20 using Lucene.Net.Analysis.Standard;
23 namespace Lucene.Net.Analysis.Shingle
35 protected int maxShingleSize = 2;
36 protected bool outputUnigrams =
true;
40 this.defaultAnalyzer = defaultAnalyzer;
41 SetOverridesTokenStreamMethod<ShingleAnalyzerWrapper>();
45 : this(defaultAnalyzer)
48 this.maxShingleSize = maxShingleSize;
57 SetOverridesTokenStreamMethod<ShingleAnalyzerWrapper>();
66 this.maxShingleSize = nGramSize;
72 public int MaxShingleSize
74 get {
return maxShingleSize; }
75 set { this.maxShingleSize = value; }
81 public bool IsOutputUnigrams
83 get {
return outputUnigrams; }
84 set { this.outputUnigrams = value; }
92 wrapped = defaultAnalyzer.ReusableTokenStream(fieldName, reader);
96 wrapped = defaultAnalyzer.TokenStream(fieldName, reader);
110 public override TokenStream ReusableTokenStream(String fieldName, TextReader reader)
112 if (overridesTokenStreamMethod)
120 SavedStreams streams = (SavedStreams)PreviousTokenStream;
123 streams =
new SavedStreams();
124 streams.wrapped = defaultAnalyzer.ReusableTokenStream(fieldName, reader);
126 PreviousTokenStream = streams;
130 TokenStream result = defaultAnalyzer.ReusableTokenStream(fieldName, reader);
131 if (result == streams.wrapped)
134 streams.shingle.Reset();
139 streams.wrapped = result;
143 streams.shingle.SetMaxShingleSize(maxShingleSize);
144 streams.shingle.SetOutputUnigrams(outputUnigrams);
145 return streams.shingle;