ABB.Swum.Utilities.LibFileLoader.ReadWordList C# (CSharp) Method

ReadWordList() public static method

Reads a file containing a list of words, and returns it as a set. The file is assumed to contain a single word on each line. Duplicate words will be ignored.
public static ReadWordList ( bool keepOriginalCase ) : HashSet
keepOriginalCase bool If True, words are added to the set in their original case. If False, words are converted to lower case.
return HashSet
        public static HashSet<string> ReadWordList(bool keepOriginalCase, params string[] paths)
        {
            var culture = CultureInfo.CurrentCulture;
            if (paths == null) throw new ArgumentNullException("paths");

            HashSet<string> wordList = new HashSet<string>();
            foreach (string path in paths)
            {
                using (StreamReader file = new StreamReader(path))
                {
                    string word;
                    while (!file.EndOfStream)
                    {
                        word = file.ReadLine().Trim();
                        if (word != string.Empty && word[0]!='#' && !(word.Length>=2 && word[0]=='/' && word[1]=='/')) //ignore blank and commented lines
                        {
                            if (keepOriginalCase)
                            {
                                wordList.Add(word);
                            }
                            else
                            {
                                wordList.Add(word.ToLower(culture));
                            }
                        }
                    }
                }
            }

            return wordList;
        }

Same methods

LibFileLoader::ReadWordList ( ) : HashSet