JMDict 1.0.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package JMDict --version 1.0.6                
NuGet\Install-Package JMDict -Version 1.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="JMDict" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add JMDict --version 1.0.6                
#r "nuget: JMDict, 1.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install JMDict as a Cake Addin
#addin nuget:?package=JMDict&version=1.0.6

// Install JMDict as a Cake Tool
#tool nuget:?package=JMDict&version=1.0.6                

JMDict-Parser

This is a parser written in Dotnet 7 for parsing the XML files for JMDict, JMnedict and KANJIDIC2.

Compatability

This parser is currently compatible with the following versions of the dictionaries:

  • JMDict: Rev 1.09
  • JMnedict: Rev 1.08
  • KANJIDIC2: Version 1.6

Using any newer versions of the dictionaries should still work, but each revision add new features that this parser might not utilize.

Notes

  • This parser might not be compatible with future versions of the dictionaries, as the format of the XML files might change. I will try to keep this package up to date with the latest versions of the dictionaries. If you find any issues with the parser, please contact me.

  • Most of the properties of the classes are currently nullable, therefore you should check for null before using them. See examples below.

  • The dictionary three classes ( Jmdict, Jmnedict and Kanjidic ) have different sets of properties, as the dictionaries have different sets of data.

  • The DictParser methods are currently synchronous since the XMLSerializer only can deserialize XML files synchronously.

Usage examples

You can use the parser by first creating an instance of the DictParser class and then calling the ParseXml method with the appropriate type and the path to the XML file.

var jmdictParser = new DictParser();
var kanjidic2 = jmdictParser.ParseXml<Kanjidic>("path/to/kanjidic2.xml");

Then you can either loop through the data:

// Loop through each character in the dictionary
foreach (var character in kanjidic2.Characters)
{
    // Make sure everything up to the Readings object are not null using the null-coalescing operator
    if (character?.ReadingMeaning?.ReadingMeaningGroup?.Readings != null)
    {
        // Do something with the data
        foreach (var reading in character.ReadingMeaning.ReadingMeaningGroup.Readings)
        {
            Console.WriteLine(JsonConvert.SerializeObject(reading, Formatting.Indented));
        }
    }
}

Or use LINQ to get the data you want:

// LINQ expression to get all the readings, english meanings and the kanji character for every character in the dictionary
var readingsMeaningKanji = kanjidic2.Characters
    .Select(c => new
    {
        Kanji = c.Literal,
        Readings = c?.ReadingMeaning?.ReadingMeaningGroup?.Readings,
        Meanings = c?.ReadingMeaning?.ReadingMeaningGroup?.Meanings?.Where(m => m.Language == null) // If the language is null, it means that the meaning is in English
    })
    .Where(rmk => rmk.Readings != null && rmk.Meanings != null);

// Process the data
foreach (var reading in readingsMeaningKanji)
{
    Console.WriteLine(JsonConvert.SerializeObject(reading, Formatting.Indented));
}

License

This project is licensed under the MIT License - see the LICENSE file for details

TODO

  • Add tests
  • Check for a newer version of the dictionaries in the ParseXml method.
  • Check for newer version of the dictionaries in the pipeline.
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 303 3/19/2023
1.0.6 233 3/19/2023
1.0.5 233 3/18/2023
1.0.4 221 3/18/2023
1.0.3 210 3/18/2023
1.0.2 230 3/18/2023
1.0.1 221 3/18/2023