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

Refactor some handlings and unit tests. #40

Merged
merged 1 commit into from
Mar 19, 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
2 changes: 1 addition & 1 deletion Tekkon.Tests/Tekkon.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ReleaseVersion>1.5.1</ReleaseVersion>
<ReleaseVersion>1.6.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
34 changes: 12 additions & 22 deletions Tekkon.Tests/TekkonTests.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
// (c) 2022 and onwards The vChewing Project (MIT-NTL License).
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

1. The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

2. No trademark license is granted to use the trade names, trademarks, service
marks, or product names of Contributor, except as required to fulfill notice
requirements above.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.

using NUnit.Framework;

Expand Down Expand Up @@ -183,8 +167,14 @@ public void TestPhonabetKeyReceivingAndCompositions() {
// Testing tool functions
Assert.AreEqual(Shared.RestoreToneOneInPhona("ㄉㄧㄠ"), "ㄉㄧㄠ1");
Assert.AreEqual(Shared.CnvPhonaToTextbookStyle("ㄓㄜ˙"), "˙ㄓㄜ");
Assert.AreEqual(Shared.CnvPhonaToHanyuPinyin("ㄍㄢˋ"), "gan4");
Assert.AreEqual(Shared.CnvHanyuPinyinToTextbookStyle("起(qi3)居(ju1)"),
"起(qǐ)居(jū)");
Assert.AreEqual(Shared.CnvHanyuPinyinToPhona("bian4-le5-tian1"),
"ㄅㄧㄢˋ-ㄌㄜ˙-ㄊㄧㄢ");
// 測試這種情形:「如果傳入的字串不包含任何半形英數內容的話,那麼應該直接將傳入的字串原樣返回」。
Assert.AreEqual(Shared.CnvHanyuPinyinToPhona("ㄅㄧㄢˋ-˙ㄌㄜ-ㄊㄧㄢ"),
"ㄅㄧㄢˋ-˙ㄌㄜ-ㄊㄧㄢ");
}

[Test]
Expand Down
14,976 changes: 7,482 additions & 7,494 deletions Tekkon.Tests/TekkonTests_Advanced.cs

Large diffs are not rendered by default.

28 changes: 6 additions & 22 deletions Tekkon.Tests/TekkonTests_Intermediate.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
// (c) 2022 and onwards The vChewing Project (MIT-NTL License).
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

1. The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

2. No trademark license is granted to use the trade names, trademarks, service
marks, or product names of Contributor, except as required to fulfill notice
requirements above.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.

using NUnit.Framework;

Expand Down
2 changes: 1 addition & 1 deletion Tekkon.sln
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ Global
$0.DotNetNamingPolicy = $4
$4.DirectoryNamespaceAssociation = PrefixedHierarchical
$0.StandardHeader = $5
version = 1.5.1
version = 1.6.0
EndGlobalSection
EndGlobal
63 changes: 32 additions & 31 deletions Tekkon/Composer.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
// (c) 2022 and onwards The vChewing Project (MIT-NTL License).
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

1. The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

2. No trademark license is granted to use the trade names, trademarks, service
marks, or product names of Contributor, except as required to fulfill notice
requirements above.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.

