18 using System.Collections.Generic;
20 namespace Lucene.Net.Analysis
34 public static ISet<string> GetWordSet(System.IO.FileInfo wordfile)
36 using (var reader =
new System.IO.StreamReader(wordfile.FullName, System.Text.Encoding.Default))
38 return GetWordSet(reader);
50 public static ISet<string> GetWordSet(System.IO.FileInfo wordfile, System.String comment)
52 using (var reader =
new System.IO.StreamReader(wordfile.FullName, System.Text.Encoding.Default))
54 return GetWordSet(reader, comment);
66 public static ISet<string> GetWordSet(System.IO.TextReader reader)
68 var result = Support.Compatibility.SetFactory.CreateHashSet<
string>();
71 while ((word = reader.ReadLine()) != null)
73 result.Add(word.Trim());
91 public static ISet<string> GetWordSet(System.IO.TextReader reader, System.String comment)
93 var result = Support.Compatibility.SetFactory.CreateHashSet<
string>();
95 System.String word = null;
96 while ((word = reader.ReadLine()) != null)
98 if (word.StartsWith(comment) ==
false)
100 result.Add(word.Trim());
117 public static Dictionary<string, string> GetStemDict(System.IO.FileInfo wordstemfile)
119 if (wordstemfile == null)
120 throw new System.NullReferenceException(
"wordstemfile may not be null");
121 var result =
new Dictionary<string, string>();
122 System.IO.StreamReader br = null;
123 System.IO.StreamReader fr = null;
126 fr =
new System.IO.StreamReader(wordstemfile.FullName, System.Text.Encoding.Default);
127 br =
new System.IO.StreamReader(fr.BaseStream, fr.CurrentEncoding);
130 while ((line = br.ReadLine()) != null)
132 System.String[] wordstem = line.Split(tab, 2);
133 result[wordstem[0]] = wordstem[1];