semfont is a small library that analyzes plain text and maps semantic signals to typography to make prose easier to scan. It computes four per-word scores: valence (good/bad, -1 to 1) adjusted by nearby negators (reach ~3 words, with damping) and intensifiers; salience (0-1) from corpus rarity plus repetition within the passage; surprise (0-1) from explicit cue words, contrast windows (six words after a contrast, decaying with distance), and words much rarer than the passage mean; and certainty (−1 to 1) from hedge and assertion words, with hedges propagating ~55% to the rest of the sentence. Those scores are mapped to visual axes (valence→color, salience→weight, surprise→highlight, certainty→slant) with thresholds so most words remain untouched.
A second, clause-aware pass resolves longer-range phenomena: negators reach to clause end with distance-based fading; verbs like fixed mark following tokens as resolved; sarcasm and comparative patterns get special cases. The engine exposes analyze() for token scores and a styleFor/themes layer to produce CSS, plus a React SemanticText component for streaming chat UIs. It’s lightweight enough to run client-side via an import map/CDN and is intended for live AI streams; imperfections are expected and future work targets sarcasm, embedded-clause negation, and domain vocabularies. Code and demo live at github.com/RohanAdwankar/semfont.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.