-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
namespace JL.Core.Dicts.JMdict; | ||
|
||
internal sealed class KanjiElement(string keb, List<string> keInfList) | ||
internal readonly struct KanjiElement(string keb, List<string> keInfList) : IEquatable<KanjiElement> | ||
{ | ||
public string Keb { get; } = keb; // e.g. 娘 | ||
public List<string> KeInfList { get; } = keInfList; // e.g. Ateji. | ||
// public List<string> KePriList { get; } // e.g. gai1 | ||
|
||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
int hash = (17 * 37) + Keb.GetHashCode(StringComparison.Ordinal); | ||
foreach (string keInf in KeInfList) | ||
{ | ||
hash = (hash * 37) + keInf.GetHashCode(StringComparison.Ordinal); | ||
} | ||
|
||
return hash; | ||
} | ||
} | ||
|
||
public override bool Equals(object? obj) | ||
{ | ||
return obj is KanjiElement other | ||
&& Keb == other.Keb | ||
&& KeInfList.SequenceEqual(other.KeInfList); | ||
} | ||
|
||
public bool Equals(KanjiElement other) | ||
{ | ||
return Keb == other.Keb && KeInfList.SequenceEqual(other.KeInfList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
namespace JL.Core.Dicts.JMdict; | ||
|
||
internal sealed class ReadingElement(string reb, List<string> reRestrList, List<string> reInfList) | ||
internal readonly struct ReadingElement(string reb, List<string> reRestrList, List<string> reInfList) : IEquatable<ReadingElement> | ||
{ | ||
public string Reb { get; } = reb; // Reading in kana. e.g. むすめ | ||
public List<string> ReRestrList { get; } = reRestrList; // ReRestrList = Keb. The reading is only valid for this specific keb. | ||
public List<string> ReInfList { get; } = reInfList; // e.g. gikun | ||
// public bool ReNokanji { get; } // Is kana insufficient to notate the right spelling? | ||
// public List<string> RePriList { get; } // e.g. ichi1 | ||
|
||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
int hash = (17 * 37) + Reb.GetHashCode(StringComparison.Ordinal); | ||
foreach (string reRestr in ReRestrList) | ||
{ | ||
hash = (hash * 37) + reRestr.GetHashCode(StringComparison.Ordinal); | ||
} | ||
|
||
foreach (string reInf in ReInfList) | ||
{ | ||
hash = (hash * 37) + reInf.GetHashCode(StringComparison.Ordinal); | ||
} | ||
|
||
return hash; | ||
} | ||
} | ||
|
||
public override bool Equals(object? obj) | ||
{ | ||
return obj is ReadingElement other | ||
&& Reb == other.Reb | ||
&& ReRestrList.SequenceEqual(other.ReRestrList) | ||
&& ReInfList.SequenceEqual(other.ReInfList); | ||
} | ||
|
||
public bool Equals(ReadingElement other) | ||
{ | ||
return Reb == other.Reb | ||
&& ReRestrList.SequenceEqual(other.ReRestrList) | ||
&& ReInfList.SequenceEqual(other.ReInfList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,39 @@ | ||
namespace JL.Core.Dicts.JMnedict; | ||
|
||
internal sealed class Translation(List<string> nameTypeList, List<string> transDetList) | ||
internal readonly struct Translation(List<string> nameTypeList, List<string> transDetList) : IEquatable<Translation> | ||
{ | ||
public List<string> NameTypeList { get; } = nameTypeList; | ||
public List<string> TransDetList { get; } = transDetList; | ||
//public List<string> XRefList { get; } | ||
|
||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
int hash = 17 * 37; | ||
foreach (string nameType in NameTypeList) | ||
{ | ||
hash = (hash * 37) + nameType.GetHashCode(StringComparison.Ordinal); | ||
} | ||
|
||
foreach (string transDet in TransDetList) | ||
{ | ||
hash = (hash * 37) + transDet.GetHashCode(StringComparison.Ordinal); | ||
} | ||
|
||
return hash; | ||
} | ||
} | ||
|
||
public override bool Equals(object? obj) | ||
{ | ||
return obj is Translation other | ||
&& NameTypeList.SequenceEqual(other.NameTypeList) | ||
&& TransDetList.SequenceEqual(other.TransDetList); | ||
} | ||
|
||
public bool Equals(Translation other) | ||
{ | ||
return NameTypeList.SequenceEqual(other.NameTypeList) && TransDetList.SequenceEqual(other.TransDetList); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters