Skip to content

Commit

Permalink
Merge branch 'update-kanjivg' into 'main'
Browse files Browse the repository at this point in the history
Update kanji stroke path data from KanjiVG

See merge request Wacton/Desu!3
  • Loading branch information
waacton committed Jul 23, 2022
2 parents 90892d3 + 6d2109d commit 44c0d4f
Show file tree
Hide file tree
Showing 21 changed files with 134 additions and 125 deletions.
6 changes: 4 additions & 2 deletions .gitlab/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ test:
reports:
junit:
- ./**/*test-result.xml
cobertura: ./**/coverage.cobertura.xml

coverage_report:
coverage_format: cobertura
path: ./**/coverage.cobertura.xml

# will enable when GitLab allows it to work
#sast:
# stage: security-test
Expand Down
16 changes: 8 additions & 8 deletions Desu.ExampleConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class Program
{
private const bool GenerateExampleJson = false;
private const bool UseAsync = true;
private static readonly Random Random = new Random();
private static readonly Transliterator Transliterator = new Transliterator();
private static readonly Random Random = new();
private static readonly Transliterator Transliterator = new();

public static async Task Main()
{
Expand Down Expand Up @@ -45,7 +45,7 @@ public static async Task Main()
}
}

public static async Task RunAsync()
private static async Task RunAsync()
{
var japaneseDictionaryStopwatch = new Stopwatch();
var nameDictionaryStopwatch = new Stopwatch();
Expand Down Expand Up @@ -78,7 +78,7 @@ public static async Task RunAsync()
}
}

public static void RunSync()
private static void RunSync()
{
var japaneseDictionaryStopwatch = new Stopwatch();
var nameDictionaryStopwatch = new Stopwatch();
Expand Down Expand Up @@ -165,12 +165,12 @@ private static void OutputRandomJapaneseEntry(IReadOnlyList<IJapaneseEntry> japa

OutputEndEntry();
}

private static void OutputStartEntry() => OutputLine("------------------------------");

private static void OutputLineBreak() => OutputLine("------------------------------");
private static void OutputStartEntry() => OutputLineBreak();
private static void OutputEndEntry()
{
OutputLine("------------------------------");
OutputLineBreak();
OutputLine(string.Empty);
Console.ReadKey();
}
Expand Down
4 changes: 2 additions & 2 deletions Desu.ExampleWpf/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="MainWindow" Height="350" Width="525">

<Grid x:Name="Grid">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
Expand All @@ -31,6 +31,6 @@
</ItemsControl.ItemTemplate>
</ItemsControl>

<Button Content="Next" Grid.Row="3" Click="ButtonBase_OnClick" />
<Button Content="Next" Grid.Row="3" Click="OnNextButtonClick" />
</Grid>
</Window>
39 changes: 18 additions & 21 deletions Desu.ExampleWpf/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,48 @@ public partial class MainWindow : Window, INotifyPropertyChanged

public MainWindow()
{
this.kanjiEntries = KanjiDictionary.ParseEntries().ToList();
this.UpdateKanji();
kanjiEntries = KanjiDictionary.ParseEntries().ToList();
UpdateKanji();

InitializeComponent();
}

public string Text => this.currentEntry.Literal;
public string Meanings => this.GetEnglishMeanings();
public string Text => currentEntry.Literal;
public string Meanings => GetEnglishMeanings();

public ObservableCollection<Geometry> Strokes { get; set; }

private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
this.UpdateKanji();
}

private void OnNextButtonClick(object sender, RoutedEventArgs e) => UpdateKanji();

private void UpdateKanji()
{
var hasStrokePaths = false;
while (!hasStrokePaths)
{
this.currentEntry = this.kanjiEntries[this.GetRandomIndex()];
hasStrokePaths = this.currentEntry.StrokePaths.Any();
currentEntry = kanjiEntries[GetRandomIndex()];
hasStrokePaths = currentEntry.StrokePaths.Any();
}

this.Strokes = new ObservableCollection<Geometry>();
foreach (var strokePath in this.currentEntry.StrokePaths)
Strokes = new ObservableCollection<Geometry>();
foreach (var strokePath in currentEntry.StrokePaths)
{
this.Strokes.Add(Geometry.Parse(strokePath));
Strokes.Add(Geometry.Parse(strokePath));
}

this.OnPropertyChanged(nameof(this.Text));
this.OnPropertyChanged(nameof(this.Meanings));
this.OnPropertyChanged(nameof(this.Strokes));
OnPropertyChanged(nameof(Text));
OnPropertyChanged(nameof(Meanings));
OnPropertyChanged(nameof(Strokes));
}

