public void getListOfRhymes() { StreamReader s = new StreamReader("dict2.txt"); string S; RhymeCodeClass Rc; while ((S = s.ReadLine()) != null) { string[] a = S.Split(" ".ToCharArray()); Rc = new RhymeCodeClass(); Rc.name = a[0]; foreach (string sl in a) { if (sl != "") { if (IsNumber(sl[sl.Length - 1].ToString())) { Rc.numSyllables++; } } } if (a.Count() > 1) { Rc.RhymeCode = a[a.Count() - 2] + a[a.Count() - 1]; } RhymeCodes.Add(Rc); } }
public void GetRhymeCodes(Word wd) { RhymeCodeClass GotWord = new RhymeCodeClass(); if (wd.Name == "") { return; } string uppername = wd.Name.ToUpper(); string st = ""; IEnumerable <RhymeCodeClass> rcs = from s in RhymeCodes where s.name == uppername select s; if (rcs.Count() > 0) { GotWord = rcs.First(); st = GotWord.name; // we have our word string[] a = st.Split(" ".ToCharArray()); // if(rcs.Count()!=0) { //get syllables wd.NumSyllables = GotWord.numSyllables; wd.RhymeCode = GotWord.RhymeCode; } } }