Esempio n. 1
0
        public Match Matches(string input, Hashtable vars, CSharpToolbox csToolbox)
        {
            Match match = new Match();

            if (this.regex.IsMatch(input))
            {
                //copy shortTermMemory vars to inputVars
                Hashtable inputVars = new Hashtable();
                foreach (object key in vars.Keys)
                {
                    inputVars[key] = vars[key];
                }
                //captures the variables and adds them to the inputVars object
                this.CaptureVars(input, inputVars);

                if (csToolbox.ExecuteCondition(this.inputId, inputVars))
                {
                    double noise      = InputRecognizer.random.NextDouble() * 0.0001;
                    double usageBonus = (0.01 / (this.usageCount + 1)); //goes lower the more it's used
                    double cf         = 0;
                    if (this.length == 0)                               //is this ever true? yes, when input is *
                    {
                        cf = usageBonus + noise + 0.0001;
                    }
                    else
                    {
                        cf = usageBonus + noise + (this.length / (double)input.Length);
                    }
                    match.InputRecognizer  = this;
                    match.Vars             = inputVars;
                    match.ConfidenceFactor = cf;
                }
            }    //if(this.regex.IsMatch(input))
            return(match);
        }        //Matches(string input)
Esempio n. 2
0
 private void initializeCSToolbox()
 {
     this.csToolbox = new CSharpToolbox();
     this.csToolbox.OnCompileError += new Conversive.Verbot5.CSharpToolbox.CompileError(csToolbox_OnCompileError);
     this.csToolbox.OnCompileWarning += new Conversive.Verbot5.CSharpToolbox.CompileWarning(csToolbox_OnCompileWarning);
 }
Esempio n. 3
0
        public Match Matches(string input, Hashtable vars, CSharpToolbox csToolbox)
        {
            Match match = new Match();
            if(this.regex.IsMatch(input))
            {
                //copy shortTermMemory vars to inputVars
                Hashtable inputVars = new Hashtable();
                foreach(object key in vars.Keys)
                    inputVars[key] = vars[key];
                //captures the variables and adds them to the inputVars object
                this.CaptureVars(input, inputVars);

                if(csToolbox.ExecuteCondition(this.inputId, inputVars))
                {
                    double noise = InputRecognizer.random.NextDouble() * 0.0001;
                    double usageBonus = (0.01 / (this.usageCount + 1));//goes lower the more it's used
                    double cf = 0;
                    if(this.length == 0)//is this ever true? yes, when input is *
                        cf = usageBonus + noise + 0.0001;
                    else
                        cf = usageBonus + noise + (this.length / (double)input.Length);
                    match.InputRecognizer = this;
                    match.Vars = inputVars;
                    match.ConfidenceFactor = cf;
                }
            }//if(this.regex.IsMatch(input))
            return match;
        }
Esempio n. 4
0
 private void initializeCSToolbox()
 {
     this.csToolbox = new CSharpToolbox();
     this.csToolbox.OnCompileError   += new Conversive.Verbot5.CSharpToolbox.CompileError(csToolbox_OnCompileError);
     this.csToolbox.OnCompileWarning += new Conversive.Verbot5.CSharpToolbox.CompileWarning(csToolbox_OnCompileWarning);
 }