Skip to content

Datatypes

datatypes

This module defines the kotobase datatypes representing information from the different data sources.

JLPTGrammarDTO dataclass

Bases: Serializable

A Python Dataclass object representing an entry of Tanos JLPT Grammar list.

Parameters:

Name Type Description Default
id int

Integer Database Entry ID.

required
level int

Integer representing in which JLPT level the Entry exists.

required
grammar str

String representing grammar point.

required
formation str

String representing grammar point formation pattern.

required
examples List[str]

List of strings containing grammar point examples.

list()

JLPTKanjiDTO dataclass

Bases: Serializable

A Python Dataclass object representing an entry of Tanos JLPT Kanji list.

Parameters:

Name Type Description Default
id int

Integer Database Entry ID.

required
level int

Integer representing in which JLPT level the Entry exists.

required
kanji str

String representing Entry Kanji

required

JLPTVocabDTO dataclass

Bases: Serializable

A Python Dataclass object representing an entry of Tanos JLPT Vocabulary list.

Parameters:

Name Type Description Default
id int

Integer Database Entry ID.

required
level int

Integer representing in which JLPT level the Entry exists.

required
kanji str

String representing Entry Kanji

required
hiragana str

String representing Entry kana reading.

required
english str

String representing Entry english translation

required

JMDictEntryDTO dataclass

Bases: Serializable

A Python Dataclass object representing a JMDict Entry.

Parameters:

Name Type Description Default
id int

Integer Database Entry ID.

required
rank int

Integer priority rank of entry

required
kana List[str]

List of Strings representing Kana Readings.

list()
kanji List[str]

List of Strings representig existing Kanji in Entry.

list()
senses List[Dict[str, Any]]

List of Dicts in format {'order':int, 'pos': str, 'gloss':str} representing Entry senses.

list()

JMNeDictEntryDTO dataclass

Bases: Serializable

A Python Dataclass object representing a JMNeDict Entry.

Parameters:

Name Type Description Default
id int

Integer Database Entry ID.

required
kana List[str]

List of Strings representing Kana Readings.

list()
kanji List[str]

List of Strings representig existing Kanji in Entry.

list()
translation_type str

String representing type of Entry.

''
gloss List[str]

List of strings representing glosses of Entry.

list()

KanjiDTO dataclass

Bases: Serializable

A Python Dataclass object representing an entry of KANJIDIC2.

Parameters:

Name Type Description Default
literal str

String of Kanji Literal

required
grade Optional[int]

Optional Integer of Japanese Grade in which Kanji is learned

required
stroke_count int

Integer representing number of strokes in handwriting.

required
meanings List[str]

List of String representing known meanings.

required
onyomi List[str]

List of strings representing on readings.

required
kunyomi List[str]

List of strings representing kun readings.

required
jlpt_kanjidic Optional[int]

Optional Integer representing JLPT level in KANJIDIC2

required
jlpt_tanos Optional[int]

Optional Integer representing JLPT level in Tanos list.

required

LookupResult dataclass

Bases: Serializable

A Python Dataclass object which aggreates results of all database queries.

Parameters:

Name Type Description Default
word str

String of the looked up word.

required
entries List[JMDictEntryDTO | JMNeDictEntryDTO]

List containing found entries in the form of JMDictEntryDTO or JMNeDictEntryDTO objects.

required
kanji List[KanjiDTO]

List containing found kanji in the form of KanjiDTO objects.

required
jlpt_vocab Optional[JLPTVocabDTO]

Optional JLPTVocabDTO object.

required
jlpt_kanji_levels Dict[str, int]

Dictionary with kanji levels from Tanos Lists.

required
jlpt_grammar List[JLPTGrammarDTO]

List of JLPTGrammarDTO objects.

required
examples List[SentenceDTO]

List of SentenceDTO objects.

required

filter_entries()

Convenience function for splitting entries between JMDictEntryDTO and JMNeDictEntryDTO

Returns:

Type Description
Dict[str, list]

Dict[str, list]: Split entries dictionary of format {'jmdict': list, 'jmnedict': list}

has_jlpt()

Convenience function for checking if the result contains JLPT information

Returns:

Name Type Description
bool bool

True if JLPT is present, False otherwise

SentenceDTO dataclass

Bases: Serializable

A Python Dataclass object representing an example sentence from the Tatoeba project.

Parameters:

Name Type Description Default
id int

Integer Database Entry ID.

required
text str

String of example.

required

Serializable

Base class for adding to_dict and to_json methods for all dataclasses.

to_dict()

Return DTO as a python dictionary by calling asdict on dataclass

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: DTO information as a python dict

to_json(**json_kwargs)

Return DTO in json format by calling json.dumps on the to_dict method.

Parameters:

Name Type Description Default
**json_kwargs dict

Keyword arguments for json.dumps

{}

Returns:

Name Type Description
str str

The object in JSON string format