/** * /// Returns a random sentence that fits this grammar * * /// @return a random sentence that fits this grammar */ public string GetRandomSentence() { StringBuilder sb = new StringBuilder(); GrammarNode node = InitialNode; while (!node.IsFinalNode) { if (!node.IsEmpty) { Word word = node.GetWord(); if (!word.IsFiller) { sb.Append(word.Spelling).Append(" "); } } node = SelectRandomSuccessor(node); } return(sb.ToString().Trim()); }
/** * /// Given a node, returns a GDL Label for the node * * /// @param node the node * /// @return a gdl label for the node */ string GetGDLLabel(GrammarNode node) { string label = node.IsEmpty ? "" : node.GetWord().Spelling; return("\"" + label + "\""); }