コード例 #1
0
        /// <summary>
        /// Adds a word to the whitelist.
        /// </summary>
        /// <remarks>
        /// The word can contain spaces, such as "Starbase 3001".
        /// </remarks>
        /// <param name="word">Word to add.</param>
        public void AddWord(string word)
        {
            // Add the word.
            word = word.ToLower().Trim();
            if (AcceptedWords.Contains(word))
            {
                return;
            }
            AcceptedWords.Add(word.ToLower());

            // Set up the word if it has a space.
            var wordSections = _wordPattern.Matches(word);

            if (wordSections.Count == 1)
            {
                return;
            }
            var initialWord = word.Substring(0, wordSections[0].Length);

            if (!AcceptedWordsWithMultipleSections.ContainsKey(initialWord))
            {
                AcceptedWordsWithMultipleSections[initialWord] = new List <string>();
            }
            AcceptedWordsWithMultipleSections[initialWord].Add(word);
        }
コード例 #2
0
        public async Task LoadDefaultWhitelist()
        {
            var raw = await _resources.ReadTextAsync("./chatminus_en_us.txt");

            AcceptedWords.AddRange(raw.Split("\r\n").Select(s => s.ToLower()));

            raw = await _resources.ReadTextAsync("./chatplus_en_us.txt");

            AcceptedWords.AddRange(raw.Split("\r\n").Select(s => s.ToLower()));
        }