Esempio n. 1
0
        public string doSomething(O_NLP.RootObject _o_NLP)
        {
            string sentence = "";

            // Bind to the wit.ai NLP response class
            o_NLP = _o_NLP;
            conf  = (o_NLP.outcomes[0].confidence * 100);

            direction = o_NLP.outcomes [0].entities.direction [0].value;
            value     = o_NLP.outcomes [0].entities.distance[0].value;
            unit      = o_NLP.outcomes [0].entities.distance[0].unit;

            if (!direction.Equals("stop"))
            {
                PlayerMover.startMovement(direction, value, unit);
            }
            else
            {
                PlayerMover.stopMovement();
            }

            sentence += "sentence: " + o_NLP.outcomes[0]._text + "\n";
            sentence += "intent: move\n";
            sentence += "direction: " + direction + "\n";
            sentence += "value: " + value + "\n";
            sentence += "unit: " + unit + "\n";
            sentence += "confidence: " + conf + "\n";

            return(sentence);
        }
Esempio n. 2
0
        public string doSomething(O_NLP.RootObject _o_NLP)
        {
            // Bind to the wit.ai NLP response class
            o_NLP = _o_NLP;
            conf  = (o_NLP.outcomes[0].confidence * 100);

            direction = o_NLP.outcomes [0].entities.direction [0].value;
            value     = o_NLP.outcomes [0].entities.distance[0].value;
            unit      = o_NLP.outcomes [0].entities.distance[0].unit;

            if (!direction.Equals("stop"))
            {
                PlayerMover.startMovement(direction, value, unit);
            }
            else
            {
                PlayerMover.stopMovement();
            }

            string sentence = "";

            sentence += "Hello! I'm " + conf.ToString() + "% sure you set up lights.";

            return(sentence);
        }
Esempio n. 3
0
        public string doSomething(O_NLP.RootObject _o_NLP)
        {
            // Bind to the wit.ai NLP response class
            o_NLP = _o_NLP;



            conf = (o_NLP.outcomes[0].confidence * 100);

            state = o_NLP.outcomes[0].entities.on_off[0].value;

            if (state.Equals("on"))
            {
                LightsActuator.setActive(true);
            }
            else
            {
                LightsActuator.setActive(false);
            }


            string sentence = "";

            sentence += "sentence: " + o_NLP.outcomes [0]._text + "\n";
            sentence += "intent: lights\n";
            sentence += "state: " + state + "\n";
            sentence += "confidence: " + conf + "\n";

            return(sentence);
        }
Esempio n. 4
0
        private string ElaborateResponse(string nlp_text)
        {
            string sentence = "";
               	//log += "\n" + nlp_text;

            // If the audio file doesn't contain anything, or wit.ai doesn't understand it, a code 400 will be returned
            if (nlp_text.Contains("The remote server returned an error: (400) Bad Request"))
            {
                throw new Exception("The remote server returned an error: (400) Bad Request");
                //return "Sorry, didn't get that. Could you please repeat yourself?";
            }

            oNLP = Post_NLP_Processing.ParseData(nlp_text);

            // This codeblock dynamically casts the intent to the corresponding class
            // Check README.txt in Vitals.Brain

            try{

                Assembly objAssembly;
                objAssembly = Assembly.GetExecutingAssembly();

                Type classType = objAssembly.GetType("UnityHttpReq." + oNLP.outcomes[0].intent);

                if (classType == null)
                    log += "Error: can't recognize the intent";

                object obj = Activator.CreateInstance(classType);

                MethodInfo mi = classType.GetMethod("doSomething");

                object[] parameters = new object[1];
                parameters[0] = oNLP;

                mi = classType.GetMethod("doSomething");

                sentence = (string)mi.Invoke(obj, parameters);

            }
            catch (IndexOutOfRangeException e){
                UnityEngine.Debug.Log("Index out of range");
            }
            catch(NullReferenceException n)
            {
                UnityEngine.Debug.Log("null ref");

            }
            // Show what was deducted from the sentence
            //nlp_text += "\n\n"+sentence;
            log += sentence;
            return sentence;
        }
Esempio n. 5
0
        public string doSomething(O_NLP.RootObject _o_NLP)
        {
            // Bind to the wit.ai NLP response class
            o_NLP = _o_NLP;
            conf  = (o_NLP.outcomes[0].confidence * 100);

            state = o_NLP.outcomes[0].entities.on_off[0].value;

            if (state.Equals("on"))
            {
                LightsActuator.setActive(true);
            }
            else
            {
                LightsActuator.setActive(false);
            }

            string sentence = "";

            sentence += "Hello! I'm " + conf.ToString() + "% sure you set up lights.";

            return(sentence);
        }