public Word ChooseByGrammar(Vocabulary.SpeechPart nextPart, Random random) { Dictionary <Word, int> possibleFollowers = new Dictionary <Word, int> (); foreach (Word word in followers.Keys) { foreach (Vocabulary.SpeechPart part in Enum.GetValues(typeof(Vocabulary.SpeechPart))) { if (word.Part.HasFlag(part)) { //Console.Write (" YES " + word.Self + " as " + part + "."); possibleFollowers.Add(word, followers [word]); break; } // else { // Console.Write (" not " + word.Self + "."); // } } } if (possibleFollowers.Count == 0) { //Console.WriteLine ("Word.ChooseByGrammar: There is no " + nextPart + " that can follow " + this.Self + "."); return(null); } return(ChooseFollower(possibleFollowers, random)); }
public VocabWord(string input) { int splitPosition; char separator = '×'; string remaining; splitPosition = input.IndexOf (separator); if (splitPosition <= 0) { Console.WriteLine ("Error: splitPosition <= 0 in " + input + "."); } else { self = input.Substring (0, splitPosition); remaining = input.Substring (splitPosition + 1); if (remaining.Contains ("N")) { part |= Vocabulary.SpeechPart.Noun; } if (remaining.Contains ("p")) { part |= Vocabulary.SpeechPart.Plural; } if (remaining.Contains ("V")) { part |= Vocabulary.SpeechPart.Verb; } if (remaining.Contains ("t")) { part |= Vocabulary.SpeechPart.TransVerb; } if (remaining.Contains ("i")) { part |= Vocabulary.SpeechPart.IntransVerb; } if (remaining.Contains ("A")) { part |= Vocabulary.SpeechPart.Adjective; } if (remaining.Contains ("v")) { part |= Vocabulary.SpeechPart.Adverb; } if (remaining.Contains ("C")) { part |= Vocabulary.SpeechPart.Conjunction; } if (remaining.Contains ("P")) { part |= Vocabulary.SpeechPart.Preposition; } if (remaining.Contains ("!")) { part |= Vocabulary.SpeechPart.Interjection; } if (remaining.Contains ("r")) { part |= Vocabulary.SpeechPart.Pronoun; } if (remaining.Contains ("D")) { part |= Vocabulary.SpeechPart.DefArticle; } if (remaining.Contains ("I")) { part |= Vocabulary.SpeechPart.IndefArticle; } if (remaining.Contains ("o")) { part |= Vocabulary.SpeechPart.Nominative; } //Console.WriteLine ("Vocab word created: " + self + ". Part of speech: " + part); } }
public Grammar(Word word, int count) { part = word.Part; depth = count; maxID++; id = maxID; //Console.Write (" (grammar node " + id + ") "); }
public Word(string inbound, bool first, Vocabulary vocabulary) { if (inbound.Length == 0) { Console.WriteLine ("STOP STOP STOP STOP STOP"); } name = inbound; part = vocabulary.GetSpeechPart (name); frequency++; if (first) { firstCount++; } }
public Word(string inbound, bool first, Vocabulary vocabulary) { if (inbound.Length == 0) { Console.WriteLine("STOP STOP STOP STOP STOP"); } name = inbound; part = vocabulary.GetSpeechPart(name); frequency++; if (first) { firstCount++; } }
Word ChooseByPart(Vocabulary.SpeechPart part) { List <Word> options; int count, choice; if (!novel.CrossReference.ContainsKey(part)) { Console.WriteLine("No " + part + " found in CrossReference."); return(null); } options = novel.CrossReference[part]; count = options.Count; choice = novel.Rand.Next(0, count); return(options[choice]); }
public VocabWord(string input) { int splitPosition; char separator = '×'; string remaining; splitPosition = input.IndexOf(separator); if (splitPosition <= 0) { Console.WriteLine("Error: splitPosition <= 0 in " + input + "."); } else { self = input.Substring(0, splitPosition); remaining = input.Substring(splitPosition + 1); if (remaining.Contains("N")) { part |= Vocabulary.SpeechPart.Noun; } if (remaining.Contains("p")) { part |= Vocabulary.SpeechPart.Plural; } if (remaining.Contains("V")) { part |= Vocabulary.SpeechPart.Verb; } if (remaining.Contains("t")) { part |= Vocabulary.SpeechPart.TransVerb; } if (remaining.Contains("i")) { part |= Vocabulary.SpeechPart.IntransVerb; } if (remaining.Contains("A")) { part |= Vocabulary.SpeechPart.Adjective; } if (remaining.Contains("v")) { part |= Vocabulary.SpeechPart.Adverb; } if (remaining.Contains("C")) { part |= Vocabulary.SpeechPart.Conjunction; } if (remaining.Contains("P")) { part |= Vocabulary.SpeechPart.Preposition; } if (remaining.Contains("!")) { part |= Vocabulary.SpeechPart.Interjection; } if (remaining.Contains("r")) { part |= Vocabulary.SpeechPart.Pronoun; } if (remaining.Contains("D")) { part |= Vocabulary.SpeechPart.DefArticle; } if (remaining.Contains("I")) { part |= Vocabulary.SpeechPart.IndefArticle; } if (remaining.Contains("o")) { part |= Vocabulary.SpeechPart.Nominative; } //Console.WriteLine ("Vocab word created: " + self + ". Part of speech: " + part); } }