public static List <Word> GetPhonemeRhymes(Syllable syllable, int maxSyllables = 0) { var rhymes = new Dictionary <string, Word>(); foreach (var word in English.GetWords()) { // todo: Temporary hack, this should be removed //if (word.Syllables.Count <= 0) { // continue; //} if (rhymes.ContainsKey(word.Text)) { continue; } if (maxSyllables > 0 && word.Syllables.Count > maxSyllables) { continue; } if (word.Text.Trim().Length <= 1 || word.Text.Contains(".")) { continue; } if (IsRhyme(syllable, word.Syllables.Last())) { rhymes.Add(word.Text, word); } } //return rhymes.GroupBy(each => each.Value).SelectMany(each => each.ToList()).OrderByDescending(each => each.Value).Select(each => each.Key).ToList(); return(rhymes.Values.ToList()); }
public OrderedWord(NGram ngram, string word, int index) { NGram = ngram; Index = index; Word = English.GetWord(word); if (Word != null) { Word.NGrams.Add(this); } }
public long GetNGramScore() { if (Text.Length == 0) { return(0); } var collection = English.GetNGrams(Words.Count); if (collection == null || !collection.ContainsKey(Text)) { return(0); } return(collection[Text].Frequency); }
public Phrase(string text) : this() { foreach (var word in text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)) { var english = English.GetWord(word); if (english == null) { Words.Clear(); break; } Words.Add(english); } Initialize(); }
public static bool IsRhyme(string word1, string word2) { return(IsRhyme(English.GetWord(word1), English.GetWord(word2))); }