Module koplugin.japanese.deinflector

Yomichan deinflector implementation in pure Lua.

This is very heavily modelled after Yomichan's deinflection code, with some minor changes to make it slightly more performant in the more restricted environment KOReader tends to run in.

Functions

deinflectVerbatim (text) Deinflect some text as-is (without trying any possible conversions between types of kana or any other such modifications).
deinflect (text) Return the set of deinflections (and the reason path taken) for the provided text.
init () Initialise a Deflector instance with the set of rules defined in yomichan-deflect.json.
new (o) Create a new Deflector instance.

Tables

DeinflectResult A single deinflection result.

Issues

init-todo11 Maybe make this location configurable or look in the user-controlled data directory too?


Functions

deinflectVerbatim (text)
Deinflect some text as-is (without trying any possible conversions between types of kana or any other such modifications). You probably want to use Deinflector:deinflect() because it is more thorough.

Parameters:

  • text string Japanese text to deinflect verbatim.

Returns:

    {DeinflectResult,...} An array of possible deinflections (including the text given).

See also:

deinflect (text)
Return the set of deinflections (and the reason path taken) for the provided text. In addition to the verbatim text provided, several cleanups will be attempted on the text (conversion from half-width kana, conversion between katakana and hiragana, and collapsing of any emphatic sequences) and any valid deinflections found will also be returned.

Parameters:

  • text string Japanese text to deinflect.

Returns:

    {DeinflectResult,...} An array of possible deinflections (including the text given).
init ()
Initialise a Deflector instance with the set of rules defined in yomichan-deflect.json.
new (o)
Create a new Deflector instance.

Parameters:

  • o

Tables

DeinflectResult
A single deinflection result.

Fields:

  • term Deinflected form of the term (string).
  • rules Rules bitmask the term has applied (int).
  • reasons Array of reasons applied to reach the term ({string,...}).

Issues

init-todo11
Maybe make this location configurable or look in the user-controlled data directory too?
generated by LDoc 1.5.0 Last updated 2024-03-18 16:45:36