using System;
using System.Linq;
Expand Down Expand Up @@ -335,15 +319,21 @@ public void ReceiveKeyFromPhonabet(string phonabet = "") {
}
if ((thePhone.Type is PhoneType.Intonation or PhoneType.Vowel) &&
(Consonant.Value is "ㄓ" or "ㄔ" or "ㄕ" or "ㄗ" or "ㄘ" or "ㄙ")) {
switch (Semivowel.Value) {
case "ㄧ":
switch (Semivowel.Value, Consonant.Value) {
case ("ㄧ", _):
Semivowel.Clear();
break;
case "ㄩ":
Consonant = Consonant.Value switch { "ㄓ" or "ㄗ" => new("ㄐ"),
"ㄔ" or "ㄘ" => new("ㄑ"),
"ㄕ" or "ㄙ" => new("ㄒ"),
_ => Consonant };
case ("ㄩ", "ㄓ"):
case ("ㄩ", "ㄗ"):
Consonant = new("ㄐ");
break;
case ("ㄩ", "ㄔ"):
case ("ㄩ", "ㄘ"):
Consonant = new("ㄑ");
break;
case ("ㄩ", "ㄕ"):
case ("ㄩ", "ㄙ"):
Consonant = new("ㄒ");
break;
}
}
Expand Down Expand Up @@ -829,10 +819,10 @@ private string HandleDachen26(string key = "") {
} else if (Semivowel.Value != "ㄩ" && Vowel.Value == "ㄡ") {
Vowel.Clear();
strReturn = "ㄩ";
} else if (!Semivowel.IsEmpty)
} else if (!Semivowel.IsEmpty || !"ㄐㄑㄒ".DoesHave(Consonant.Value))
strReturn = "ㄡ";
else
strReturn = ("ㄐㄑㄒ".DoesHave(Consonant.Value)) ? "ㄩ" : "ㄡ";
strReturn = "ㄩ";
break;
case "u":
if (Semivowel.Value == "ㄧ" && Vowel.Value != "ㄚ") {
Expand Down Expand Up @@ -949,6 +939,17 @@ private void CommonFixWhenHandlingDynamicArrangeInputs(
// 處理公共特殊情形。
switch (incomingPhonabet.Type) {
case PhoneType.Semivowel:
string newConstantStr =
(Consonant.Value, incomingPhonabet.Value) switch {
("ㄓ", "ㄧ") => "ㄐ",
("ㄓ", "ㄩ") => "ㄐ",
("ㄍ", "ㄩ") => "ㄑ",
("ㄔ", "ㄧ") => "ㄑ",
("ㄔ", "ㄩ") => "ㄑ",
("ㄕ", "ㄧ") => "ㄒ",
("ㄕ", "ㄩ") => "ㄒ",
_ => "",
};
switch (Consonant.Value) {
case "ㄍ":
// 這裡不處理「ㄍㄧ」到「ㄑㄧ」的轉換,因為只有倚天26需要處理這個。
Expand Down
28 changes: 6 additions & 22 deletions Tekkon/Enums.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
// (c) 2022 and onwards The vChewing Project (MIT-NTL License).
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

1. The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

2. No trademark license is granted to use the trade names, trademarks, service
marks, or product names of Contributor, except as required to fulfill notice
requirements above.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.

namespace Tekkon {
/// <summary>
Expand Down
28 changes: 6 additions & 22 deletions Tekkon/Phonabet.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
// (c) 2022 and onwards The vChewing Project (MIT-NTL License).
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

1. The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

2. No trademark license is granted to use the trade names, trademarks, service
marks, or product names of Contributor, except as required to fulfill notice
requirements above.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.

using System;
using System.Linq;
Expand Down
28 changes: 6 additions & 22 deletions Tekkon/Shared.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
// (c) 2022 and onwards The vChewing Project (MIT-NTL License).
/*
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

1. The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

2. No trademark license is granted to use the trade names, trademarks, service
marks, or product names of Contributor, except as required to fulfill notice
requirements above.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.

using System.Collections.Generic;
using System.Linq;
Expand Down
8 changes: 4 additions & 4 deletions Tekkon/Tekkon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<CodePage>65001</CodePage>
<ReleaseVersion>1.5.1</ReleaseVersion>
<ReleaseVersion>1.6.0</ReleaseVersion>
<PackageId>vChewing.Tekkon</PackageId>
<Authors>Shiki Suen</Authors>
<Company>Atelier Inmu</Company>
<Copyright>(c) 2022 and onwards The vChewing Project (MIT-NTL License).</Copyright>
<RepositoryUrl>https://github.com/ShikiSuen/TekkonNT</RepositoryUrl>
<NeutralLanguage>zh-TW</NeutralLanguage>
<AssemblyVersion>1.5.1</AssemblyVersion>
<FileVersion>1.5.1</FileVersion>
<Version>1.5.1</Version>
<AssemblyVersion>1.6.0</AssemblyVersion>
<FileVersion>1.6.0</FileVersion>
<Version>1.6.0</Version>
<Product>Tekkon</Product>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
Loading