private WordDictionaryFile LoadFromTextFile(String fileName)
{
WordDictionaryFile dictFile = new WordDictionaryFile();
dictFile.Dicts = new List<WordAttribute>();
using (StreamReader sr = new StreamReader(fileName, Encoding.UTF8))
{
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
string[] strs = line.Split(new char[] { '|' });
if (strs.Length == 3)
{
string word = strs[0].Trim();
POS pos = (POS)int.Parse(strs[1].Substring(2, strs[1].Length - 2), System.Globalization.NumberStyles.HexNumber);
double frequency = double.Parse(strs[2]);
WordAttribute dict = new WordAttribute(word, pos, frequency);
dictFile.Dicts.Add(dict);
}
}
}
return dictFile;
}