Skip to content

Commit

Permalink
Merge pull request #271 from andy840119/fix-language-detection
Browse files Browse the repository at this point in the history
Fix Japanese lyric cannot be detected.
  • Loading branch information
andy840119 authored Nov 29, 2020
2 parents 9162ff0 + bc5c6ae commit 4fc1c29
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,16 @@ public class LanguageDetectorTest
{
[TestCase("花火大会", "zh-CN")]
[TestCase("花火大會", "zh-TW")]
[TestCase("Testing", "en-US")]
[TestCase("Testing", "en")]
[TestCase("ハナビ", "ja")]
[TestCase("はなび", "ja")]
public void TestDetectLanguage(string text, string language)
{
var detector = new LanguageDetector(generageConfig());
var result = detector.DetectLanguage(new Lyric { Text = text });
Assert.AreEqual(result, new CultureInfo(language));
}

[Ignore("Japanese text not supported now")]
[TestCase("ハナビ", "ja-jp")]
[TestCase("はなび", "ja-jp")]
public void TestJapaneseLanguage(string text, string language)
{
// todo : should fix this dictionary to add all Hiragana and Katakana
// https://github.com/pdonald/language-detection/blob/master/LanguageDetection/Profiles/ja
TestDetectLanguage(text, language);
}

private LanguageDetectorConfig generageConfig()
{
return new LanguageDetectorConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ public CultureInfo DetectLanguage(Lyric lyric)
if (languageCode == null)
return null;

// make some language conversion here
switch (languageCode)
{
// todo : need to think about is this needed?
case "en":
return new CultureInfo("en-US");
default:
return new CultureInfo(languageCode);
}
return new CultureInfo(languageCode);
}
}
}
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ILRepack.MSBuild.Task" Version="2.0.13" />
<PackageReference Include="LanguageDetection" Version="1.2.0" />
<PackageReference Include="LanguageDetection.karaoke-dev" Version="1.3.3-alpha" />
<PackageReference Include="Octokit" Version="0.48.0" />
<PackageReference Include="osu.Framework.KaraokeFont" Version="1.2.0" />
<PackageReference Include="osu.Framework.Microphone" Version="1.0.10" />
Expand Down

0 comments on commit 4fc1c29

Please sign in to comment.