code wiki / (root) / nx_depparse.nx

nx_depparse.nx

buildroot/runtime/nx_depparse.nx

21393 B536 linesdepth 4pulls 4 transitivereach 5 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_reviewmine_lib.nx nx_postag.nx nx_depparse.nx nx_absa_seq.nx nx_depparse_eval.nx nx_depparse_gate.nx

imports: nx_syscalls.nxnx_reviewmine_lib.nxnx_postag.nx

imported by: nx_absa_seq.nxnx_depparse_eval.nxnx_depparse_gate.nx

structs

none

consts

18const DP_W: i64 = 2097152 // 2^21 weight slots shared by (feature, action) pairs
19const DP_WMASK: i64 = 2097151
20const DP_EPOCHS: i64 = 12 // 5 left 17777 updates in the last epoch on EWT (UAS 804); raised toward convergence
21const DP_NFEAT: i64 = 24
22const DP_NREL: i64 = 48 // label table cap (UD v2 has 37 universal relations)
23const DP_RELNAME: i64 = 16 // bytes per interned relation name
24const DP_ACT_SHIFT: i64 = 0 // LEFT-ARC(r) = 1 + r ; RIGHT-ARC(r) = 1 + DP_NREL + r
25const DP_NACT: i64 = 97 // 1 + 2 * DP_NREL
26const DP_NONE: i64 = 0 - 1
27const DP_TOK_CAP: i64 = 256 // same as the reader's
28const DP_NODE_CAP: i64 = 258 // tokens + the virtual ROOT + one spare
29const DP_FEATBUF: i64 = 192
30const DP_DIST_CAP: i64 = 6 // distance buckets 1..5 and 6-or-more
31const DP_CH_CARET: i64 = 94 // '^' encodes tag -1
32const DP_CH_DOLLAR: i64 = 36 // '$' the ROOT node's tag byte
33const DP_CH_AT: i64 = 64 // '@' no such node (child absent, buffer exhausted)
34const DP_CH_A: i64 = 65 // 'A' + rel id encodes a relation as one byte
35const DP_CH_ZERO: i64 = 48
36const DP_SEP: i64 = 31 // unit separator between two words in one feature
37const DP_PERMIL: i64 = 1000
39const DP_PFX_B: i64 = 98 // 'b' bias
40const DP_PFX_S0W: i64 = 65
41const DP_PFX_S0P: i64 = 66
42const DP_PFX_S0WP: i64 = 67
43const DP_PFX_S1W: i64 = 68
44const DP_PFX_S1P: i64 = 69
45const DP_PFX_S1WP: i64 = 70
46const DP_PFX_B0W: i64 = 71
47const DP_PFX_B0P: i64 = 72
48const DP_PFX_B0WP: i64 = 73
49const DP_PFX_B1P: i64 = 74
50const DP_PFX_B2P: i64 = 75
51const DP_PFX_S0PB0P: i64 = 76
52const DP_PFX_S1PS0P: i64 = 77
53const DP_PFX_S1PS0PB0P: i64 = 78
54const DP_PFX_S0PB0PB1P: i64 = 79
55const DP_PFX_S1PS0PS0LP: i64 = 80
56const DP_PFX_S1PS0PS0RP: i64 = 81
57const DP_PFX_S1PS1RPS0P: i64 = 82
58const DP_PFX_S1PS1LPS0P: i64 = 83
59const DP_PFX_S0WB0W: i64 = 84
60const DP_PFX_S1WS0W: i64 = 85
61const DP_PFX_DIST: i64 = 86
62const DP_PFX_S0RR: i64 = 87
64const DP_O_TOKENS: i64 = 0
65const DP_O_UAS_CORRECT: i64 = 1
66const DP_O_LAS_CORRECT: i64 = 2
67const DP_O_UAS: i64 = 3 // permil
68const DP_O_LAS: i64 = 4 // permil, on the base relation names
69const DP_O_TRAINSENT: i64 = 5
70const DP_O_TRAINTOK: i64 = 6
71const DP_O_NONPROJ: i64 = 7 // training sentences the static oracle could not reach (skipped)
72const DP_O_TESTSENT: i64 = 8
73const DP_O_UPDATES: i64 = 9 // updates in the last epoch
74const DP_O_NREL: i64 = 10 // relation labels interned
75const DP_O_UNUSABLE: i64 = 11 // training sentences with an absent HEAD or an overflowing label table
76const DP_O_N: i64 = 12

functions

112func dp_reset() -> i64
called by 3: sp_evaldp_evalmain calls 1: sys_mmap
146func dp_rel_id(s: *u8, n: i64, intern: i64) -> i64
called by 2: dp_load_goldmain
167func dp_rel_name(id: i64, out: *u8) -> i64
called by 1: main
174func dp_wp(i: i64) -> *u8
called by 3: dp_fwdp_fwtdp_fww
179func dp_wl(i: i64) -> i64
called by 3: dp_fwdp_fwtdp_fww
184func dp_tb(i: i64) -> i64
called by 2: dp_fwtdp_feats
189func dp_lcof(i: i64) -> i64 { if i < 0 { return DP_NONE } return dp_lc[i] }
called by 1: dp_feats
190func dp_rcof(i: i64) -> i64 { if i < 0 { return DP_NONE } return dp_rc[i] }
called by 1: dp_feats
191func dp_relbyte(i: i64) -> i64
called by 1: dp_feats
197func dp_f0(pfx: i64) -> i64 { dp_featbuf[0] = pfx as u8; return rm_hash(dp_featbuf, 1) }
called by 1: dp_feats calls 1: rm_hash
198func 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) }
called by 1: dp_feats calls 1: rm_hash
199func 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) }
called by 1: dp_feats calls 1: rm_hash
200func 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) }
called by 1: dp_feats calls 1: rm_hash
201func dp_fw(pfx: i64, i: i64) -> i64
called by 1: dp_feats calls 3: dp_wpdp_wlrm_hash
210func dp_fwt(pfx: i64, i: i64) -> i64
called by 1: dp_feats calls 4: dp_tbdp_wpdp_wlrm_hash
220func dp_fww(pfx: i64, i: i64, j: i64) -> i64
called by 1: dp_feats calls 3: dp_wpdp_wlrm_hash
235func dp_feats() -> i64
275func dp_w_at(idx: i64, useavg: i64) -> i64
called by 1: dp_score
279func dp_bump(idx: i64, delta: i64) -> i64
called by 1: dp_update
285func dp_score(act: i64, useavg: i64) -> i64
called by 1: dp_predict calls 1: dp_w_at
292func dp_valid(act: i64) -> i64
called by 1: dp_predict
307func dp_predict(useavg: i64) -> i64
called by 1: dp_parse_loaded calls 2: dp_validdp_score
320func dp_apply(act: i64) -> i64
called by 1: dp_parse_loaded
348func dp_oracle() -> i64
called by 1: dp_parse_loaded
361func dp_init_state() -> i64
called by 1: dp_parse_loaded
369func dp_update(gold: i64, pred: i64) -> i64
called by 1: dp_parse_loaded calls 1: dp_bump
380func dp_parse_loaded(train: i64) -> i64
403func dp_load_gold(cnt: i64, intern: i64) -> i64
called by 2: dp_traindp_test calls 1: dp_rel_id
420func dp_bind_reader(cnt: i64) -> i64
called by 2: dp_traindp_test calls 1: pt_tag_loaded
429func dp_train(path: *u8, out: *i64) -> i64
472func dp_test(path: *u8, out: *i64) -> i64
510func dp_eval(train: *u8, test: *u8, out: *i64) -> i64
called by 2: mainmain calls 3: dp_resetdp_traindp_test
519func dp_parse_stream(buf: *u8, offs: *i64, lens: *i64, tags: *i64, cnt: i64, heads_out: *i64, rels_out: *i64) -> i64
called by 2: sp_tag_sentencemain calls 1: dp_parse_loaded