Research code for Cross-lingual Inflection as a Data Augmentation Method for Parsing (Insights 2022). The method trains a morphological inflector on a target language and applies it to selected parts of speech in a richer source-language UD treebank. The output retains the source syntax but replaces word forms with forms generated from the target-language morphology.
This repository exposes the data-conversion and treebank-reconstruction pipeline. Its two external tools are pinned as Git submodules. No treebanks, UniMorph snapshots, trained checkpoints, or paper result tables are bundled.
Clone the repository with its exact external revisions:
git clone --recursive https://github.com/amunozo/x-inflection.git
cd x-inflection
python -m pip install -r requirements.txtIf the repository was cloned without submodules:
git submodule update --init --recursiveThe UD-to-UniMorph converter only needs termcolor. Model training and decoding
use the environment specified in external/neural-transducer/environment.yml.
The training command does not access the network unless --download is
provided. Pinning --unimorph-ref is recommended for a reproducible run.
python scripts/train.py \
--lang fin \
--data-dir data/unimorph \
--download \
--unimorph-ref COMMIT \
--prepare-onlyThis clones https://github.com/unimorph/fin.git into
data/unimorph/fin/ and writes deterministic fin.train, fin.dev, and
fin.test files. To use an existing checkout, omit --download.
Remove --prepare-only to launch the neural-transducer training configuration:
python scripts/train.py \
--lang fin \
--data-dir data/unimorph \
--epochs 50 \
--batch-size 50Training is expensive and produces one or more files beginning with
data/unimorph/fin/model.nll. Use the exact desired checkpoint in the next
step; the pipeline refuses to choose arbitrarily when a directory contains
several.
The input directory may contain any subset of the standard train, dev, and test
files, named *-ud-train.conllu, *-ud-dev.conllu, and
*-ud-test.conllu.
python scripts/x-inflect.py \
--treebank-folder data/UD_Spanish-AnCora \
--model data/unimorph/fin/model.nll_EXACT_CHECKPOINT \
--output results/es-ancora-to-fin \
--pos-types ADJ NOUN VERB \
--device cpuThe command converts UD features to UniMorph in a temporary directory, extracts
the selected parts of speech, generates new forms, and reconstructs each
CoNLL-U split without modifying the source treebank. Output files are named
train.conllu, dev.conllu, and test.conllu.
--post-lang CODE enables a language-specific converter implemented by the
pinned ud-compatibility project. --decode beam selects beam search. Run any
entry point with --help for the complete set of path and device overrides.
Serialized PyTorch checkpoints can execute code while loading. Only use model files that you created or otherwise trust.
The lightweight suite exercises data splitting, CoNLL-U extraction and reconstruction, converter/decoder orchestration, all three treebank splits, and split-specific reconstruction. It does not download data or train a model.
python -m pip install -r requirements-dev.txt
pytest -q
ruff check src scripts tests --select E4,E7,E9,FThe complete training and parsing experiment matrix requires external UD and UniMorph snapshots, the neural-transducer environment, trained inflectors, and downstream parser runs. The lightweight test suite covers orchestration and local transformations.
@inproceedings{munoz-ortiz-etal-2022-cross,
title = {Cross-lingual Inflection as a Data Augmentation Method for Parsing},
author = {Mu{\~n}oz-Ortiz, Alberto and G{\'o}mez-Rodr{\'i}guez, Carlos and Vilares, David},
booktitle = {Proceedings of the Third Workshop on Insights from Negative Results in NLP},
year = {2022},
pages = {51--57},
doi = {10.18653/v1/2022.insights-1.7}
}The x-inflection code is available under the MIT License. The submodules retain their own licenses; see the license file in each external checkout.