API
api
¶
This module defines the main kotobase API through the Kotobase
class
to make queries to the database and return data objects.
Kotobase
¶
Stateless class that orchestrates the individual repositories and returns serialisable objects.
__call__(word, *, wildcard=False, include_names=False, sentence_limit=50, entry_limit=None)
¶
Comprehensive word lookup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
word
|
str
|
The query string (kana, kanji) Supports SQL wildcards '*' or '%'. |
required |
wildcard
|
bool
|
If True, passes wildcards through unchanged.
If False, the search is exact (JMdict) but
Tatoeba uses |
False
|
include_names
|
bool
|
Also query JMnedict (proper names). Can be slow on very broad wildcards. |
False
|
sentence_limit
|
int
|
Maximum number of Tatoeba sentences to fetch. |
50
|
entry_limit
|
int
|
Maximum number of entries to fetch. |
None
|
Returns:
Name | Type | Description |
---|---|---|
LookupResult |
LookupResult
|
LookupResult Object. |
db_info()
staticmethod
¶
Return a dictionary containing variables from Database build log file, if it exists.
Raises:
Type | Description |
---|---|
EnvironmentError
|
If file doeesn't exist. |
jlpt_level(word)
staticmethod
¶
kanji(literal)
staticmethod
¶
lookup(word, *, wildcard=False, include_names=False, sentence_limit=50, entry_limit=None)
¶
Comprehensive word lookup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
word
|
str
|
The query string (kana, kanji) Supports SQL wildcards '*' or '%'. |
required |
wildcard
|
bool
|
If True, passes wildcards through unchanged.
If False, the search is exact (JMdict) but
Tatoeba uses |
False
|
include_names
|
bool
|
Also query JMnedict (proper names). Can be slow on very broad wildcards. |
False
|
sentence_limit
|
int
|
Maximum number of Tatoeba sentences to fetch. |
50
|
entry_limit
|
int
|
Maximum number of entries to fetch. |
None
|
Returns:
Name | Type | Description |
---|---|---|
LookupResult |
LookupResult
|
LookupResult Object. |