Пример #1
0
        /// <summary>
        /// Returns a new settings object with the settings specified in the file as key value pair. Settings not beeing specified in this file will have the default value.
        /// </summary>
        /// <param name="settingLocation">Full qualified name of the settings file.</param>
        /// <returns>A settings object with the values specified in the file.</returns>
        public static ML_Settings readSettingsFromFile(string settingLocation)
        {
            ML_Settings mls = new ML_Settings();

            if (System.IO.File.Exists(settingLocation) == false)
            {
                GlobalState.logError.logLine("Could not load ML settings file! File (" + settingLocation + ") does not exit.");
                return(mls);
            }
            System.IO.StreamReader file = new System.IO.StreamReader(settingLocation);
            string line;

            while ((line = file.ReadLine()) != null)
            {
                string[] nameAndValue = line.Split(new char[] { ' ' }, 2);
                if (!mls.setSetting(nameAndValue[0], nameAndValue[1]))
                {
                    GlobalState.logError.logLine("MlSetting " + nameAndValue[0] + " not found!");
                }
            }
            file.Close();

            if (GlobalState.varModel != null && mls.blacklisted.Count > 0)
            {
                mls.checkAndCleanBlacklisted();
            }

            return(mls);
        }
Пример #2
0
        private void AddMlSetting_Click(object sender, EventArgs e)
        {
            MachineLearning.Learning.ML_Settings setting = new MachineLearning.Learning.ML_Settings();

            foreach (Control c in mlSettingsPanel.Controls)
            {
                if (c.Name.EndsWith("_textBox"))
                {
                    string fieldName = c.Name.Substring(0, c.Name.Length - "_textBox".Length);
                    setting.setSetting(fieldName, ((TextBox)c).Text);
                }
            }
            addedElementsList.Items.Add(new Container(CONTAINERKEY_MLSETTING, setting));
        }
Пример #3
0
        /// <summary>
        /// Returns a new settings object with the settings specified in the file as key value pair. Settings not beeing specified in this file will have the default value.
        /// </summary>
        /// <param name="settings">All settings to be changed in a string with whitespaces as separator .</param>
        /// <returns>A settings object with the values specified in the file.</returns>
        public static ML_Settings readSettings(string settings)
        {
            ML_Settings mls = new ML_Settings();

            String[] settingArray = settings.Split(' ');

            for (int i = 0; i < settingArray.Length; i++)
            {
                string[] nameAndValue = settingArray[i].Split(new char[] { ':' }, 2);
                if (!mls.setSetting(nameAndValue[0], nameAndValue[1]))
                {
                    GlobalState.logError.log("MlSetting " + nameAndValue[0] + " not found!");
                }
            }

            return(mls);
        }
Пример #4
0
        /// <summary>
        /// Returns a new settings object with the settings specified in the file as key value pair. Settings not beeing specified in this file will have the default value.
        /// </summary>
        /// <param name="settings">All settings to be changed in a string with whitespaces as separator .</param>
        /// <returns>A settings object with the values specified in the file.</returns>
        public static ML_Settings readSettings(string settings)
        {
            settings = settings.Trim();
            settings = settings.Replace(System.Environment.NewLine, "");
            ML_Settings mls = new ML_Settings();

            String[] settingArray = settings.Split(' ');

            for (int i = 0; i < settingArray.Length; i++)
            {
                string[] nameAndValue = settingArray[i].Split(new char[] { ':' }, 2);
                if (!mls.setSetting(nameAndValue[0], nameAndValue[1]))
                {
                    GlobalState.logError.logLine("MlSetting " + nameAndValue[0] + " not found!");
                }
            }

            if (GlobalState.varModel != null && mls.blacklisted.Count > 0)
            {
                mls.checkAndCleanBlacklisted();
            }

            return(mls);
        }
Пример #5
0
        private void AddMlSetting_Click(object sender, EventArgs e)
        {
            MachineLearning.Learning.ML_Settings setting = new MachineLearning.Learning.ML_Settings();

            foreach (Control c in mlSettingsPanel.Controls)
            {
                if (c.Name.EndsWith("_textBox"))
                {
                    string fieldName = c.Name.Substring(0, c.Name.Length - "_textBox".Length);
                    setting.setSetting(fieldName, ((TextBox)c).Text);
                }
            }
            addedElementsList.Items.Add(new Container(CONTAINERKEY_MLSETTING, setting));
        }
        /// <summary>
        /// Returns a new settings object with the settings specified in the file as key value pair. Settings not beeing specified in this file will have the default value. 
        /// </summary>
        /// <param name="settingLocation">Full qualified name of the settings file.</param>
        /// <returns>A settings object with the values specified in the file.</returns>
        public static ML_Settings readSettingsFromFile(string settingLocation)
        {
            ML_Settings mls = new ML_Settings();
            if (System.IO.File.Exists(settingLocation) == false)
            {
                GlobalState.logError.logLine("Could not load ML settings file! File (" + settingLocation + ") does not exit.");
                return mls;
            }
            System.IO.StreamReader file = new System.IO.StreamReader(settingLocation);
            string line;
            while ((line = file.ReadLine()) != null)
            {
                string[] nameAndValue = line.Split(new char[] { ' ' }, 2);
                if (!mls.setSetting(nameAndValue[0], nameAndValue[1]))
                {
                    GlobalState.logError.logLine("MlSetting " + nameAndValue[0] + " not found!");
                }
            }
            file.Close();

            return mls;
        }
        /// <summary>
        /// Returns a new settings object with the settings specified in the file as key value pair. Settings not beeing specified in this file will have the default value. 
        /// </summary>
        /// <param name="settings">All settings to be changed in a string with whitespaces as separator .</param>
        /// <returns>A settings object with the values specified in the file.</returns>
        public static ML_Settings readSettings(string settings)
        {
            settings = settings.Trim();
            settings = settings.Replace(System.Environment.NewLine, "");
            ML_Settings mls = new ML_Settings();
            String[] settingArray = settings.Split(' ');

            for (int i = 0; i < settingArray.Length; i++)
            {
                string[] nameAndValue = settingArray[i].Split(new char[] { ':' }, 2);
                if (!mls.setSetting(nameAndValue[0], nameAndValue[1]))
                {
                    GlobalState.logError.logLine("MlSetting " + nameAndValue[0] + " not found!");
                }

            }

            return mls;
        }