neleval weights-for-hierarchy
¶
Translate a hierarchy of types into a sparse matrix of type-pair weights
See Approximate type matching.
Usage summary¶
$ neleval weights-for-hierarchy --help
usage: neleval weights-for-hierarchy [-h] [-d DECAY] FILE
Translate a hierarchy of types into a sparse matrix of type-pair weights
Input is a JSON object mapping parents to children in the hierarchy.
Output is a three-column TSV with:
* gold type
* system type
* weight
The weights are assigned such that where the system type is an ancestor of
the gold type with d edges between them, it will score (decay ** d).
positional arguments:
FILE Path to hierarchy JSON
optional arguments:
-h, --help show this help message and exit
-d DECAY, --decay DECAY
Decay value for systems selecting an ancestor of the
gold type
Converting JSON type hierarchy to weights¶
$ bash -c "\
neleval weights-for-hierarchy --decay 0.5 <( \
echo '{\"root\": [\"A\", \"B\"], \"A\": [\"A1\", \"A2\"], \"B\": [\"B1\"], \"B1\": [\"B1i\"]}' \
) \
"
A A1 0.500000
A A2 0.500000
B B1 0.500000
B B1i 0.250000
root A 0.500000
root A1 0.250000
root A2 0.250000
root B 0.500000
root B1 0.250000
root B1i 0.125000
B1 B1i 0.500000
These weights can be applied to evaluation with neleval evaluate’s
--type-weight
option.