示例#1
0
        /// <summary>
        /// Builds the lexicon.
        /// </summary>
        private void BuildLexicon()
        {
            var Data  = new FileInfo("resource://Enlighten/Enlighten.Resources.en_us.lexicon.txt").Read();
            var Lines = Data.Split(NewLineSplitter, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0, LinesLength = Lines.Length; i < LinesLength; i++)
            {
                var Line = Lines[i];
                if (string.IsNullOrEmpty(Line))
                {
                    continue;
                }
                var LineData = Line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var Key      = LineData[0];
                var Item     = LineData[1];
                Lexicon.TryAdd(Key, new LexiconRule(Key, Item));
            }

            Data  = new FileInfo("resource://Enlighten/Enlighten.Resources.en_us.regularverbs.txt").Read();
            Lines = Data.Split(NewLineSplitter, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0, LinesLength = Lines.Length; i < LinesLength; i++)
            {
                var Line = Lines[i];
                if (string.IsNullOrEmpty(Line))
                {
                    continue;
                }
                var Key = Line;
                Infinitives.Add(Key);
                var Item = Inflector.ToPresent(Key, InflectorLanguage.English);
                Lexicon.TryAdd(Item, new LexiconRule(Item, "VB"));
                Item = Inflector.ToPast(Key, InflectorLanguage.English);
                Lexicon.TryAdd(Item, new LexiconRule(Item, "VBN"));
                Item = Inflector.ToGerund(Key, InflectorLanguage.English);
                Lexicon.TryAdd(Item, new LexiconRule(Item, "VBG"));
            }

            Data  = new FileInfo("resource://Enlighten/Enlighten.Resources.en_us.irregularverbs.txt").Read();
            Lines = Data.Split(NewLineSplitter, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0, LinesLength = Lines.Length; i < LinesLength; i++)
            {
                var Line = Lines[i];
                if (string.IsNullOrEmpty(Line))
                {
                    continue;
                }
                var Items = Line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                Infinitives.Add(Items[0]);
                Lexicon.TryAdd(Items[0], new LexiconRule(Items[0], "VB"));
                Lexicon.TryAdd(Items[1], new LexiconRule(Items[1], "VBD"));
                Lexicon.TryAdd(Items[2], new LexiconRule(Items[2], "VBN"));
                Lexicon.TryAdd(Items[3], new LexiconRule(Items[3], "VBZ"));
                Lexicon.TryAdd(Items[4], new LexiconRule(Items[4], "VBG"));
            }
        }