Pre-requisites
pip3 install -r scripts/requirements.txt
This is only needed if you are extending the corpus
python align_after_seva.py ../v2.0/source/bruk ../v2.0/output/bruk
python align_after_seva.py ../v2.0/source/ng ../v2.0/output/ngpython calculate_split_stats.py ../v2.0/data ../v2.0/data/dev-test-split.txtIf you need data in IOB/BEIOS formats for some other kinds of training just use convert_data.py script.
To export in IOB format with no inner nested tags:
python convert_data.py --src_dataset ../v2.0/data --dst /tmp/ner-output --overlap_strategy remove_inner --split_file ../v2.0/data/dev-test-split.txtYou can change the overlap_strategy parameter to remove outer overlapping tags
python3 scripts/convert_data.py will generate iob files according to train/test split provided.
For more parameters run python3 scripts/convert_data.py -h.
python3 -m unittest discover -s testRequirements:
- trained feature extractor - binary can be obtained by running
MITIE/tools/wordrepon data set. If not provided, the script will try to download pre-trained model.
Run from project root
python3 scripts/train_mitie_ner.py
Use python3 scripts/ner_train_mitie.py -h to print cmd line arguments.
The resulting model will reside in workspace/mitie/mitie_ner_model.dat
Stanza already has almost everything that is required to train on our data set. But if the dataset was updated - you can execute the training process with scripts/train_stanza_ner.sh`
To use custom word vectors, specify its file path with the argument --word_vecor-w. **Stanza uses vectors of dimension 100**. scripts/train_stanza_ner.sh -w=path_to_your_wordvec_file`
Vector file must be converted to .pt format (pytorch binary format) using script from stanza convert_pretrain.py. For more details please read here in Stanza docs.
Vector file to be converted - must start with line of format: <word_count> <dimension [100]>
Word count can usually be obtained by wc -l <file>
The trained model will be available under workspace/stanza folder.
Stanza additionally provides a pretrained Character level model. It was shown to improve the performance of the NER model by around 1%.
Execute: python3 scripts/eval_ner_models.py --stanza=<path_to_stanza_model> --mitie=<path_to_mitie_model>
The script will produce a report with the help of sklearn classification report and will print it out to the console.
If you want to get the most recent numbers on the corpus (document count, token count, split between train and test sets) - just run scripts/corpus_stats.py
$ sbcl --non-interactive --eval '(compile-file "tokenize-uk--all-systems.lisp")'
-
tokenize text from STDIN line-by-line:
$ sbcl --script tokenize-uk--all-systems.fasl -
tokenize files (for each file create a corresponding .tok file):
$ sbcl --script tokenize-uk--all-systems.fasl -- file-to-tokenize1 file-to-tokenize2 ...