A font that reads what you wrote
Recorded: Sept. 22, 2026, 10:09 a.m.
| Original | Summarized |
A font that reads what you wrote — Rohan Adwankar A font that reads what you wrote ← Home ← HomeContents How it works semfont is a small library that sets typography automatically. theme How it works Salience is how much the word is worth looking at, 0 to 1. A frequency list gives each word a rarity, 0 for one of the hundred most common English words and 1 for one it has never seen. Rarity alone is not enough, so the score also rises with how often the word repeats in this particular text: an uncommon word you keep saying is what the text is about. // rarity('the') 0.00, rarity('kubelet') 0.93 Surprise is where the sentence turns, 0 to 1. Some words announce it on their own, like suddenly or ironically. Otherwise it comes from position: everything for six words after a contrast word gets it, decaying with distance, and so does any word much rarer than the rest of the passage. // 'The tests failed' -> failed 0.16 Certainty is how sure the writer sounds, -1 hedged to 1 asserted. Words like probably and definitely are in a table. But if you write The build probably failed, you are not unsure about the word probably, you are unsure about whether it failed. So the hedge keeps its own score and every other word in the sentence gets 55% of it, and the whole line leans a little instead of one word in the middle of it. // 'The build probably failed.' Then a theme maps each score to one typographic axis: valence to colour, salience to weight, surprise to a highlight, certainty to slant. Each axis has a threshold, so most words come out untouched. It costs about as much as the first pass and stays inside the budget, so there is no switch to flip. These are the ten sentences that led to it, including those two. Left is the first version, right is now. beforenow Using it <SemanticText as="p"> Pick a theme, or only the channels you want: Teach it your own vocabulary: Now for the case I started this for. AI system stream in a large amount of text and its hard to read all of it so the intention of this is a library that can easily be tossed into most streaming components to make the text easier to read: function Chat() { send plain text Or skip React and take the scores. analyze is the engine alone, four numbers per word, no CSS, and these imports work with no React installed: const { tokens } = analyze('The rollback failed too.'); That last form is how this page works. There is no bundler here, so one import map tells the browser where semfont/analyze and semfont/theme live, pinned to a version on npm, and the demo box above is the same three lines as the React component: analyze, style, render. Next Steps |
The semfont library is designed to automatically manage typography to enhance text readability by analyzing the semantic properties of the writing. The core mechanism involves assigning four scores to every word: valence, salience, surprise, and certainty. Valence measures the emotional quality of a word, ranging from negative to positive, which is dynamically adjusted based on contextual modifiers like negators and intensifiers to reflect nuanced meaning. Salience quantifies how important a word is to the text, factoring in both the rarity of the word and its repetition within the passage to gauge thematic focus. Surprise measures shifts in tone, triggered by contrasting words or positional context, and is influenced by word rarity. Finally, certainty assesses the writer's assertiveness regarding the text, which influences the scores of surrounding words within a sentence. These four derived scores are then mapped to specific typographic axes: valence controls color, salience controls weight, surprise dictates highlighting, and certainty influences slant. Thresholds are applied to these mappings to ensure that the resulting typographic adjustments are subtle, focusing on making adjustments rather than overstyling. The development of the system involves an iterative process to improve accuracy. An initial pass relies on local context, analyzing scores within a small window of surrounding words. A subsequent pass addresses these blind spots by analyzing clauses as whole units. This second phase looks for larger contextual cues, such as how negators affect distant words or how verbs indicate change, allowing the system to better detect complex linguistic phenomena like sarcasm or subtle complaints embedded in the text. This process results in specific notes attached to each word, allowing for an analysis of why a word received a particular visual treatment based on the calculated scores. The practical application of semfont involves integrating this analysis into various components. Users can interact with the library through a high-level component that accepts text and optionally applies themes or channels related to the calculated scores. Furthermore, the system allows for custom vocabulary definition, enabling the user to teach the system context-specific values for valence and salience. Implementation can be achieved either through a React-based approach where the scores drive dynamic styling or through a specialized analytical engine that calculates the scores directly. This latter method allows for a decoupled approach where textual analysis is separated from rendering, utilizing import maps to load the necessary analysis and theming logic directly from content delivery networks rather than relying on a full bundler environment. The ongoing goal is to refine the heuristics to handle complex linguistic issues like sarcasm and negations more effectively in streaming environments. |