23 using System.Collections.Generic;
26 using Lucene.Net.Analysis.AR;
29 namespace Lucene.Net.Analysis.Fa
50 public readonly
static String DEFAULT_STOPWORD_FILE =
"stopwords.txt";
55 private readonly ISet<string> stoptable;
61 public static readonly String STOPWORDS_COMMENT =
"#";
67 public static ISet<string> getDefaultStopSet()
69 return DefaultSetHolder.DEFAULT_STOP_SET;
76 private static class DefaultSetHolder
78 internal static readonly ISet<string> DEFAULT_STOP_SET;
80 static DefaultSetHolder()
84 DEFAULT_STOP_SET = LoadDefaultStopWordSet();
86 catch (IOException ex)
90 throw new Exception(
"Unable to load default stopword set");
94 static ISet<String> LoadDefaultStopWordSet()
97 var stream = System.Reflection.Assembly.GetAssembly(typeof(PersianAnalyzer)).GetManifestResourceStream(
"Lucene.Net.Analyzers.Fa." + DEFAULT_STOPWORD_FILE);
100 StreamReader reader =
new StreamReader(stream, System.Text.Encoding.UTF8);
102 return CharArraySet.UnmodifiableSet(
new CharArraySet(WordlistLoader.GetWordSet(reader, STOPWORDS_COMMENT),
true));
111 private readonly
Version matchVersion;
118 : this(matchVersion, DefaultSetHolder.DEFAULT_STOP_SET)
134 this.matchVersion = matchVersion;
142 : this(matchVersion,
StopFilter.MakeStopSet(stopwords))
152 : this(matchVersion, stopwords.Keys.ToArray())
163 : this(matchVersion,
WordlistLoader.GetWordSet(stopwords, STOPWORDS_COMMENT))
193 private class SavedStreams
208 public override TokenStream ReusableTokenStream(String fieldName, TextReader reader)
210 SavedStreams streams = (SavedStreams)PreviousTokenStream;
213 streams =
new SavedStreams();
224 streams.result, stoptable);
225 PreviousTokenStream = streams;
229 streams.source.Reset(reader);
231 return streams.result;