Open JeltevanBoheemen opened 4 years ago
In LASSY XML files (Alpino parses), make a script that replaces attribute-value pairs based on client-specified python dictionary.
Current dictionary: REPLACEMENTS = { 'eh': { 'search': {'lemma': 'eh', 'word': 'eh'}, 'remove': ['genus', 'getal', 'graad', 'naamval', 'ntype'], 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} }, 'uh': { 'search': {'lemma': 'eh', 'word': 'uh'}, 'remove': ['genus', 'getal', 'graad', 'naamval', 'ntype'], 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} }, 'xxx': { 'search': {'word': 'xxx'}, 'keep_only': ['begin', 'end', 'pos', 'root', 'postag', 'pt', 'lemma', 'word', 'sense', 'rel', 'id'], 'edit': {'pos': 'tag', 'postag': 'SPEC(onverst)', 'pt': 'spec', 'spectype': 'onverst'} }, 'yyy': { 'search': {'word': 'yyy'}, 'keep_only': ['begin', 'end', 'pos', 'root', 'postag', 'pt', 'lemma', 'word', 'sense', 'rel', 'id'], 'edit': {'pos': 'tag', 'postag': 'SPEC(onverst)', 'pt': 'spec', 'spectype': 'onverst'} }, 'NA()': { 'search': {'postag': 'NA()'}, 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} } }
REPLACEMENTS = { 'eh': { 'search': {'lemma': 'eh', 'word': 'eh'}, 'remove': ['genus', 'getal', 'graad', 'naamval', 'ntype'], 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} }, 'uh': { 'search': {'lemma': 'eh', 'word': 'uh'}, 'remove': ['genus', 'getal', 'graad', 'naamval', 'ntype'], 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} }, 'xxx': { 'search': {'word': 'xxx'}, 'keep_only': ['begin', 'end', 'pos', 'root', 'postag', 'pt', 'lemma', 'word', 'sense', 'rel', 'id'], 'edit': {'pos': 'tag', 'postag': 'SPEC(onverst)', 'pt': 'spec', 'spectype': 'onverst'} }, 'yyy': { 'search': {'word': 'yyy'}, 'keep_only': ['begin', 'end', 'pos', 'root', 'postag', 'pt', 'lemma', 'word', 'sense', 'rel', 'id'], 'edit': {'pos': 'tag', 'postag': 'SPEC(onverst)', 'pt': 'spec', 'spectype': 'onverst'} }, 'NA()': { 'search': {'postag': 'NA()'}, 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} } }
Operations:
search specifies attribute-value pairs that should produce the nodes on which to apply the other operations. In case of multiple, all should apply.
search
remove specifies attributes that should be discarded
remove
keep_only is the opposite of remove, only keep these attributes
keep_only
edit replaces the attribute with the new attribute-value pair
edit
In LASSY XML files (Alpino parses), make a script that replaces attribute-value pairs based on client-specified python dictionary.
Current dictionary:
REPLACEMENTS = { 'eh': { 'search': {'lemma': 'eh', 'word': 'eh'}, 'remove': ['genus', 'getal', 'graad', 'naamval', 'ntype'], 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} }, 'uh': { 'search': {'lemma': 'eh', 'word': 'uh'}, 'remove': ['genus', 'getal', 'graad', 'naamval', 'ntype'], 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} }, 'xxx': { 'search': {'word': 'xxx'}, 'keep_only': ['begin', 'end', 'pos', 'root', 'postag', 'pt', 'lemma', 'word', 'sense', 'rel', 'id'], 'edit': {'pos': 'tag', 'postag': 'SPEC(onverst)', 'pt': 'spec', 'spectype': 'onverst'} }, 'yyy': { 'search': {'word': 'yyy'}, 'keep_only': ['begin', 'end', 'pos', 'root', 'postag', 'pt', 'lemma', 'word', 'sense', 'rel', 'id'], 'edit': {'pos': 'tag', 'postag': 'SPEC(onverst)', 'pt': 'spec', 'spectype': 'onverst'} }, 'NA()': { 'search': {'postag': 'NA()'}, 'edit': {'postag': 'TSW()', 'pt': 'tsw', 'pos': 'tag'} } }
Operations:
search
specifies attribute-value pairs that should produce the nodes on which to apply the other operations. In case of multiple, all should apply.remove
specifies attributes that should be discardedkeep_only
is the opposite of remove, only keep these attributesedit
replaces the attribute with the new attribute-value pair