Created
September 20, 2021 14:04
-
-
Save fhardison/f14969f411f8643cf40a6a065871abb1 to your computer and use it in GitHub Desktop.
Simple tool for generating a paradigm from the tokens file format used in vocabulary-tools gnt_data (by James Tauber: https://github.com/jtauber/vocabulary-tools)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from greek_normalisation.utils import nfc,grave_to_acute | |
def layout_paradigm(forms, row_identifiers, column_idenfiers): | |
#""" forms: [(form, parse)] | |
#... idenfiers = [lambda x: -> Boolean] | |
#""" | |
output = [] | |
for rfn in row_identifiers: | |
row = [] | |
for cfn in column_idenfiers: | |
cell = '' | |
for (form, parse) in forms: | |
if rfn(parse) and cfn(parse): | |
cell += grave_to_acute(form) + ' ' | |
#break | |
if not cell.strip(): | |
cell = '-' | |
row.append(cell.strip()) | |
output.append(row) | |
return output | |
# example of how to use the tool to find Greek paradigms for noun like things. | |
def layout_nouny_paradigm(forms): | |
row_ident = [ | |
lambda x: x[4] == 'N' and x[5] == 'S', | |
lambda x: x[4] == 'G' and x[5] == 'S', | |
lambda x: x[4] == 'D' and x[5] == 'S', | |
lambda x: x[4] == 'A' and x[5] == 'S', | |
lambda x: x[4] == 'N' and x[5] == 'P', | |
lambda x: x[4] == 'G' and x[5] == 'P', | |
lambda x: x[4] == 'D' and x[5] == 'P', | |
lambda x: x[4] == 'A' and x[5] == 'P' | |
] | |
col_ident = [ | |
lambda x: x[6] == 'M', | |
lambda x: x[6] == 'F', | |
lambda x: x[6] == 'N' | |
] | |
return layout_paradigm(forms, row_ident, col_ident) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment