From 0e7cbb04651bd9b65668ca1635a4625640639560 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 17 Jun 2017 18:59:17 -0400 Subject: add subtitle language detection --- .../TextEncoding/NLangDetect/ProbVector.cs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Emby.Common.Implementations/TextEncoding/NLangDetect/ProbVector.cs (limited to 'Emby.Common.Implementations/TextEncoding/NLangDetect/ProbVector.cs') diff --git a/Emby.Common.Implementations/TextEncoding/NLangDetect/ProbVector.cs b/Emby.Common.Implementations/TextEncoding/NLangDetect/ProbVector.cs new file mode 100644 index 000000000..c5a20dbf0 --- /dev/null +++ b/Emby.Common.Implementations/TextEncoding/NLangDetect/ProbVector.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace NLangDetect.Core +{ + public class ProbVector + { + private readonly Dictionary _dict = new Dictionary(); + + 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; + } + } + } +} -- cgit v1.2.3