コード例 #1
0
    void NoteUserSpeech(string key, DataStore.IValue value)
    {
        string input = value.ToString().Trim();

        if (string.IsNullOrEmpty(input))
        {
            return;
        }

        // Initialize a parser with the raw input
        var        parser = new Parser();
        ParseState st     = parser.InitState(input);

        // Apply parsing rules until we can do no more
        int rule;

        while ((rule = parser.NextStep(st)) > 0)
        {
            //Print(st.ToString() + " {" + rule + "}");
        }
        SetValue("user:parse", st.TreeForm(), "parsed: " + input);

        // Now, attempt to grok the input (convert it to a Communication)
        Communication comm = Grok.GrokInput(input, st);

        SetValue("user:communication", new CommunicationValue(comm), comm.ToString());
    }