essyntax
Fast Spanish dependency parser written in Rust, the core of the esSyntax library for Python: the head and the Universal Dependencies relation of every word of a sentence.
- The input is the words of a sentence with their UD part of speech and features, for example from the morphological analyzer esMorph; the output is the number of the head of every word (0 for the root) and its relation.
- The model is a BiLSTM over the words, their endings and tags; the heads come from a biaffine score and the tree of the maximum weight with one root (non-projective trees too), the relations from the pair "dependent - head". In degenerate sentences (more than 16 cycles or 8 root candidates among the best heads) and in sentences longer than 1024 words the tree is assembled faster: the extra roots and the nodes of cycles are attached to the best root; in long sentences the head is looked for among 64 words on each side and the root, and the time grows linearly with the length.
- The part of speech is one of the 17 UD parts of speech in capitals (an unknown one is parsed as
X), the features are in the CoNLL-U notation. ARelationhas the head, the relation, its number inParser::relationsand the probabilities of the head and the relation by the model (head_prob,deprel_prob);Parser::checksumis the CRC32 of the model. - Sentences of close length are parsed four at once:
Parser::parse_many.
The model is not part of the crate: the parser reads it from a file, such as data/es-syntax.bin of the repository,
trained on the treebanks UD Spanish AnCora and GSD (CC BY-SA 4.0,
LICENSE-MODEL.txt).
Example
use ;
The model is loaded and checked on every call of Parser::from_path and Parser::from_bytes: create the parser once
and parse all the text with it, from several threads too.
Model file
The header is the signature ESSYNTAX, the format version and the CRC32 of the rest of the file; then come entries by
name: lists of strings, matrices of f32 or of int8 by rows with a scale per row, numbers. A file of another format
version, a damaged one or one with weights of disagreeing sizes is not loaded: Error::Format.
License
The code is distributed under the MIT license.