Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rampaa committed Jan 5, 2025
1 parent 6eb8235 commit 5de672b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
21 changes: 20 additions & 1 deletion JL.Core/Dicts/PitchAccent/PitchAccentRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace JL.Core.Dicts.PitchAccent;

public sealed record class PitchAccentRecord : IDictRecord
public sealed class PitchAccentRecord : IDictRecord, IEquatable<PitchAccentRecord>
{
public string Spelling { get; }
public string? Reading { get; }
Expand Down Expand Up @@ -52,4 +52,23 @@ internal PitchAccentRecord(List<JsonElement> jsonElements)
? null
: Reading!.GetPooledString();
}

public override bool Equals(object? obj)
{
return obj is PitchAccentRecord pitchAccentRecord
&& Spelling == pitchAccentRecord.Spelling
&& Reading == pitchAccentRecord.Reading;
}

public bool Equals(PitchAccentRecord? other)
{
return other is not null
&& Spelling == other.Spelling
&& Reading == other.Reading;
}

public override int GetHashCode()
{
return HashCode.Combine(Spelling, Reading);
}
}
5 changes: 4 additions & 1 deletion JL.Core/Dicts/PitchAccent/YomichanPitchAccentLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ public static async Task Load(Dict dict)
{
if (pitchDict.TryGetValue(readingInHiragana, out IList<IDictRecord>? readingResult))
{
readingResult.Add(newEntry);
if (!readingResult.Contains(newEntry))
{
readingResult.Add(newEntry);
}
}
else
{
Expand Down

0 comments on commit 5de672b

Please sign in to comment.