nx_depparse.nx
buildroot/runtime/nx_depparse.nx
about
nx_depparse.nx -- a DEPENDENCY PARSER for the estate (rung IM28's parse-feature lever: DLIREC, the SemEval-2014
restaurants winner, took its exceed from dependency features, and nx_capsearch over 7,437 organs found no parser
here -- every hit was the software-dependency homonym). ARC-STANDARD transition parsing (SHIFT, LEFT-ARC(rel),
RIGHT-ARC(rel)) with a greedy AVERAGED PERCEPTRON over the actions, integer weights only (nofloat), trained by the
STATIC ORACLE on a CoNLL-U treebank read by nx_postag's reader (HEAD and DEPREL columns), with POS tags from
nx_postag's own predictions on the training sentences, so train and test see ONE tag generator. Relation labels are
the UD base names (before ':'), interned in first-seen order at training. Non-projective training sentences (the
static oracle cannot reach them) are SKIPPED and counted. A single-root constraint: the root attaches only once the
buffer is empty. dp_parse_stream parses ANY tagged token stream, which is how the aspect model consumes it.
FEATURES (Zhang and Nivre 2011's core): word and tag of s0, s1, b0, b1, b2, their word+tag pairs, tag pairs and
triples across the stack top and buffer front, the tags of s0's and s1's leftmost and rightmost children, word pairs
s0+b0 and s1+s0, the bucketed distance s1..s0 with their tags, and the relation of s0's rightmost child.
license_tier: ORIGINAL No hw writes (Rule 26). LIB.
dependencies 3 imports · 3 importers
imports: nx_syscalls.nxnx_reviewmine_lib.nxnx_postag.nx
imported by: nx_absa_seq.nxnx_depparse_eval.nxnx_depparse_gate.nx
structs
| none |
consts
| 18 | const DP_W: i64 = 2097152 // 2^21 weight slots shared by (feature, action) pairs |
| 19 | const DP_WMASK: i64 = 2097151 |
| 20 | const DP_EPOCHS: i64 = 12 // 5 left 17777 updates in the last epoch on EWT (UAS 804); raised toward convergence |
| 21 | const DP_NFEAT: i64 = 24 |
| 22 | const DP_NREL: i64 = 48 // label table cap (UD v2 has 37 universal relations) |
| 23 | const DP_RELNAME: i64 = 16 // bytes per interned relation name |
| 24 | const DP_ACT_SHIFT: i64 = 0 // LEFT-ARC(r) = 1 + r ; RIGHT-ARC(r) = 1 + DP_NREL + r |
| 25 | const DP_NACT: i64 = 97 // 1 + 2 * DP_NREL |
| 26 | const DP_NONE: i64 = 0 - 1 |
| 27 | const DP_TOK_CAP: i64 = 256 // same as the reader's |
| 28 | const DP_NODE_CAP: i64 = 258 // tokens + the virtual ROOT + one spare |
| 29 | const DP_FEATBUF: i64 = 192 |
| 30 | const DP_DIST_CAP: i64 = 6 // distance buckets 1..5 and 6-or-more |
| 31 | const DP_CH_CARET: i64 = 94 // '^' encodes tag -1 |
| 32 | const DP_CH_DOLLAR: i64 = 36 // '$' the ROOT node's tag byte |
| 33 | const DP_CH_AT: i64 = 64 // '@' no such node (child absent, buffer exhausted) |
| 34 | const DP_CH_A: i64 = 65 // 'A' + rel id encodes a relation as one byte |
| 35 | const DP_CH_ZERO: i64 = 48 |
| 36 | const DP_SEP: i64 = 31 // unit separator between two words in one feature |
| 37 | const DP_PERMIL: i64 = 1000 |
| 39 | const DP_PFX_B: i64 = 98 // 'b' bias |
| 40 | const DP_PFX_S0W: i64 = 65 |
| 41 | const DP_PFX_S0P: i64 = 66 |
| 42 | const DP_PFX_S0WP: i64 = 67 |
| 43 | const DP_PFX_S1W: i64 = 68 |
| 44 | const DP_PFX_S1P: i64 = 69 |
| 45 | const DP_PFX_S1WP: i64 = 70 |
| 46 | const DP_PFX_B0W: i64 = 71 |
| 47 | const DP_PFX_B0P: i64 = 72 |
| 48 | const DP_PFX_B0WP: i64 = 73 |
| 49 | const DP_PFX_B1P: i64 = 74 |
| 50 | const DP_PFX_B2P: i64 = 75 |
| 51 | const DP_PFX_S0PB0P: i64 = 76 |
| 52 | const DP_PFX_S1PS0P: i64 = 77 |
| 53 | const DP_PFX_S1PS0PB0P: i64 = 78 |
| 54 | const DP_PFX_S0PB0PB1P: i64 = 79 |
| 55 | const DP_PFX_S1PS0PS0LP: i64 = 80 |
| 56 | const DP_PFX_S1PS0PS0RP: i64 = 81 |
| 57 | const DP_PFX_S1PS1RPS0P: i64 = 82 |
| 58 | const DP_PFX_S1PS1LPS0P: i64 = 83 |
| 59 | const DP_PFX_S0WB0W: i64 = 84 |
| 60 | const DP_PFX_S1WS0W: i64 = 85 |
| 61 | const DP_PFX_DIST: i64 = 86 |
| 62 | const DP_PFX_S0RR: i64 = 87 |
| 64 | const DP_O_TOKENS: i64 = 0 |
| 65 | const DP_O_UAS_CORRECT: i64 = 1 |
| 66 | const DP_O_LAS_CORRECT: i64 = 2 |
| 67 | const DP_O_UAS: i64 = 3 // permil |
| 68 | const DP_O_LAS: i64 = 4 // permil, on the base relation names |
| 69 | const DP_O_TRAINSENT: i64 = 5 |
| 70 | const DP_O_TRAINTOK: i64 = 6 |
| 71 | const DP_O_NONPROJ: i64 = 7 // training sentences the static oracle could not reach (skipped) |
| 72 | const DP_O_TESTSENT: i64 = 8 |
| 73 | const DP_O_UPDATES: i64 = 9 // updates in the last epoch |
| 74 | const DP_O_NREL: i64 = 10 // relation labels interned |
| 75 | const DP_O_UNUSABLE: i64 = 11 // training sentences with an absent HEAD or an overflowing label table |
| 76 | const DP_O_N: i64 = 12 |
functions
| 112 | func dp_reset() -> i64 |
| 146 | func dp_rel_id(s: *u8, n: i64, intern: i64) -> i64 |
| 167 | func dp_rel_name(id: i64, out: *u8) -> i64 called by 1: main |
| 174 | func dp_wp(i: i64) -> *u8 |
| 179 | func dp_wl(i: i64) -> i64 |
| 184 | func dp_tb(i: i64) -> i64 |
| 189 | func dp_lcof(i: i64) -> i64 { if i < 0 { return DP_NONE } return dp_lc[i] } called by 1: dp_feats |
| 190 | func dp_rcof(i: i64) -> i64 { if i < 0 { return DP_NONE } return dp_rc[i] } called by 1: dp_feats |
| 191 | func dp_relbyte(i: i64) -> i64 called by 1: dp_feats |
| 197 | func dp_f0(pfx: i64) -> i64 { dp_featbuf[0] = pfx as u8; return rm_hash(dp_featbuf, 1) } |
| 198 | func dp_ft1(pfx: i64, a: i64) -> i64 { dp_featbuf[0] = pfx as u8; dp_featbuf[1] = a as u8; return rm_hash(dp_featbuf, 2) } |
| 199 | func dp_ft2(pfx: i64, a: i64, b: i64) -> i64 { dp_featbuf[0] = pfx as u8; dp_featbuf[1] = a as u8; dp_featbuf[2] = b as u8; return rm_hash(dp_featbuf, 3) } |
| 200 | func dp_ft3(pfx: i64, a: i64, b: i64, c: i64) -> i64 { dp_featbuf[0] = pfx as u8; dp_featbuf[1] = a as u8; dp_featbuf[2] = b as u8; dp_featbuf[3] = c as u8; return rm_hash(dp_featbuf, 4) } |
| 201 | func dp_fw(pfx: i64, i: i64) -> i64 |
| 210 | func dp_fwt(pfx: i64, i: i64) -> i64 |
| 220 | func dp_fww(pfx: i64, i: i64, j: i64) -> i64 |
| 235 | func dp_feats() -> i64 |
| 275 | func dp_w_at(idx: i64, useavg: i64) -> i64 called by 1: dp_score |
| 279 | func dp_bump(idx: i64, delta: i64) -> i64 called by 1: dp_update |
| 285 | func dp_score(act: i64, useavg: i64) -> i64 |
| 292 | func dp_valid(act: i64) -> i64 called by 1: dp_predict |
| 307 | func dp_predict(useavg: i64) -> i64 |
| 320 | func dp_apply(act: i64) -> i64 called by 1: dp_parse_loaded |
| 348 | func dp_oracle() -> i64 called by 1: dp_parse_loaded |
| 361 | func dp_init_state() -> i64 called by 1: dp_parse_loaded |
| 369 | func dp_update(gold: i64, pred: i64) -> i64 |
| 380 | func dp_parse_loaded(train: i64) -> i64 called by 3: dp_traindp_testdp_parse_stream calls 6: dp_init_statedp_featsdp_oracledp_predictdp_updatedp_apply |
| 403 | func dp_load_gold(cnt: i64, intern: i64) -> i64 |
| 420 | func dp_bind_reader(cnt: i64) -> i64 |
| 429 | func dp_train(path: *u8, out: *i64) -> i64 called by 2: sp_evaldp_eval calls 6: sys_mmapsys_read_filept_read_sentencedp_bind_readerdp_load_golddp_parse_loaded |
| 472 | func dp_test(path: *u8, out: *i64) -> i64 called by 2: dp_evalmain calls 6: sys_mmapsys_read_filept_read_sentencedp_bind_readerdp_load_golddp_parse_loaded |
| 510 | func dp_eval(train: *u8, test: *u8, out: *i64) -> i64 |
| 519 | func dp_parse_stream(buf: *u8, offs: *i64, lens: *i64, tags: *i64, cnt: i64, heads_out: *i64, rels_out: *i64) -> i64 |