nx_writecraft.nx
buildroot/runtime/nx_writecraft.nx
about
nx_writecraft.nx -- WRITING arc, rung W-R0: the bedrock prose-measurement organ.
Every writing domain the operator named (fiction, non-fiction, business,
academic, research papers) rests on the same three counts -- words, sentences,
syllables -- and the readability grades derived from them. This is the
foundation the rest of nishi-write (outliner, style/grammar, citations,
export) builds on; it is also the first DIRECTLY exceed-able rung vs the
readability engines in Hemingway Editor / Grammarly / ProWritingAid / MS Word.
Counting (heuristics, the same class the incumbents use):
- WORD = maximal run of ASCII letters (apostrophe kept inside a word:
"don't" = 1 word, 4 letters).
- SENTENCE = one run of terminal punctuation [.!?] (so "..." counts once).
- SYLLABLE = vowel-group count (a e i o u y), minus a silent trailing 'e',
EXCEPT a "consonant + le" ending keeps its syllable
("table"=2, "make"=1); floor of 1.
- COMPLEX = a word of >=3 syllables (Gunning Fog / SMOG input).
Readability is returned in MILLI-UNITS (value x 1000, integer, may be negative)
so the whole arc stays integer-only (no floats). The fixed-point formula is
exact where the divisions are exact and tracks the published real-number
formula elsewhere; the gate KATs both the exact case and the discrimination.
FRE (Flesch Reading Ease) x1000 = 206835 - 1015*W/S - 84600*Y/W
FKGL (Flesch-Kincaid Grade) x1000 = 390*W/S + 11800*Y/W - 15590
FOG (Gunning Fog index) x1000 = 400*W/S + 40000*C/W
where W=words S=sentences Y=syllables C=complex words.
Pure integer, NO floats, NO syscalls, NO imports (caller owns all buffers) --
the nx_note shape, so any lane (tutor, local-LLM, daemon) can call it.
wc_syllables(t, a, b) -- syllables in the word t[a..b) (b exclusive)
wc_counts(t, n, out) -- out[0]=letters out[1]=words out[2]=sentences
out[3]=syllables out[4]=complex; returns words
wc_flesch_reading_ease(out) -- FRE x1000 (higher = easier)
wc_fk_grade(out) -- FKGL x1000 (US grade level)
wc_gunning_fog(out) -- FOG x1000 (US grade level)
license_tier: ORIGINAL
module: nishi-core.write.craft
depends:
capability: WRITE_PROSE_METRICS
dependencies 0 imports · 6 importers
imports: none
imported by: nx_grammar.nxnx_ingest_scene.nxnx_tone.nxnx_write_exceed_gate.nxnx_writecraft_gate.nxnx_writestyle.nx
structs
| none |
consts
| none |
functions
| 43 | func wc_lower(c: i64) -> i64 |
| 51 | func wc_is_alpha(c: i64) -> i64 |
| 60 | func wc_is_vowel(c: i64) -> i64 |
| 72 | func wc_syllables(t: *u8, a: i64, b: i64) -> i64 |
| 106 | func wc_counts(t: *u8, n: i64, out: *i64) -> i64 |
| 163 | func wc_flesch_reading_ease(out: *i64) -> i64 called by 1: main |
| 173 | func wc_fk_grade(out: *i64) -> i64 |
| 183 | func wc_gunning_fog(out: *i64) -> i64 called by 1: main |