コード例 #1
0
ファイル: Grammar.cs プロジェクト: threax/syn-speech
        /**
         * /// 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());
        }
コード例 #2
0
ファイル: GrammarNode.cs プロジェクト: threax/syn-speech
        /**
         * /// 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 + "\"");
        }