Lindera Dependency
Lindera Dependency (lindera-dependency) is a crate for Japanese bunsetsu dependency analysis: it groups the morphemes of a sentence into bunsetsu (文節) and finds, for each bunsetsu, the bunsetsu it depends on.
彼は 本を 読んだ。
彼は ──────┐
本を ──────┤
読んだ。 ◀──┘ (root)
Status
The crate is on crates.io from Lindera 7.1.0 on, and each release of Lindera publishes the models for IPADIC and for the three UniDic dictionaries with it. The analysis is complete from morphemes to dependencies: the training data, the chunker, the parser, the model file, the evaluation and a command for text are here, and the token filter of Lindera is in the default builds of the
linderacommand and of the bindings.
Start with the Installation and the Quick Start; Reading and Using the Result says what a bunsetsu and a dependency are and how to read what comes out. The work is tracked in #1417.
What it can do
- Segment the morphemes of a sentence into bunsetsu (chunking), with a conditional random field and a model that is a table of weights. With IPADIC, the F-score is 96.97 on the dev file and 97.02 on the test file of UD Japanese-GSD.
- Keep a model in one file per dictionary and read it in place: from bytes embedded in a program, read from a file or mapped into memory, without copying its tables. The file names its dictionary, and morphemes that cannot be of that dictionary are refused.
- Parse the dependencies of the bunsetsu with shift-reduce and a classifier over features and pairs of features, as CaboCha and J.DepP do, and train that classifier. With IPADIC, 90.09% of the bunsetsu of the dev file of UD Japanese-GSD get the right head with the bunsetsu of the answer (88.66% on the test file), and 85.55% from the morphemes (84.72%).
- Parse plain text from the command line, tokenized with a Lindera dictionary, and write what
cabocha -f1writes. - Run as a token filter of Lindera,
japanese_dependency: from thelinderacommand, a configuration file, Rust and the five bindings, with the bunsetsu and the head of each token in the JSON output and on theToken. - Give the head word and the function word of a bunsetsu, and recognize punctuation and brackets, from a schema of the dictionary. IPADIC is the first schema.
- Read and write the lattice format of CaboCha (
cabocha -f1), and check that a sentence is the tree the parsers assume. - Make training data from a dependency corpus such as UD Japanese-GSD, on the morphemes of the dictionary the parser will run with.
- Convert the three models CaboCha distributes, for IPA, for JUMAN and for UniDic, into a model file that analyzes as CaboCha does. Such a model is limited to research and personal use, as CaboCha's.
- Evaluate chunking and dependency accuracy as CaboCha and J.DepP count them, and compare two outputs with a paired test.
The default build has no dependency and builds for wasm32-unknown-unknown: it holds the types, the lattice format, the schema, the model file, the chunker and the parser. The training and the evaluation are behind the train feature. The crate is a library: its command is lindera dependency, of the lindera command.
Contents
-
Installation -- The crate, the builds that have the token filter, and the three ways to get the model
-
Quick Start -- One sentence parsed with the released model, from the command line and from Rust
-
Reading and Using the Result -- What a bunsetsu and a dependency are, the result of several kinds of sentence, a program that uses it, and how far to trust it
-
Architecture -- The modules, the types, the lattice format and the feature flags
-
Chunking -- Segmenting morphemes into bunsetsu, and training a model
-
Parsing -- Finding the head of each bunsetsu: the loop, the features, training a model, and its accuracy
-
Model File -- The file of a dictionary: reading it in place, checking the dictionary, and its format
-
CaboCha's Models -- Converting the models CaboCha distributes: their terms, the command, what is converted, and the agreement with CaboCha
-
Command Line -- Parsing plain text with
lindera dependency parse: the options, the input layers, the speed -
Token Filter -- The filter
japanese_dependencyof the Lindera tokenizer: the build, what is written on a token, the sentences, the order of the filters, the speed -
Head and Function Word -- The schema of a dictionary and the two words of a bunsetsu
-
Training Data -- Making training data from UD Japanese-GSD
-
Evaluation -- Counting accuracy, comparing two outputs, and cross-validation
-
API Reference -- The documentation of the crate on docs.rs
For the decisions behind the crate and the numbers they rest on, see the design notes.