// public methods public virtual void AddWord(string word) { // add to dictionary FullDicVarObj fullDicVarObj = new FullDicVarObj(word); if (dictionary_.ContainsKey(word) == true) { dictionary_.GetValueOrNull(word).Add(fullDicVarObj); } else { HashSet <FullDicVarObj> valueSet = new HashSet <FullDicVarObj>(); valueSet.Add(fullDicVarObj); dictionary_[word] = valueSet; } // add to file: TBD }
// private methods // TBD ... too many key ... private void LoadWords(string inFile) { int lineNo = 0; try { String[] lines = File.ReadAllLines(inFile, Encoding.UTF8); // go through all lines foreach (var line in lines) { if (line.StartsWith("#", StringComparison.Ordinal) == false) { var buf = line.Split("|"); string word = buf[0]; long pos = long.Parse(buf[1]); long infl = long.Parse(buf[2]); string src = buf[3]; bool acrAbb = bool.Parse(buf[4]); bool properNoun = bool.Parse(buf[5]); string key = word.ToLower(); FullDicVarObj fullDicVarObj = new FullDicVarObj(word, pos, infl, src, acrAbb, properNoun); if (dictionary_.ContainsKey(key) == true) { dictionary_.GetValueOrNull(key).Add(fullDicVarObj); } else { HashSet <FullDicVarObj> valueSet = new HashSet <FullDicVarObj>(); valueSet.Add(fullDicVarObj); dictionary_[key] = valueSet; } lineNo++; } } Console.WriteLine("- total LineNo: " + lineNo); } catch (Exception x1) { Console.Error.WriteLine("** [email protected]( ): " + x1.ToString()); } }