private int GetRandomIndex()
{
return this.random.Next(0, this.kanjiEntries.Count - 1);
return random.Next(0, kanjiEntries.Count - 1);
}

private string GetEnglishMeanings()
{
var englishMeanings = this.currentEntry.Meanings
.Where(meaning => meaning.Language == Wacton.Desu.Enums.Language.English)
var englishMeanings = currentEntry.Meanings
.Where(meaning => meaning.Language.Equals(Enums.Language.English))
.Select(meaning => meaning.Term);

return string.Join(" · ", englishMeanings);
Expand All @@ -78,7 +75,7 @@ private string GetEnglishMeanings()
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
4 changes: 2 additions & 2 deletions Desu.Tests/Japanese/TestEntries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public static TestEntry 九百()
KanjiRestriction = new List<string> { "九百" },
ReadingRestriction = new List<string> { "くひゃく" },
PartsOfSpeech = new List<PartOfSpeech> { PartOfSpeech("noun (common) (futsuumeishi)") },
Miscellanea = new List<Miscellaneous> { Miscellaneous("archaism"), Miscellaneous("derogatory") },
Miscellanea = new List<Miscellaneous> { Miscellaneous("archaic"), Miscellaneous("derogatory") },
Glosses = new List<Gloss> {
new("fool", Language("eng"), null, null),
new("idiot", Language("eng"), null, null)
Expand Down Expand Up @@ -567,7 +567,7 @@ public static TestEntry タチ()
PartsOfSpeech = new List<PartOfSpeech> { PartOfSpeech("noun (common) (futsuumeishi)") },
CrossReferences = new List<string> { "攻め・2", "受け・5" },
Antonyms = new List<string> { "猫・6" },
Miscellanea = new List<Miscellaneous> { Miscellaneous("colloquialism") },
Miscellanea = new List<Miscellaneous> { Miscellaneous("colloquial") },
Glosses = new List<Gloss> { new("dominant partner of a homosexual relationship", Language("eng"), null, null) }
};

Expand Down
10 changes: 5 additions & 5 deletions Desu/Desu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
<ApplicationIcon>Resources\Desu.ico</ApplicationIcon>
<AssemblyName>Wacton.Desu</AssemblyName>
<RootNamespace>Wacton.Desu</RootNamespace>
<Version>6.1.0</Version>
<Version>6.2.0</Version>
<Authors>William Acton</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Japanese and kanji dictionary .NET library built upon JMdict, JMnedict, KANJIDIC, RADKFILE/KRADFILE, and KanjiVG.
Targets .NET Standard 2.0 for use in .NET 5.0+, .NET Core 2.0+ and .NET Framework 4.6.1+ applications.</Description>
<PackageProjectUrl>https://gitlab.com/Wacton/Desu</PackageProjectUrl>
<RepositoryUrl>https://gitlab.com/Wacton/Desu</RepositoryUrl>
<PackageTags>Japanese kanji dictionary JMdict JMnedict KANJIDIC RADKFILE KRADFILE KanjiVG EDICT radicals romaji</PackageTags>
<PackageReleaseNotes>Remove duplicate radicals and replace approximate glyphs</PackageReleaseNotes>
<PackageReleaseNotes>Update kanji stroke path data from KanjiVG</PackageReleaseNotes>
<LangVersion>7.3</LangVersion>
<Copyright>William Acton</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>Desu_64.png</PackageIcon>
<PackageVersion>6.1.0</PackageVersion>
<PackageVersion>6.2.0</PackageVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -29,7 +29,7 @@ Targets .NET Standard 2.0 for use in .NET 5.0+, .NET Core 2.0+ and .NET Framewor
<None Remove="Resources\JMdict.zip" />
<None Remove="Resources\JMnedict.zip" />
<None Remove="Resources\kanjidic2.zip" />
<None Remove="Resources\KanjiVG.zip" />
<None Remove="Resources\kanjivg.zip" />
<None Remove="Resources\kradfile" />
<None Remove="Resources\kradfile2" />
<None Remove="Resources\radkfilex" />
Expand All @@ -47,7 +47,7 @@ Targets .NET Standard 2.0 for use in .NET 5.0+, .NET Core 2.0+ and .NET Framewor
<EmbeddedResource Include="Resources\JMdict.zip" />
<EmbeddedResource Include="Resources\JMnedict.zip" />
<EmbeddedResource Include="Resources\kanjidic2.zip" />
<EmbeddedResource Include="Resources\KanjiVG.zip" />
<EmbeddedResource Include="Resources\kanjivg.zip" />
<EmbeddedResource Include="Resources\kradfile" />
<EmbeddedResource Include="Resources\kradfile2" />
<EmbeddedResource Include="Resources\radkfilex" />
Expand Down
5 changes: 4 additions & 1 deletion Desu/Enums/Field.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class Field : Enumeration
public static readonly Field Botany = new Field(nameof(Botany), "botany");
public static readonly Field Buddhism = new Field(nameof(Buddhism), "Buddhism");
public static readonly Field Business = new Field(nameof(Business), "business");
public static readonly Field CardGames = new Field(nameof(CardGames), "card games");
public static readonly Field Chemistry = new Field(nameof(Chemistry), "chemistry");
public static readonly Field Christianity = new Field(nameof(Christianity), "Christianity");
public static readonly Field Clothing = new Field(nameof(Clothing), "clothing");
Expand All @@ -37,7 +38,9 @@ public class Field : Enumeration
public static readonly Field Geology = new Field(nameof(Geology), "geology");
public static readonly Field Geometry = new Field(nameof(Geometry), "geometry");
public static readonly Field Go = new Field(nameof(Go), "go (game)");
public static readonly Field Golf = new Field(nameof(Golf), "golf");
public static readonly Field Grammar = new Field(nameof(Grammar), "grammar");
public static readonly Field GreekMythology = new Field(nameof(GreekMythology), "Greek mythology");
public static readonly Field Hanafuda = new Field(nameof(Hanafuda), "hanafuda");
public static readonly Field HorseRacing = new Field(nameof(HorseRacing), "horse racing");
public static readonly Field Law = new Field(nameof(Law), "law");
Expand All @@ -54,7 +57,7 @@ public class Field : Enumeration
public static readonly Field Ornithology = new Field(nameof(Ornithology), "ornithology");
public static readonly Field Paleontology = new Field(nameof(Paleontology), "paleontology");
public static readonly Field Pathology = new Field(nameof(Pathology), "pathology");
public static readonly Field Pharmacy = new Field(nameof(Pharmacy), "pharmacy");
public static readonly Field Pharmacology = new Field(nameof(Pharmacology), "pharmacology");
public static readonly Field Philosophy = new Field(nameof(Philosophy), "philosophy");
public static readonly Field Photography = new Field(nameof(Photography), "photography");
public static readonly Field Physics = new Field(nameof(Physics), "physics");
Expand Down
2 changes: 2 additions & 0 deletions Desu/Enums/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ public class Language : Enumeration
public static readonly Language Spanish = new Language(nameof(Spanish), "spa", "es");
public static readonly Language Swahili = new Language(nameof(Swahili), "swa", "sw");
public static readonly Language Swedish = new Language(nameof(Swedish), "swe", "sv");
public static readonly Language Tagalog = new Language(nameof(Tagalog), "tgl", "tl");
public static readonly Language Tahitian = new Language(nameof(Tahitian), "tah", "ty");
public static readonly Language Tamil = new Language(nameof(Tamil), "tam", "ta");
public static readonly Language Thai = new Language(nameof(Thai), "tha", "th");
public static readonly Language Tibetan = new Language(nameof(Tibetan), "tib", "bo");
public static readonly Language Turkish = new Language(nameof(Turkish), "tur", "tr");
public static readonly Language Ukrainian = new Language(nameof(Ukrainian), "ukr", "uk");
public static readonly Language Urdu = new Language(nameof(Urdu), "urd", "ur");
public static readonly Language Vietnamese = new Language(nameof(Vietnamese), "vie", "vi");
public static readonly Language Yiddish = new Language(nameof(Yiddish), "yid", "yi");
Expand Down
8 changes: 4 additions & 4 deletions Desu/Enums/Miscellaneous.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
public class Miscellaneous : Enumeration
{
public static readonly Miscellaneous Abbreviation = new Miscellaneous(nameof(Abbreviation), "abbreviation");
public static readonly Miscellaneous Archaism = new Miscellaneous(nameof(Archaism), "archaism");
public static readonly Miscellaneous Archaic = new Miscellaneous(nameof(Archaic), "archaic");
public static readonly Miscellaneous Childrens = new Miscellaneous(nameof(Childrens), "children's language");
public static readonly Miscellaneous Colloquialism = new Miscellaneous(nameof(Colloquialism), "colloquialism");
public static readonly Miscellaneous Colloquial = new Miscellaneous(nameof(Colloquial), "colloquial");
public static readonly Miscellaneous Dated = new Miscellaneous(nameof(Dated), "dated term");
public static readonly Miscellaneous Derogatory = new Miscellaneous(nameof(Derogatory), "derogatory");
public static readonly Miscellaneous Euphemistic = new Miscellaneous(nameof(Euphemistic), "euphemistic");
public static readonly Miscellaneous Familiar = new Miscellaneous(nameof(Familiar), "familiar language");
public static readonly Miscellaneous Female = new Miscellaneous(nameof(Female), "female term or language");
public static readonly Miscellaneous Formal = new Miscellaneous(nameof(Formal), "formal or literary term");
Expand All @@ -21,7 +22,6 @@ public class Miscellaneous : Enumeration
public static readonly Miscellaneous Legend = new Miscellaneous(nameof(Legend), "legend");
public static readonly Miscellaneous Male = new Miscellaneous(nameof(Male), "male term or language");
public static readonly Miscellaneous Manga = new Miscellaneous(nameof(Manga), "manga slang");
public static readonly Miscellaneous Obscure = new Miscellaneous(nameof(Obscure), "obscure term");
public static readonly Miscellaneous Obsolete = new Miscellaneous(nameof(Obsolete), "obsolete term");
public static readonly Miscellaneous Onomatopoeic = new Miscellaneous(nameof(Onomatopoeic), "onomatopoeic or mimetic word");
public static readonly Miscellaneous Person = new Miscellaneous(nameof(Person), "full name of a particular person");
Expand All @@ -30,7 +30,7 @@ public class Miscellaneous : Enumeration
public static readonly Miscellaneous Polite = new Miscellaneous(nameof(Polite), "polite (teineigo) language");
public static readonly Miscellaneous Proverb = new Miscellaneous(nameof(Proverb), "proverb");
public static readonly Miscellaneous Quotation = new Miscellaneous(nameof(Quotation), "quotation");
public static readonly Miscellaneous Rare = new Miscellaneous(nameof(Rare), "rare");
public static readonly Miscellaneous Rare = new Miscellaneous(nameof(Rare), "rare term");
public static readonly Miscellaneous Sensitive = new Miscellaneous(nameof(Sensitive), "sensitive");
public static readonly Miscellaneous Slang = new Miscellaneous(nameof(Slang), "slang");
public static readonly Miscellaneous UsuallyKanaAlone = new Miscellaneous(nameof(UsuallyKanaAlone), "word usually written using kana alone");
Expand Down
1 change: 1 addition & 0 deletions Desu/Enums/NameType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class NameType : Enumeration
public static readonly NameType Company = new NameType(nameof(Company), "company name");
public static readonly NameType Creature = new NameType(nameof(Creature), "creature");
public static readonly NameType Deity = new NameType(nameof(Deity), "deity");
public static readonly NameType Document = new NameType(nameof(Document), "document");
public static readonly NameType Event = new NameType(nameof(Event), "event");
public static readonly NameType Female = new NameType(nameof(Female), "female given name or forename");
public static readonly NameType Fiction = new NameType(nameof(Fiction), "fiction");
Expand Down
4 changes: 2 additions & 2 deletions Desu/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Desu/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@
<data name="kanjidic2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\kanjidic2.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="KanjiVG" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\KanjiVG.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="kanjivg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\kanjivg.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="kradfile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\kradfile;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
Expand Down
Binary file modified Desu/Resources/JMdict.zip
Binary file not shown.
Binary file modified Desu/Resources/JMnedict.zip
Binary file not shown.
Binary file removed Desu/Resources/KanjiVG.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion Desu/Resources/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Resource : Enumeration
public static readonly Resource KanjiToRadicals1 = new Resource("KanjiToRadicals1", nameof(Resources.kradfile));
public static readonly Resource KanjiToRadicals2 = new Resource("KanjiToRadicals2", nameof(Resources.kradfile2));
public static readonly Resource RadicalToKanjis = new Resource("RadicalToKanjis", nameof(Resources.radkfilex));
public static readonly Resource KanjiStrokes = new Resource("KanjiStrokes", nameof(Resources.KanjiVG));
public static readonly Resource KanjiStrokes = new Resource("KanjiStrokes", nameof(Resources.kanjivg));

public string Name { get; }

Expand Down
Binary file added Desu/Resources/kanjivg.zip
Binary file not shown.
Loading

0 comments on commit 44c0d4f

Please sign in to comment.