private void ButtonTrainingClick(object sender, EventArgs e)
        {
            var languageDetected = new Dictionary <string, double>();

            foreach (string language in Settings.Default.ListOfLanguages.Split(','))
            {
                languageDetected.Add(language, 0.0);
            }

            var listOfWords         = AIHelper.SplitWords(AIHelper.RemovePunctuation(textBoxSource.Text));
            var languageDetectedTmp = new Dictionary <string, double>();

            foreach (KeyValuePair <string, double> pair in languageDetected)
            {
                languageDetectedTmp[pair.Key] = AIHelper.CountFoundWords(GetLanguageWords(pair.Key), listOfWords.Keys.ToList());
            }

            double maxValue = languageDetectedTmp.Max(v => v.Value);
            string languageDetectedGuess = "unknown";

            if (maxValue != 0.0)
            {
                languageDetectedGuess = languageDetectedTmp
                                        .FirstOrDefault(x => x.Value == maxValue).Key;
            }

            //labelLanguageDetected.Text = $"Language detected is : {languageDetectedGuess.ToUpper()}";
            //labelLanguageDetected.ForeColor = GetColor(languageDetectedGuess);
        }
        public void TestMethodCountFoundWords25Percent()
        {
            var source1 = new List <string> {
                "you", "are", "he", "is"
            };
            var source2 = new List <string> {
                "you"
            };
            const double Expected = 0.25;
            var          result   = AIHelper.CountFoundWords(source1, source2);

            Assert.AreEqual(result, Expected);
        }
        public void TestMethodCountFoundWords50PercentWithUpperLetters()
        {
            var source1 = new List <string> {
                "you", "are", "he", "is"
            };
            var source2 = new List <string> {
                "YOU", "ARE"
            };
            const double Expected = 0.5;
            var          result   = AIHelper.CountFoundWords(source1, source2);

            Assert.AreEqual(result, Expected);
        }
        public void TestMethodCountFoundWords100Percent_UpperLettersReference()
        {
            var source1 = new List <string> {
                "YOU", "ARE", "HE", "IS"
            };
            var source2 = new List <string> {
                "you", "are", "he", "is"
            };
            const double Expected = 0.0;
            double       result   = AIHelper.CountFoundWords(source1, source2);

            Assert.AreEqual(result, Expected);
            // assuming all reference words are in lower case.
        }