aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions')
-rw-r--r--Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs94
-rw-r--r--Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs76
-rw-r--r--Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/UnicodeBlock.cs258
3 files changed, 214 insertions, 214 deletions
diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs
index cd77a30eb..6e58a0be8 100644
--- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs
+++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/CharExtensions.cs
@@ -1,14 +1,14 @@
-using System;
+using System;
namespace NLangDetect.Core.Extensions
{
- public static class CharExtensions
- {
- private const int MIN_CODE_POINT = 0x000000;
- private const int MAX_CODE_POINT = 0x10ffff;
+ public static class CharExtensions
+ {
+ private const int MIN_CODE_POINT = 0x000000;
+ private const int MAX_CODE_POINT = 0x10ffff;
- private static readonly int[] _unicodeBlockStarts =
- {
+ private static readonly int[] _unicodeBlockStarts =
+ {
#region Unicode block starts
0x0000, // Basic Latin
@@ -165,8 +165,8 @@ namespace NLangDetect.Core.Extensions
#endregion
};
- private static readonly UnicodeBlock?[] _unicodeBlocks =
- {
+ private static readonly UnicodeBlock?[] _unicodeBlocks =
+ {
#region Unicode blocks
UnicodeBlock.BasicLatin,
UnicodeBlock.Latin1Supplement,
@@ -322,53 +322,53 @@ namespace NLangDetect.Core.Extensions
#endregion
};
- #region Public methods
+ #region Public methods
- /// <remarks>
- /// Taken from JDK source: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Character.java#Character.UnicodeBlock.0LATIN_EXTENDED_ADDITIONAL
- /// </remarks>
- public static UnicodeBlock? GetUnicodeBlock(this char ch)
- {
- int codePoint = ch;
+ /// <remarks>
+ /// Taken from JDK source: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Character.java#Character.UnicodeBlock.0LATIN_EXTENDED_ADDITIONAL
+ /// </remarks>
+ public static UnicodeBlock? GetUnicodeBlock(this char ch)
+ {
+ int codePoint = ch;
- if (!IsValidCodePoint(codePoint))
- {
- throw new ArgumentException("Argument is not a valid code point.", nameof(ch));
- }
+ if (!IsValidCodePoint(codePoint))
+ {
+ throw new ArgumentException("Argument is not a valid code point.", nameof(ch));
+ }
- int top, bottom, current;
+ int top, bottom, current;
- bottom = 0;
- top = _unicodeBlockStarts.Length;
- current = top / 2;
+ bottom = 0;
+ top = _unicodeBlockStarts.Length;
+ current = top / 2;
- // invariant: top > current >= bottom && codePoint >= unicodeBlockStarts[bottom]
- while (top - bottom > 1)
- {
- if (codePoint >= _unicodeBlockStarts[current])
- {
- bottom = current;
- }
- else
- {
- top = current;
- }
+ // invariant: top > current >= bottom && codePoint >= unicodeBlockStarts[bottom]
+ while (top - bottom > 1)
+ {
+ if (codePoint >= _unicodeBlockStarts[current])
+ {
+ bottom = current;
+ }
+ else
+ {
+ top = current;
+ }
- current = (top + bottom) / 2;
- }
+ current = (top + bottom) / 2;
+ }
- return _unicodeBlocks[current];
- }
+ return _unicodeBlocks[current];
+ }
- #endregion
+ #endregion
- #region Private helper methods
+ #region Private helper methods
- private static bool IsValidCodePoint(int codePoint)
- {
- return codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT;
- }
+ private static bool IsValidCodePoint(int codePoint)
+ {
+ return codePoint >= MIN_CODE_POINT && codePoint <= MAX_CODE_POINT;
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs
index d55ca80df..5b2fce60b 100644
--- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs
+++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/RandomExtensions.cs
@@ -1,51 +1,51 @@
-using System;
+using System;
namespace NLangDetect.Core.Extensions
{
- public static class RandomExtensions
- {
- private const double _Epsilon = 2.22044604925031E-15;
-
- private static readonly object _mutex = new object();
-
- private static double _nextNextGaussian;
- private static bool _hasNextNextGaussian;
-
- /// <summary>
- /// Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.
- /// The general contract of nextGaussian is that one double value, chosen from (approximately) the usual normal distribution with mean 0.0 and standard deviation 1.0, is pseudorandomly generated and returned.
- /// </summary>
- /// <remarks>
- /// Taken from: http://download.oracle.com/javase/6/docs/api/java/util/Random.html (nextGaussian())
- /// </remarks>
- public static double NextGaussian(this Random random)
+ public static class RandomExtensions
{
- lock (_mutex)
- {
- if (_hasNextNextGaussian)
- {
- _hasNextNextGaussian = false;
+ private const double _Epsilon = 2.22044604925031E-15;
- return _nextNextGaussian;
- }
+ private static readonly object _mutex = new object();
- double v1, v2, s;
+ private static double _nextNextGaussian;
+ private static bool _hasNextNextGaussian;
- do
+ /// <summary>
+ /// Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.
+ /// The general contract of nextGaussian is that one double value, chosen from (approximately) the usual normal distribution with mean 0.0 and standard deviation 1.0, is pseudorandomly generated and returned.
+ /// </summary>
+ /// <remarks>
+ /// Taken from: http://download.oracle.com/javase/6/docs/api/java/util/Random.html (nextGaussian())
+ /// </remarks>
+ public static double NextGaussian(this Random random)
{
- v1 = 2.0 * random.NextDouble() - 1.0; // between -1.0 and 1.0
- v2 = 2.0 * random.NextDouble() - 1.0; // between -1.0 and 1.0
- s = v1 * v1 + v2 * v2;
- }
- while (s >= 1.0 || Math.Abs(s - 0.0) < _Epsilon);
+ lock (_mutex)
+ {
+ if (_hasNextNextGaussian)
+ {
+ _hasNextNextGaussian = false;
+
+ return _nextNextGaussian;
+ }
- double multiplier = Math.Sqrt(-2.0 * Math.Log(s) / s);
+ double v1, v2, s;
- _nextNextGaussian = v2 * multiplier;
- _hasNextNextGaussian = true;
+ do
+ {
+ v1 = 2.0 * random.NextDouble() - 1.0; // between -1.0 and 1.0
+ v2 = 2.0 * random.NextDouble() - 1.0; // between -1.0 and 1.0
+ s = v1 * v1 + v2 * v2;
+ }
+ while (s >= 1.0 || Math.Abs(s - 0.0) < _Epsilon);
- return v1 * multiplier;
- }
+ double multiplier = Math.Sqrt(-2.0 * Math.Log(s) / s);
+
+ _nextNextGaussian = v2 * multiplier;
+ _hasNextNextGaussian = true;
+
+ return v1 * multiplier;
+ }
+ }
}
- }
}
diff --git a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/UnicodeBlock.cs b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/UnicodeBlock.cs
index 71b5de75e..bcc81f968 100644
--- a/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/UnicodeBlock.cs
+++ b/Emby.Server.Implementations/TextEncoding/NLangDetect/Extensions/UnicodeBlock.cs
@@ -1,131 +1,131 @@
-namespace NLangDetect.Core.Extensions
+namespace NLangDetect.Core.Extensions
{
- public enum UnicodeBlock
- {
- BasicLatin,
- Latin1Supplement,
- LatinExtendedA,
- LatinExtendedB,
- IpaExtensions,
- SpacingModifierLetters,
- CombiningDiacriticalMarks,
- Greek,
- Cyrillic,
- CyrillicSupplementary,
- Armenian,
- Hebrew,
- Arabic,
- Syriac,
- Thaana,
- Devanagari,
- Bengali,
- Gurmukhi,
- Gujarati,
- Oriya,
- Tamil,
- Telugu,
- Kannada,
- Malayalam,
- Sinhala,
- Thai,
- Lao,
- Tibetan,
- Myanmar,
- Georgian,
- HangulJamo,
- Ethiopic,
- Cherokee,
- UnifiedCanadianAboriginalSyllabics,
- Ogham,
- Runic,
- Tagalog,
- Hanunoo,
- Buhid,
- Tagbanwa,
- Khmer,
- Mongolian,
- Limbu,
- TaiLe,
- KhmerSymbols,
- PhoneticExtensions,
- LatinExtendedAdditional,
- GreekExtended,
- GeneralPunctuation,
- SuperscriptsAndSubscripts,
- CurrencySymbols,
- CombiningMarksForSymbols,
- LetterlikeSymbols,
- NumberForms,
- Arrows,
- MathematicalOperators,
- MiscellaneousTechnical,
- ControlPictures,
- OpticalCharacterRecognition,
- EnclosedAlphanumerics,
- BoxDrawing,
- BlockElements,
- GeometricShapes,
- MiscellaneousSymbols,
- Dingbats,
- MiscellaneousMathematicalSymbolsA,
- SupplementalArrowsA,
- BraillePatterns,
- SupplementalArrowsB,
- MiscellaneousMathematicalSymbolsB,
- SupplementalMathematicalOperators,
- MiscellaneousSymbolsAndArrows,
- CjkRadicalsSupplement,
- KangxiRadicals,
- IdeographicDescriptionCharacters,
- CjkSymbolsAndPunctuation,
- Hiragana,
- Katakana,
- Bopomofo,
- HangulCompatibilityJamo,
- Kanbun,
- BopomofoExtended,
- KatakanaPhoneticExtensions,
- EnclosedCjkLettersAndMonths,
- CjkCompatibility,
- CjkUnifiedIdeographsExtensionA,
- YijingHexagramSymbols,
- CjkUnifiedIdeographs,
- YiSyllables,
- YiRadicals,
- HangulSyllables,
- HighSurrogates,
- HighPrivateUseSurrogates,
- LowSurrogates,
- PrivateUseArea,
- CjkCompatibilityIdeographs,
- AlphabeticPresentationForms,
- ArabicPresentationFormsA,
- VariationSelectors,
- CombiningHalfMarks,
- CjkCompatibilityForms,
- SmallFormVariants,
- ArabicPresentationFormsB,
- HalfwidthAndFullwidthForms,
- Specials,
- LinearBSyllabary,
- LinearBIdeograms,
- AegeanNumbers,
- OldItalic,
- Gothic,
- Ugaritic,
- Deseret,
- Shavian,
- Osmanya,
- CypriotSyllabary,
- ByzantineMusicalSymbols,
- MusicalSymbols,
- TaiXuanJingSymbols,
- MathematicalAlphanumericSymbols,
- CjkUnifiedIdeographsExtensionB,
- CjkCompatibilityIdeographsSupplement,
- Tags,
- VariationSelectorsSupplement,
- SupplementaryPrivateUseAreaA,
- SupplementaryPrivateUseAreaB,
- }
+ public enum UnicodeBlock
+ {
+ BasicLatin,
+ Latin1Supplement,
+ LatinExtendedA,
+ LatinExtendedB,
+ IpaExtensions,
+ SpacingModifierLetters,
+ CombiningDiacriticalMarks,
+ Greek,
+ Cyrillic,
+ CyrillicSupplementary,
+ Armenian,
+ Hebrew,
+ Arabic,
+ Syriac,
+ Thaana,
+ Devanagari,
+ Bengali,
+ Gurmukhi,
+ Gujarati,
+ Oriya,
+ Tamil,
+ Telugu,
+ Kannada,
+ Malayalam,
+ Sinhala,
+ Thai,
+ Lao,
+ Tibetan,
+ Myanmar,
+ Georgian,
+ HangulJamo,
+ Ethiopic,
+ Cherokee,
+ UnifiedCanadianAboriginalSyllabics,
+ Ogham,
+ Runic,
+ Tagalog,
+ Hanunoo,
+ Buhid,
+ Tagbanwa,
+ Khmer,
+ Mongolian,
+ Limbu,
+ TaiLe,
+ KhmerSymbols,
+ PhoneticExtensions,
+ LatinExtendedAdditional,
+ GreekExtended,
+ GeneralPunctuation,
+ SuperscriptsAndSubscripts,
+ CurrencySymbols,
+ CombiningMarksForSymbols,
+ LetterlikeSymbols,
+ NumberForms,
+ Arrows,
+ MathematicalOperators,
+ MiscellaneousTechnical,
+ ControlPictures,
+ OpticalCharacterRecognition,
+ EnclosedAlphanumerics,
+ BoxDrawing,
+ BlockElements,
+ GeometricShapes,
+ MiscellaneousSymbols,
+ Dingbats,
+ MiscellaneousMathematicalSymbolsA,
+ SupplementalArrowsA,
+ BraillePatterns,
+ SupplementalArrowsB,
+ MiscellaneousMathematicalSymbolsB,
+ SupplementalMathematicalOperators,
+ MiscellaneousSymbolsAndArrows,
+ CjkRadicalsSupplement,
+ KangxiRadicals,
+ IdeographicDescriptionCharacters,
+ CjkSymbolsAndPunctuation,
+ Hiragana,
+ Katakana,
+ Bopomofo,
+ HangulCompatibilityJamo,
+ Kanbun,
+ BopomofoExtended,
+ KatakanaPhoneticExtensions,
+ EnclosedCjkLettersAndMonths,
+ CjkCompatibility,
+ CjkUnifiedIdeographsExtensionA,
+ YijingHexagramSymbols,
+ CjkUnifiedIdeographs,
+ YiSyllables,
+ YiRadicals,
+ HangulSyllables,
+ HighSurrogates,
+ HighPrivateUseSurrogates,
+ LowSurrogates,
+ PrivateUseArea,
+ CjkCompatibilityIdeographs,
+ AlphabeticPresentationForms,
+ ArabicPresentationFormsA,
+ VariationSelectors,
+ CombiningHalfMarks,
+ CjkCompatibilityForms,
+ SmallFormVariants,
+ ArabicPresentationFormsB,
+ HalfwidthAndFullwidthForms,
+ Specials,
+ LinearBSyllabary,
+ LinearBIdeograms,
+ AegeanNumbers,
+ OldItalic,
+ Gothic,
+ Ugaritic,
+ Deseret,
+ Shavian,
+ Osmanya,
+ CypriotSyllabary,
+ ByzantineMusicalSymbols,
+ MusicalSymbols,
+ TaiXuanJingSymbols,
+ MathematicalAlphanumericSymbols,
+ CjkUnifiedIdeographsExtensionB,
+ CjkCompatibilityIdeographsSupplement,
+ Tags,
+ VariationSelectorsSupplement,
+ SupplementaryPrivateUseAreaA,
+ SupplementaryPrivateUseAreaB,
+ }
}