예제 #1
0
        private string SetCommand(string[] commandComp)
        {
            //set _rawData = LoadFileAsMatrix("",T,' ');
            string[] rhs         = (commandComp.Count(c => c == "(") == 1) ? commandComp[3].Split('(') : commandComp[3].Split(new[] { '(' }, 2);
            string   varname     = commandComp[1];
            string   commandName = rhs[0];

            string[] args      = ParseArgs(rhs[1]);
            string   outputRHS = "";

            switch (commandName)
            {
            case "loadFileAsMatrix":
                MatrixData dataToAdd = loadFileAsMatrix(args[0], sb(args[1]), sc(args[2]));
                outputRHS += (_ANN.SetVar(varname, dataToAdd)) ? "set as new" : "replaced with";
                outputRHS += " " + dataToAdd.NumberOfRows + "x" + dataToAdd.NumberOfColumns + " MatrixData";
                break;

            case "copyMatrix":
                MatrixData copiedData = copyMatrix(args[0], si(args[1]), si(args[2]), si(args[3]), si(args[4]));
                outputRHS += (_ANN.SetVar(varname, copiedData)) ? "set as new" : "replaced with";
                outputRHS += " " + copiedData.NumberOfRows + "x" + copiedData.NumberOfColumns + " MatrixData from " + args[0];
                break;

            case "getExemplar":
                MatrixData exepData = getExemplar(args[0], si(args[1]), si(args[2]), si(args[3]), args[4]);
                outputRHS += (_ANN.SetVar(varname, exepData)) ? "set as new" : "replaced with";
                outputRHS += " " + exepData.NumberOfRows + "x" + exepData.NumberOfColumns + " MatrixData from " + args[0];
                break;

            case "var":
                outputRHS += (_ANN.SetVar(varname, _ANN.GetVar(args[0].Replace("$", "")))) ? "set as new" : "replaced with";
                outputRHS += " $" + args[0].Replace("$", "");
                break;

            case "int":
                outputRHS += (_ANN.SetVar(varname, si(args[0]))) ? "set to" : "replaced with";
                outputRHS += " " + _ANN.GetVarAs <int>(varname).ToString();
                break;

            case "double":
                outputRHS += (_ANN.SetVar(varname, sd(args[0]))) ? "set to" : "replaced with";
                outputRHS += " " + _ANN.GetVarAs <double>(varname).ToString();
                break;

            case "string":
                outputRHS += (_ANN.SetVar(varname, (string)Value(args[0]))) ? "set to" : "replaced with";
                outputRHS += " " + _ANN.GetVarAs <string>(varname).ToString();
                break;

            case "radomGen":
                Random rand = radomGen(si(args[0]));
                outputRHS += (_ANN.SetVar(varname, rand)) ? "set to" : "replaced with";
                outputRHS += " an instance of a \"Random\" object with seed " + args[0];
                break;

            case "nuralNetwork":
                var nn = nuralNetwork(si(args[0]), si(args[1]), si(args[2]), (Random)_ANN.GetVar((args[3])));
                outputRHS += (_ANN.SetVar(varname, nn)) ? "set to" : "replaced with";
                outputRHS += " an instance of a \"Nural Network\" object with " + si(args[0]) + " inputs, " + si(args[1]) + " hidden, " + si(args[2]) + " outputs.";
                break;

            case "getGraphData":
                var gd = getGraphData(args[0]);
                outputRHS += (_ANN.SetVar(varname, gd)) ? "set to" : "replaced with";
                outputRHS += " graph data from " + args[0];
                break;

            case "getConfusionMatrix":
                var cm = getConfusionMatrix(args[0], (string)Value(args[1]), (string)Value(args[2]));
                outputRHS += (_ANN.SetVar(varname, cm)) ? "set to" : "replaced with";
                outputRHS += " confusion matrix from " + args[0];
                break;



            default:
                return("the LHS 'set' command cannot be used with RHS command: \"" + commandName + "\"");
            }
            return("Variable \"" + varname + "\" " + outputRHS);
        }