aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations/TextEncoding/NLangDetect/ProbVector.cs
blob: c5a20dbf0a2407bd7812760b00d158d010afd13c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;

namespace NLangDetect.Core
{
  public class ProbVector
  {
    private readonly Dictionary<int, double> _dict = new Dictionary<int, double>();

    public double this[int key]
    {
      get
      {
        double value;

        return _dict.TryGetValue(key, out value) ? value : 0.0;
      }

      set
      {
        if (Math.Abs(value) < double.Epsilon)
        {
          if (_dict.ContainsKey(key))
          {
            _dict.Remove(key);
          }

          return;
        }

        _dict[key] = value;
      }
    }
  }
}