nx_keyness.nx
buildroot/runtime/nx_keyness.nx
about
nx_keyness.nx -- substrate-native keyword extraction.
"Keyness" answers the canonical corpus-linguistics question:
what words are distinctively COMMON in target corpus vs reference?
Standard metric is Dunning's log-likelihood applied to a 2x2
contingency table comparing token frequencies between corpora.
This is identical in shape to the collocation log-likelihood --
the difference is the meaning of the cells:
Collocation: word_a vs word_b in same corpus, n_ab co-occurrences
Keyness: same word in target vs reference corpus
Composes:
nx_collocation.nx -- log-likelihood already there; we reuse it
Sealed verdict bands (Sketch Engine convention, see Kilgarriff 2009):
POSITIVE_KEYWORD_STRONG -- strongly over-represented in target
POSITIVE_KEYWORD_WEAK -- modestly over-represented
NEUTRAL -- about the same in both
NEGATIVE_KEYWORD -- under-represented in target
genealogy_id: dunning_1993_log_likelihood + scott_1997_wordsmith_keywords +
kilgarriff_2009_simple_maths
lineage_id: keyness_extraction_v1
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_tier.nxnx_collocation.nx
imported by: nx_keyness_test.nx
structs
| none |
consts
| 36 | const NX_MAGIC_1024: i64 = 1024 |
| 37 | const NX_MAGIC_2048: i64 = 2048 |
| 45 | const NX_KEY_NEGATIVE_STRONG: nx_int = 0 // strongly under in target |
| 46 | const NX_KEY_NEGATIVE_WEAK: nx_int = 1 |
| 47 | const NX_KEY_NEUTRAL: nx_int = 2 // ratio close to 1 |
| 48 | const NX_KEY_POSITIVE_WEAK: nx_int = 3 |
| 49 | const NX_KEY_POSITIVE_STRONG: nx_int = 4 // strongly over in target |
| 50 | const NX_KEY_N_KINDS: nx_int = 5 |
| 119 | const NX_KEY_THRESH_WEAK_Q10: nx_int = 3932 // 3.84 * 1024 |
| 120 | const NX_KEY_THRESH_STRONG_Q10: nx_int = 15493 // 15.13 * 1024 |
| 203 | const NX_KEY_OUT_G2_Q10: nx_int = 0 |
| 204 | const NX_KEY_OUT_LOG_RATIO_Q10: nx_int = 1 |
| 205 | const NX_KEY_OUT_BAND: nx_int = 2 |
| 206 | const NX_KEY_OUT_OVER: nx_int = 3 // 1 = target over-represented |
| 207 | const NX_KEY_OUT_FIELDS: nx_int = 4 |
functions
| 52 | func nx_key_kind_is_valid(k: nx_int) -> nx_int called by 1: main |
| 65 | func nx_key_target_overrepresented(observed_target: nx_int, total_target: nx_int, |
| 94 | func nx_keyness_g2_q10(observed_target: nx_int, total_target: nx_int, called by 2: nx_keyness_emit_allmain calls 2: nx_col_log_likelihood_q10nx_key_target_overrepresented |
| 122 | func nx_keyness_band(g2_q10: nx_int) -> nx_int |
| 157 | func _key_log2_ratio_q10(num: nx_int, den: nx_int) -> nx_int called by 1: nx_keyness_log_ratio_q10 |
| 190 | func nx_keyness_log_ratio_q10(observed_target: nx_int, total_target: nx_int, |
| 209 | func nx_keyness_emit_all(observed_target: nx_int, total_target: nx_int, called by 1: main calls 4: nx_keyness_g2_q10nx_keyness_log_ratio_q10nx_keyness_bandnx_key_target_overrepresented |