Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make project netstandard compatible #4

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
make project netstandard compatible
  • Loading branch information
kmoroz committed Sep 3, 2024
commit ae6815fb0a3a867080204cc8c8827554919edccd
18 changes: 10 additions & 8 deletions WanaKanaShaapu/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace WanaKanaShaapu
using System.Collections.Generic;

namespace WanaKanaShaapu
{
public static class Constants
{
Expand Down Expand Up @@ -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[]
Expand Down Expand Up @@ -192,7 +194,7 @@ public static class Constants
"ヵ"
};

public static Dictionary<char, string> SokuonWhitelist = new()
public static Dictionary<char, string> SokuonWhitelist = new Dictionary<char, string>()
{
{ 'b', "b" },
{ 'c', "t" },
Expand All @@ -214,7 +216,7 @@ public static class Constants
{ 'z', "z" }
};

public static Dictionary<string, (string Romaji, string Kana)[]> BasicKunrei = new ()
public static Dictionary<string, (string Romaji, string Kana)[]> BasicKunrei = new Dictionary<string, (string Romaji, string Kana)[]>()
{
{ "a", new (string Romaji, string Kana)[] { ("", "あ") } },
{ "i", new (string Romaji, string Kana)[] { ("", "い") } },
Expand Down
8 changes: 5 additions & 3 deletions WanaKanaShaapu/DefaultOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace WanaKanaShaapu
using System.Collections.Generic;

namespace WanaKanaShaapu
{
public class DefaultOptions
{
Expand All @@ -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<string, string> CustomKanaMapping = new();
public Dictionary<string, string> CustomRomajiMapping = new();
public Dictionary<string, string> CustomKanaMapping = new Dictionary<string, string>();
public Dictionary<string, string> CustomRomajiMapping = new Dictionary<string, string>();
}
}
15 changes: 11 additions & 4 deletions WanaKanaShaapu/Internal/Utils.cs
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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";
Expand All @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion WanaKanaShaapu/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace WanaKanaShaapu
public class Node
{
public string Data { get; set; } = string.Empty;
public Dictionary<string, Node> Children { get; set; } = new();
public Dictionary<string, Node> Children { get; set; } = new Dictionary<string, Node>();

public Node FindChild(string key)
{
Expand Down
4 changes: 3 additions & 1 deletion WanaKanaShaapu/Tokenization.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using WanaKanaShaapu;
using System.Collections.Generic;
using System.Linq;
using WanaKanaShaapu;

namespace WanaKanaShaapu
{
Expand Down
2 changes: 2 additions & 0 deletions WanaKanaShaapu/TreeBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

using System.Collections.Generic;
using System.Linq;
using System.Text.Json;

namespace WanaKanaShaapu
Expand Down
4 changes: 3 additions & 1 deletion WanaKanaShaapu/TreeConstants.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace WanaKanaShaapu
using System.Collections.Generic;

namespace WanaKanaShaapu
{
public static class TreeConstants
{
Expand Down
4 changes: 3 additions & 1 deletion WanaKanaShaapu/TreeTraverser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;

namespace WanaKanaShaapu
{
Expand Down
4 changes: 3 additions & 1 deletion WanaKanaShaapu/WanaKana.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 6 additions & 2 deletions WanaKanaShaapu/WanaKanaShaapu.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>netstandard2.1</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<Company />
<Authors>kmoroz</Authors>
Expand All @@ -18,6 +18,10 @@
<EmbeddedResource Include="wanikanilogo.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
<None Update="wanikanilogo.png">
<Pack>True</Pack>
Expand Down
Loading