Skip to content

Commit

Permalink
Merge pull request #2180 from andy840119/rename-from-romanization-to-…
Browse files Browse the repository at this point in the history
…romanisation

Romanization -> Romanisation
  • Loading branch information
andy840119 authored Mar 3, 2024
2 parents 771628e + ed7e997 commit f8da2b2
Show file tree
Hide file tree
Showing 35 changed files with 164 additions and 164 deletions.
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke.Tests/Asserts/TimeTagAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public static void ArePropertyEqual(TimeTag expect, TimeTag actually)
AreEqual(expect.Index, actually.Index);
AreEqual(expect.Time, actually.Time);
AreEqual(expect.FirstSyllable, actually.FirstSyllable);
AreEqual(expect.RomanizedSyllable, actually.RomanizedSyllable);
AreEqual(expect.RomanisedSyllable, actually.RomanisedSyllable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void TestAutoGenerateTimeTagRomaji()

AssertSelectedHitObject(h =>
{
Assert.AreEqual("karaoke", h.TimeTags[0].RomanizedSyllable);
Assert.AreEqual("karaoke", h.TimeTags[0].RomanisedSyllable);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void TestSetTimeTagFirstSyllable()
}

[Test]
public void TestSetTimeTagRomanizedSyllable()
public void TestSetTimeTagRomanisedSyllable()
{
var timeTag = new TimeTag(new TextIndex(), 1000);
PrepareHitObject(() => new Lyric
Expand All @@ -71,18 +71,18 @@ public void TestSetTimeTagRomanizedSyllable()
},
});

TriggerHandlerChanged(c => c.SetTimeTagRomanizedSyllable(timeTag, "karaoke"));
TriggerHandlerChanged(c => c.SetTimeTagRomanisedSyllable(timeTag, "karaoke"));

AssertSelectedHitObject(_ =>
{
Assert.AreEqual("karaoke", timeTag.RomanizedSyllable);
Assert.AreEqual("karaoke", timeTag.RomanisedSyllable);
});

TriggerHandlerChanged(c => c.SetTimeTagRomanizedSyllable(timeTag, " "));
TriggerHandlerChanged(c => c.SetTimeTagRomanisedSyllable(timeTag, " "));

AssertSelectedHitObject(_ =>
{
Assert.AreEqual(string.Empty, timeTag.RomanizedSyllable);
Assert.AreEqual(string.Empty, timeTag.RomanisedSyllable);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void TestCheckEmptyTime(string text, string[] timeTags)
[TestCase("カラオケ", "")] // should not be empty.
[TestCase("カラオケ", " ")] // should not be white-space only.
[TestCase("カラオケ", "卡拉OK")] // should be within latin.
public void TestCheckTimeTagRomajiInvalidText(string text, string romanizedSyllable)
public void TestCheckTimeTagRomajiInvalidText(string text, string romanisedSyllable)
{
var lyric = new Lyric
{
Expand All @@ -114,7 +114,7 @@ public void TestCheckTimeTagRomajiInvalidText(string text, string romanizedSylla
{
new TimeTag(new TextIndex())
{
RomanizedSyllable = romanizedSyllable,
RomanisedSyllable = romanisedSyllable,
Time = 1000,
},
new TimeTag(new TextIndex(3, TextIndex.IndexState.End))
Expand All @@ -128,7 +128,7 @@ public void TestCheckTimeTagRomajiInvalidText(string text, string romanizedSylla
}

[TestCase("カラオケ", null)] // should not be white-space only.
public void TestCheckRomajiEmptyTextIfFirst(string text, string romanizedSyllable)
public void TestCheckRomajiEmptyTextIfFirst(string text, string romanisedSyllable)
{
var lyric = new Lyric
{
Expand All @@ -137,7 +137,7 @@ public void TestCheckRomajiEmptyTextIfFirst(string text, string romanizedSyllabl
{
new TimeTag(new TextIndex())
{
RomanizedSyllable = romanizedSyllable,
RomanisedSyllable = romanisedSyllable,
FirstSyllable = true,
Time = 1000,
},
Expand All @@ -154,7 +154,7 @@ public void TestCheckRomajiEmptyTextIfFirst(string text, string romanizedSyllabl
[TestCase("カラオケ", "")] // should not have empty text if end.
[TestCase("カラオケ", " ")] // should not have empty text if end.
[TestCase("カラオケ", "123")] // should not have empty text if end.
public void TestRomajiNotHaveEmptyTextIfEnd(string text, string romanizedSyllable)
public void TestRomajiNotHaveEmptyTextIfEnd(string text, string romanisedSyllable)
{
var lyric = new Lyric
{
Expand All @@ -167,7 +167,7 @@ public void TestRomajiNotHaveEmptyTextIfEnd(string text, string romanizedSyllabl
},
new TimeTag(new TextIndex(3, TextIndex.IndexState.End))
{
RomanizedSyllable = romanizedSyllable,
RomanisedSyllable = romanisedSyllable,
Time = 2000,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Game.Rulesets.Karaoke.Edit.Generator.Lyrics.Romanization;
using osu.Game.Rulesets.Karaoke.Edit.Generator.Lyrics.Romanisation;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Tests.Asserts;

namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.Romanization;
namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.Romanisation;

public abstract class BaseRomanizationGeneratorTest<TRomanizationGenerator, TConfig> : BaseLyricGeneratorTest<TRomanizationGenerator, IReadOnlyDictionary<TimeTag, RomanizationGenerateResult>, TConfig>
where TRomanizationGenerator : RomanizationGenerator<TConfig> where TConfig : RomanizationGeneratorConfig, new()
public abstract class BaseRomanisationGeneratorTest<TRomanisationGenerator, TConfig> : BaseLyricGeneratorTest<TRomanisationGenerator, IReadOnlyDictionary<TimeTag, RomanisationGenerateResult>, TConfig>
where TRomanisationGenerator : RomanisationGenerator<TConfig> where TConfig : RomanisationGeneratorConfig, new()
{
protected void CheckGenerateResult(Lyric lyric, string[] expectedRubies, TConfig config)
{
var expected = RomanizationGenerateResultHelper.ParseRomanizationGenerateResults(lyric.TimeTags, expectedRubies);
var expected = RomanisationGenerateResultHelper.ParseRomanisationGenerateResults(lyric.TimeTags, expectedRubies);
CheckGenerateResult(lyric, expected, config);
}

protected override void AssertEqual(IReadOnlyDictionary<TimeTag, RomanizationGenerateResult> expected, IReadOnlyDictionary<TimeTag, RomanizationGenerateResult> actual)
protected override void AssertEqual(IReadOnlyDictionary<TimeTag, RomanisationGenerateResult> expected, IReadOnlyDictionary<TimeTag, RomanisationGenerateResult> actual)
{
TimeTagAssert.ArePropertyEqual(expected.Select(x => x.Key).ToArray(), actual.Select(x => x.Key).ToArray());
Assert.AreEqual(expected.Select(x => x.Value), actual.Select(x => x.Value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Game.Rulesets.Karaoke.Edit.Generator.Lyrics.Romanization.Ja;
using osu.Game.Rulesets.Karaoke.Edit.Generator.Lyrics.Romanisation.Ja;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Tests.Helper;

namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.Romanization.Ja;
namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.Romanisation.Ja;

public class JaRomanizationGeneratorTest : BaseRomanizationGeneratorTest<JaRomanizationGenerator, JaRomanizationGeneratorConfig>
public class JaRomanisationGeneratorTest : BaseRomanisationGeneratorTest<JaRomanisationGenerator, JaRomanisationGeneratorConfig>
{
[TestCase("花火大会", new[] { "[0,start]", "[3,end]" }, true)]
[TestCase("花火大会", new[] { "[0,start]" }, true)]
[TestCase("花火大会", new[] { "[3,end]" }, false)] // not able to generate the has no start time-tag.
[TestCase("花火大会", new string[] { }, false)] // not able to make the romanization if has no time-tag.
[TestCase("", new string[] { }, false)] // not able to make the romanization if lyric is empty.
[TestCase("花火大会", new string[] { }, false)] // not able to make the romanisation if has no time-tag.
[TestCase("", new string[] { }, false)] // not able to make the romanisation if lyric is empty.
[TestCase(" ", new string[] { }, false)]
[TestCase(null, new string[] { }, false)]
public void TestCanGenerate(string text, string[] timeTagStrings, bool canGenerate)
Expand All @@ -40,7 +40,7 @@ public void TestCanGenerate(string text, string[] timeTagStrings, bool canGenera
[TestCase("枯れた世界に輝く",
new[] { "[0,start]", "[1,start]", "[2,start]", "[3,start]", "[4,start]", "[5,start]", "[6,start]", "[6,start]", "[6,start]", "[7,start]", "[7,end]" },
new[] { "^kare", "", "ta", "sekai", "", "ni", "kagayaku", "", "", "", "" })]
public void TestGenerate(string text, string[] timeTagStrings, string[] expectedRomanizedSyllables)
public void TestGenerate(string text, string[] timeTagStrings, string[] expectedRomanisedSyllables)
{
var config = GeneratorEmptyConfig();

Expand All @@ -51,12 +51,12 @@ public void TestGenerate(string text, string[] timeTagStrings, string[] expected
TimeTags = timeTags,
};

CheckGenerateResult(lyric, expectedRomanizedSyllables, config);
CheckGenerateResult(lyric, expectedRomanisedSyllables, config);
}

[TestCase("はなび", new[] { "[0,start]" }, new[] { "^HANA BI" })]
[TestCase("花火大会", new[] { "[0,start]", "[2,start]", "[3,end]" }, new[] { "^HANABI", "TAIKAI", "" })]
public void TestGenerateWithUppercase(string text, string[] timeTagStrings, string[] expectedRomanizedSyllables)
public void TestGenerateWithUppercase(string text, string[] timeTagStrings, string[] expectedRomanisedSyllables)
{
var config = GeneratorEmptyConfig(x => x.Uppercase.Value = true);

Expand All @@ -67,21 +67,21 @@ public void TestGenerateWithUppercase(string text, string[] timeTagStrings, stri
TimeTags = timeTags,
};

CheckGenerateResult(lyric, expectedRomanizedSyllables, config);
CheckGenerateResult(lyric, expectedRomanisedSyllables, config);
}

[TestCase("花", new[] { "[0,start]", "[0,end]" }, new[] { "[0]:hana" }, new[] { "^hana", "" })]
[TestCase("花火", new[] { "[0,start]", "[1,end]" }, new[] { "[0]:hana", "[1]:bi" }, new[] { "^hana bi", "" })]
[TestCase("花火", new[] { "[0,start]", "[1,start]", "[1,end]" }, new[] { "[0]:hana", "[1]:bi" }, new[] { "^hana", "bi", "" })]
[TestCase("花火", new[] { "[0,start]", "[0,start]", "[1,start]", "[1,end]" }, new[] { "[0]:hana", "[1]:bi" }, new[] { "^hana", "", "bi", "" })]
[TestCase("はなび", new[] { "[0,start]", "[1,start]", "[2,start]", "[2,end]" }, new[] { "[0]:hana", "[2]:bi" }, new[] { "^hana", "", "bi", "" })]
public void TestConvertToRomanizationGenerateResult(string text, string[] timeTagStrings, string[] romanizationParams, string[] expectedResults)
public void TestConvertToRomanisationGenerateResult(string text, string[] timeTagStrings, string[] romanisationParams, string[] expectedResults)
{
var timeTags = TestCaseTagHelper.ParseTimeTags(timeTagStrings);
var romanizations = parseRomanizationGenerateResults(romanizationParams);
var results = parseRomanisationGenerateResults(romanisationParams);

var expected = RomanizationGenerateResultHelper.ParseRomanizationGenerateResults(timeTags, expectedResults);
var actual = JaRomanizationGenerator.Convert(timeTags, romanizations);
var expected = RomanisationGenerateResultHelper.ParseRomanisationGenerateResults(timeTags, expectedResults);
var actual = JaRomanisationGenerator.Convert(timeTags, results);

AssertEqual(expected, actual);
}
Expand All @@ -90,19 +90,19 @@ public void TestConvertToRomanizationGenerateResult(string text, string[] timeTa
/// Process test case time tag string format into <see cref="TimeTag"/>
/// </summary>
/// <param name="str">Time tag string format</param>
/// <returns><see cref="RomanizationGenerateResultHelper"/>Time tag object</returns>
private static JaRomanizationGenerator.RomanizationGeneratorParameter parseRomanizationGenerateResult(string str)
/// <returns><see cref="RomanisationGenerateResultHelper"/>Time tag object</returns>
private static JaRomanisationGenerator.RomanisationGeneratorParameter parseRomanisationGenerateResult(string str)
{
// because format is same as the text-tag testing format, so just use this helper.
var romajiTag = TestCaseTagHelper.ParseRomajiTag(str);
return new JaRomanizationGenerator.RomanizationGeneratorParameter
return new JaRomanisationGenerator.RomanisationGeneratorParameter
{
StartIndex = romajiTag.StartIndex,
EndIndex = romajiTag.EndIndex,
RomanizedSyllable = romajiTag.Text,
RomanisedSyllable = romajiTag.Text,
};
}

private static JaRomanizationGenerator.RomanizationGeneratorParameter[] parseRomanizationGenerateResults(IEnumerable<string> strings)
=> strings.Select(parseRomanizationGenerateResult).ToArray();
private static JaRomanisationGenerator.RomanisationGeneratorParameter[] parseRomanisationGenerateResults(IEnumerable<string> strings)
=> strings.Select(parseRomanisationGenerateResult).ToArray();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Karaoke.Edit.Generator.Lyrics.Romanization;
using osu.Game.Rulesets.Karaoke.Edit.Generator.Lyrics.Romanisation;
using osu.Game.Rulesets.Karaoke.Objects;

namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.Romanization;
namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.Romanisation;

public class RomanizationGenerateResultHelper
public class RomanisationGenerateResultHelper
{
/// <summary>
/// Convert the string format into the <see cref="RomanizationGenerateResult"/>.
/// Convert the string format into the <see cref="RomanisationGenerateResult"/>.
/// </summary>
/// <example>
/// karaoke
/// ^karaoke
/// </example>
/// <param name="timeTag">Origin time-tag</param>
/// <param name="str">Generate result string format</param>
/// <returns><see cref="RomanizationGenerateResult"/>Romanization generate result.</returns>
public static KeyValuePair<TimeTag, RomanizationGenerateResult> ParseRomanizationGenerateResult(TimeTag timeTag, string str)
/// <returns><see cref="RomanisationGenerateResult"/>Romanisation generate result.</returns>
public static KeyValuePair<TimeTag, RomanisationGenerateResult> ParseRomanisationGenerateResult(TimeTag timeTag, string str)
{
var result = new RomanizationGenerateResult
var result = new RomanisationGenerateResult
{
FirstSyllable = str.StartsWith("^", StringComparison.Ordinal),
RomanizedSyllable = str.Replace("^", ""),
RomanisedSyllable = str.Replace("^", ""),
};

return new KeyValuePair<TimeTag, RomanizationGenerateResult>(timeTag, result);
return new KeyValuePair<TimeTag, RomanisationGenerateResult>(timeTag, result);
}

public static IReadOnlyDictionary<TimeTag, RomanizationGenerateResult> ParseRomanizationGenerateResults(IList<TimeTag> timeTags, IList<string> strings)
public static IReadOnlyDictionary<TimeTag, RomanisationGenerateResult> ParseRomanisationGenerateResults(IList<TimeTag> timeTags, IList<string> strings)
{
if (timeTags.Count != strings.Count)
throw new InvalidOperationException();

return parseRomanizationGenerateResults(timeTags, strings).ToDictionary(k => k.Key, v => v.Value);
return parseRomanisationGenerateResults(timeTags, strings).ToDictionary(k => k.Key, v => v.Value);

static IEnumerable<KeyValuePair<TimeTag, RomanizationGenerateResult>> parseRomanizationGenerateResults(IList<TimeTag> timeTags, IList<string> strings)
static IEnumerable<KeyValuePair<TimeTag, RomanisationGenerateResult>> parseRomanisationGenerateResults(IList<TimeTag> timeTags, IList<string> strings)
{
for (int i = 0; i < timeTags.Count; i++)
{
yield return ParseRomanizationGenerateResult(timeTags[i], strings[i]);
yield return ParseRomanisationGenerateResult(timeTags[i], strings[i]);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Karaoke.Edit.Generator.Lyrics.Romanization;
using osu.Game.Rulesets.Karaoke.Edit.Generator.Lyrics.Romanisation;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Tests.Asserts;
using osu.Game.Rulesets.Karaoke.Tests.Helper;

namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.Romanization;
namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Generator.Lyrics.Romanisation;

public class RomanizationGeneratorSelectorTest : BaseLyricGeneratorSelectorTest<RomanizationGeneratorSelector, IReadOnlyDictionary<TimeTag, RomanizationGenerateResult>>
public class RomanisationGeneratorSelectorTest : BaseLyricGeneratorSelectorTest<RomanisationGeneratorSelector, IReadOnlyDictionary<TimeTag, RomanisationGenerateResult>>
{
[TestCase(17, "花火大会", true)]
[TestCase(17, "我是中文", true)] // only change the language code to decide should be able to generate or not.
[TestCase(17, "", false)] // will not able to make the romanization if lyric is empty.
[TestCase(17, "", false)] // will not able to make the romanisation if lyric is empty.
[TestCase(17, " ", false)]
[TestCase(17, null, false)]
[TestCase(1028, "はなび", false)] // Should not be able to generate if language is not supported.
Expand All @@ -39,7 +39,7 @@ public void TestCanGenerate(int lcid, string text, bool canGenerate)

[TestCase(17, "はなび", new[] { "[0,start]" }, new[] { "^hana bi" })] // Japanese
[TestCase(1041, "花火大会", new[] { "[0,start]", "[3,end]" }, new[] { "^hanabi taikai", "" })] // Japanese
public void TestGenerate(int lcid, string text, string[] timeTagStrings, string[] expectedRomanizedSyllables)
public void TestGenerate(int lcid, string text, string[] timeTagStrings, string[] expectedRomanisedSyllables)
{
var selector = CreateSelector();

Expand All @@ -51,11 +51,11 @@ public void TestGenerate(int lcid, string text, string[] timeTagStrings, string[
TimeTags = timeTags,
};

var expected = RomanizationGenerateResultHelper.ParseRomanizationGenerateResults(timeTags, expectedRomanizedSyllables);
var expected = RomanisationGenerateResultHelper.ParseRomanisationGenerateResults(timeTags, expectedRomanisedSyllables);
CheckGenerateResult(lyric, expected, selector);
}

protected override void AssertEqual(IReadOnlyDictionary<TimeTag, RomanizationGenerateResult> expected, IReadOnlyDictionary<TimeTag, RomanizationGenerateResult> actual)
protected override void AssertEqual(IReadOnlyDictionary<TimeTag, RomanisationGenerateResult> expected, IReadOnlyDictionary<TimeTag, RomanisationGenerateResult> actual)
{
TimeTagAssert.ArePropertyEqual(expected.Select(x => x.Key).ToArray(), actual.Select(x => x.Key).ToArray());
Assert.AreEqual(expected.Select(x => x.Value), actual.Select(x => x.Value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void TestTextChanged()
public void TestSwitchDisplayType()
{
// change the display type.
testProcessor!.DisplayType = LyricDisplayType.RomanizedSyllable;
testProcessor!.DisplayType = LyricDisplayType.RomanisedSyllable;

// check the changed count
Assert.AreEqual(topTextChangeCount, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void TestDisplayProperty([Values] LyricDisplayProperty property)
lyric.Text = "カラオケ";
break;

case RomanizedSyllableFirstDisplayProcessor:
case RomanisedSyllableFirstDisplayProcessor:
lyric.TimeTags = TestCaseTagHelper.ParseTimeTags(new[] { "[0,start]:1000#^ka", "[1,start]:2000#ra", "[2,start]:3000#o", "[3,start]:4000#ke", "[3,end]:5000" });
break;

Expand Down
Loading

0 comments on commit f8da2b2

Please sign in to comment.