mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-08-28 05:10:30 +00:00
merge common implementations and server implementations
This commit is contained in:
parent
e3531534b8
commit
bfcd1b520f
389 changed files with 1212 additions and 1626 deletions
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
||||
namespace NLangDetect.Core
|
||||
{
|
||||
// TODO IMM HI: change to non-static class
|
||||
// TODO IMM HI: hide other, unnecassary classes via internal?
|
||||
public static class LanguageDetector
|
||||
{
|
||||
private const double _DefaultAlpha = 0.5;
|
||||
|
||||
#region Public methods
|
||||
|
||||
public static void Initialize(IJsonSerializer json)
|
||||
{
|
||||
DetectorFactory.LoadProfiles(json);
|
||||
}
|
||||
|
||||
public static void Release()
|
||||
{
|
||||
DetectorFactory.Clear();
|
||||
}
|
||||
|
||||
public static string DetectLanguage(string plainText)
|
||||
{
|
||||
if (string.IsNullOrEmpty(plainText)) { throw new ArgumentException("Argument can't be null nor empty.", "plainText"); }
|
||||
|
||||
Detector detector = DetectorFactory.Create(_DefaultAlpha);
|
||||
|
||||
detector.Append(plainText);
|
||||
|
||||
return detector.Detect();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue