code wiki / (root) / nx_depparse_eval.nx

nx_depparse_eval.nx source

↩ module page · 55 lines · 2853 B

1// nx_depparse_eval.nx -- train the estate's POS tagger and dependency parser (nx_postag, nx_depparse) on a CoNLL-U 2// treebank and report attachment scores on a second one. ONE call: nx_depparse_eval <train.conllu> <test.conllu> [label] 3// The tagger is trained first and the parser reads ITS tags on both splits (one tag generator, no gold-tag optimism). 4// The bar is the published accuracy of feature-based transition parsers on UD English EWT (greedy averaged-perceptron 5// arc-standard parsers read in the middle-to-high eighties UAS; neural parsers read the low nineties); the receipt 6// carries every count so a partial read cannot pass as a whole one. license_tier: ORIGINAL No hw writes (Rule 26). 7import "nx_syscalls.nx" 8import "nx_reviewmine_lib.nx" 9import "nx_postag.nx" 10import "nx_depparse.nx" 11 12const DE_ARG_TRAIN: i64 = 1 13const DE_ARG_TEST: i64 = 2 14const DE_ARG_LABEL: i64 = 3 15const DE_EXIT_USAGE: i64 = 2 16const DE_EXIT_NOFILE: i64 = 3 17 18func main(argc: i64, argv: *i64) -> i64 { 19 if argc <= DE_ARG_TEST { 20 rm_w("usage: nx_depparse_eval <train.conllu> <test.conllu> [label]\n" as *u8) 21 sys_exit(DE_EXIT_USAGE); return DE_EXIT_USAGE 22 } 23 let train: *u8 = argv[DE_ARG_TRAIN] as *u8 24 let test: *u8 = argv[DE_ARG_TEST] as *u8 25 var label: *u8 = test 26 if argc > DE_ARG_LABEL { label = argv[DE_ARG_LABEL] as *u8 } 27 let po: *i64 = sys_mmap(PT_O_N * RM_I64_BYTES) as *i64 28 if pt_eval(train, test, po) < 0 { 29 rm_w("DEPPARSE REFUSED cannot read a treebank\n" as *u8) 30 sys_exit(DE_EXIT_NOFILE); return DE_EXIT_NOFILE 31 } 32 let out: *i64 = sys_mmap(DP_O_N * RM_I64_BYTES) as *i64 33 if dp_eval(train, test, out) < 0 { 34 rm_w("DEPPARSE REFUSED cannot read a treebank\n" as *u8) 35 sys_exit(DE_EXIT_NOFILE); return DE_EXIT_NOFILE 36 } 37 rm_w("DEPPARSE-EVAL corpus=" as *u8); rm_w(label) 38 rm_w(" tokens=" as *u8); rm_wn(out[DP_O_TOKENS]) 39 rm_w(" uas_correct=" as *u8); rm_wn(out[DP_O_UAS_CORRECT]) 40 rm_w(" las_correct=" as *u8); rm_wn(out[DP_O_LAS_CORRECT]) 41 rm_w(" uas_permil=" as *u8); rm_wn(out[DP_O_UAS]) 42 rm_w(" las_base_permil=" as *u8); rm_wn(out[DP_O_LAS]) 43 rm_w(" train_sentences=" as *u8); rm_wn(out[DP_O_TRAINSENT]) 44 rm_w(" train_tokens=" as *u8); rm_wn(out[DP_O_TRAINTOK]) 45 rm_w(" nonprojective_skipped=" as *u8); rm_wn(out[DP_O_NONPROJ]) 46 rm_w(" unusable_skipped=" as *u8); rm_wn(out[DP_O_UNUSABLE]) 47 rm_w(" test_sentences=" as *u8); rm_wn(out[DP_O_TESTSENT]) 48 rm_w(" relation_labels=" as *u8); rm_wn(out[DP_O_NREL]) 49 rm_w(" epochs=" as *u8); rm_wn(DP_EPOCHS) 50 rm_w(" last_epoch_updates=" as *u8); rm_wn(out[DP_O_UPDATES]) 51 rm_w(" tagger_accuracy_permil=" as *u8); rm_wn(po[PT_O_ACC]) 52 rm_w(" metric=arc-standard-averaged-perceptron-uas-las-on-a-conllu-treebank-with-predicted-tags\n" as *u8) 53 sys_exit(0) 54 return 0 55}