diff --git a/WanaKanaShaapu/Constants.cs b/WanaKanaShaapu/Constants.cs index 17a4d3c..9481484 100644 --- a/WanaKanaShaapu/Constants.cs +++ b/WanaKanaShaapu/Constants.cs @@ -1,4 +1,6 @@ -namespace WanaKanaShaapu +using System.Collections.Generic; + +namespace WanaKanaShaapu { public static class Constants { @@ -53,11 +55,11 @@ public static class Constants readonly public static CharacterRange[] MacronCharacterRanges = new CharacterRange[] { - new('\u0100', '\u0101'), - new('\u0112', '\u0113'), - new('\u012a', '\u012b'), - new('\u014C', '\u014D'), - new('\u016A', '\u016B') + new CharacterRange('\u0100', '\u0101'), + new CharacterRange('\u0112', '\u0113'), + new CharacterRange('\u012a', '\u012b'), + new CharacterRange('\u014C', '\u014D'), + new CharacterRange('\u016A', '\u016B') }; readonly public static CharacterRange[] KanaCharacterRanges = new CharacterRange[] @@ -192,7 +194,7 @@ public static class Constants "ヵ" }; - public static Dictionary SokuonWhitelist = new() + public static Dictionary SokuonWhitelist = new Dictionary() { { 'b', "b" }, { 'c', "t" }, @@ -214,7 +216,7 @@ public static class Constants { 'z', "z" } }; - public static Dictionary BasicKunrei = new () + public static Dictionary BasicKunrei = new Dictionary() { { "a", new (string Romaji, string Kana)[] { ("", "あ") } }, { "i", new (string Romaji, string Kana)[] { ("", "い") } }, diff --git a/WanaKanaShaapu/DefaultOptions.cs b/WanaKanaShaapu/DefaultOptions.cs index 9854e45..429b2b9 100644 --- a/WanaKanaShaapu/DefaultOptions.cs +++ b/WanaKanaShaapu/DefaultOptions.cs @@ -1,4 +1,6 @@ -namespace WanaKanaShaapu +using System.Collections.Generic; + +namespace WanaKanaShaapu { public class DefaultOptions { @@ -8,7 +10,7 @@ public class DefaultOptions public bool UpcaseKatakana { get; set; } public dynamic IMEMode { get; set; } public string Romanization { get; set; } = "hepburn"; - public Dictionary CustomKanaMapping = new(); - public Dictionary CustomRomajiMapping = new(); + public Dictionary CustomKanaMapping = new Dictionary(); + public Dictionary CustomRomajiMapping = new Dictionary(); } } \ No newline at end of file diff --git a/WanaKanaShaapu/Internal/Utils.cs b/WanaKanaShaapu/Internal/Utils.cs index 50ecaa0..37aaec0 100644 --- a/WanaKanaShaapu/Internal/Utils.cs +++ b/WanaKanaShaapu/Internal/Utils.cs @@ -1,9 +1,16 @@ -using System.Runtime.InteropServices; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; namespace WanaKanaShaapu.Internal { internal static class Utils { + internal static bool IsAscii(char c) + { + return c >= 0 && c <= 127; + } internal static bool IsMacron(char c) { foreach (var range in Constants.MacronCharacterRanges) @@ -89,7 +96,7 @@ internal static string GetTokenTypeCompact(char c) string letter = c.ToString(); if (WanaKana.IsJapanese(letter) && (Char.IsLetter(c) || Char.IsWhiteSpace(c))) return "ja"; - else if (Char.IsAscii(c) && (Char.IsLetter(c) || Char.IsWhiteSpace(c))) + else if (IsAscii(c) && (Char.IsLetter(c) || Char.IsWhiteSpace(c))) return "en"; else return "other"; @@ -116,9 +123,9 @@ internal static string GetTokenType(char c, string previousType, bool compact) return "japanesePunctuation"; else if (WanaKana.IsJapanese(letter)) return "ja"; - else if (Char.IsAscii(c) && Char.IsLetter(c)) + else if (IsAscii(c) && Char.IsLetter(c)) return "en"; - else if (Char.IsDigit(c) && Char.IsAscii(c)) + else if (Char.IsDigit(c) && IsAscii(c)) return "englishNumeral"; else if (Char.IsPunctuation(c)) return "englishPunctuation"; diff --git a/WanaKanaShaapu/Node.cs b/WanaKanaShaapu/Node.cs index d6bc8e6..2ea52e5 100644 --- a/WanaKanaShaapu/Node.cs +++ b/WanaKanaShaapu/Node.cs @@ -10,7 +10,7 @@ namespace WanaKanaShaapu public class Node { public string Data { get; set; } = string.Empty; - public Dictionary Children { get; set; } = new(); + public Dictionary Children { get; set; } = new Dictionary(); public Node FindChild(string key) { diff --git a/WanaKanaShaapu/Tokenization.cs b/WanaKanaShaapu/Tokenization.cs index 6be1cc6..33956a9 100644 --- a/WanaKanaShaapu/Tokenization.cs +++ b/WanaKanaShaapu/Tokenization.cs @@ -1,4 +1,6 @@ -using WanaKanaShaapu; +using System.Collections.Generic; +using System.Linq; +using WanaKanaShaapu; namespace WanaKanaShaapu { diff --git a/WanaKanaShaapu/TreeBuilder.cs b/WanaKanaShaapu/TreeBuilder.cs index 81adf90..357b149 100644 --- a/WanaKanaShaapu/TreeBuilder.cs +++ b/WanaKanaShaapu/TreeBuilder.cs @@ -1,4 +1,6 @@  +using System.Collections.Generic; +using System.Linq; using System.Text.Json; namespace WanaKanaShaapu diff --git a/WanaKanaShaapu/TreeConstants.cs b/WanaKanaShaapu/TreeConstants.cs index 98d3600..da9d3b3 100644 --- a/WanaKanaShaapu/TreeConstants.cs +++ b/WanaKanaShaapu/TreeConstants.cs @@ -1,4 +1,6 @@ -namespace WanaKanaShaapu +using System.Collections.Generic; + +namespace WanaKanaShaapu { public static class TreeConstants { diff --git a/WanaKanaShaapu/TreeTraverser.cs b/WanaKanaShaapu/TreeTraverser.cs index 661712f..fa34976 100644 --- a/WanaKanaShaapu/TreeTraverser.cs +++ b/WanaKanaShaapu/TreeTraverser.cs @@ -1,4 +1,6 @@ -using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; namespace WanaKanaShaapu { diff --git a/WanaKanaShaapu/WanaKana.cs b/WanaKanaShaapu/WanaKana.cs index 6be6593..8d6c442 100644 --- a/WanaKanaShaapu/WanaKana.cs +++ b/WanaKanaShaapu/WanaKana.cs @@ -1,4 +1,6 @@ -using System.Runtime.InteropServices; +using System; +using System.Linq; +using System.Runtime.InteropServices; using System.Text.RegularExpressions; using WanaKanaShaapu; using WanaKanaShaapu.Internal; diff --git a/WanaKanaShaapu/WanaKanaShaapu.csproj b/WanaKanaShaapu/WanaKanaShaapu.csproj index 84b164a..eeaeadc 100644 --- a/WanaKanaShaapu/WanaKanaShaapu.csproj +++ b/WanaKanaShaapu/WanaKanaShaapu.csproj @@ -1,8 +1,8 @@ - net6.0 - enable + netstandard2.1 + disable disable kmoroz @@ -18,6 +18,10 @@ + + + + True