aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/TextEncoding/NLangDetect/ProbVector.cs
blob: d7afb41133b66917829f62a841f61f7ebf0978be (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
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
            {
                return _dict.TryGetValue(key, out var value) ? value : 0.0;
            }

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

                    return;
                }

                _dict[key] = value;
            }
        }
    }
}