/// <summary>
        /// Вычисляет коэффициент взаимной информации
        /// </summary>
        /// <param name="bigramm"></param>
        /// <returns></returns>
        public double Calculate(string bigramm)
        {
            var freq = new Frequency(_words);
            var bigramWords = bigramm.Split(' ');

            var f1 = freq.GetByOneWord(bigramWords[0]);
            var f2 = freq.GetByOneWord(bigramWords[1]);
            var f12 = freq.GetByBigramm(bigramm);

            return Math.Log(((double)f12 * N) / (f1 * f2), 2);
        }
Beispiel #2
0
        /// <summary>
        /// Вычисляет коэффициент взаимной информации
        /// </summary>
        /// <param name="bigramm"></param>
        /// <returns></returns>
        public double Calculate(string bigramm)
        {
            var freq        = new Frequency(_words);
            var bigramWords = bigramm.Split(' ');

            var f1  = freq.GetByOneWord(bigramWords[0]);
            var f2  = freq.GetByOneWord(bigramWords[1]);
            var f12 = freq.GetByBigramm(bigramm);

            return(Math.Log(((double)f12 * N) / (f1 * f2), 2));
        }
Beispiel #3
0
        public double Calculate(string bigramm)
        {
            var bigrammWords = bigramm.Split(' ');

            if (bigrammWords.Count() != 2)
            {
                throw new ArgumentException("Для оценки частоты биграммы необходимо два слова.");
            }

            Frequency freq = new Frequency(_words);
            double    f1   = freq.GetByOneWord(bigrammWords[0]);
            double    f2   = freq.GetByOneWord(bigrammWords[1]);
            double    f12  = freq.GetByBigramm(bigramm);

            return((f12 - f1 * f2 / (_words.Count - 1)) / Math.Pow(f12, 2));
        }
Beispiel #4
0
 public double Calculate(string word, int collectionLength, int usedCount)
 {
     Frequency freq = new Frequency(_words);
     double f = freq.GetByOneWord(word);
     double TF = f / _words.Count;
     double IDF = Math.Log((collectionLength - usedCount)/usedCount);
     return TF * IDF;
 }
Beispiel #5
0
        public double Calculate(string word, int collectionLength, int usedCount)
        {
            Frequency freq = new Frequency(_words);
            double    f    = freq.GetByOneWord(word);
            double    TF   = f / _words.Count;
            double    IDF  = Math.Log((collectionLength - usedCount) / usedCount);

            return(TF * IDF);
        }