Apple employs a sophisticated, albeit private, system to manage profanity and sensitive content within its keyboard and autocorrect engines. At the core of this system is the Lexicon.framework, a private framework that manages per-language dictionaries located in the system's linguistic data folders. Each word in these dictionaries is associated with two 32-bit flag fields: one for a 'tier' of vulgarity and another for a 'topic' bitmask. While Apple does not provide a public API for these flags, they can be accessed via private C functions to reveal how the OS classifies language.

The system distinguishes between three primary tiers of content: 'vulgar' (swearing and sex slang), 'offensive' (slurs aimed at groups of people), and 'sensitive' (mild swears, insults, drugs, weapons, and bodily functions). Additionally, words are assigned to up to eleven topic flags, such as excretion, body parts, drugs, politics, and religion. For example, while a word like 'Trump' is flagged in the sensitive tier, it also carries a politics topic flag. These flags work independently; a word can have a topic flag without being assigned to a vulgarity tier, which may serve as a hint for the ranking engine to handle the word with caution.

To balance these flags with user intent, macOS maintains a local SQLite database at `~/Library/Keyboard/VulgarWordUsage.db`. This database tracks the usage of words already identified as vulgar by the system, recording the count of use per application and per recipient. The goal is to allow the keyboard to 'learn' a user's habits—for instance, recognizing that a user might use a swear word with a close friend in a messaging app but should be steered toward a 'clean' alternative when writing an email to a colleague. However, the exact mechanism for how this data is populated remains somewhat opaque; in some tests, standard text input did not trigger new entries in the database, suggesting the recording may be restricted to specific apps or settings.

A screenshot of a tweet showing a Finder window with the VulgarWordUsage.db file in the Library folder.
A tweet highlights the existence of the VulgarWordUsage.db file within the macOS Library folder.helgesver.re

The image shows the specific file path and database name mentioned in the article's discussion of local word tracking.

Because these frameworks are private, there is no official documentation on the specific logic used to determine these classifications. The results of the dump show that some entries appear to be hand-picked rather than rule-based, such as the inclusion of 'Oedipus' in the vulgar tier or 'niggardly' in the offensive tier. This highlights a trade-off where Apple prioritizes a curated experience of 'safe' autocorrect over a purely algorithmic approach, even if it results in some linguistic oddities or subjective classifications of common names and terms. The system's ultimate goal is to ensure that if a user types a vulgar word, the keyboard only suggests it if the user has established a pattern of using it in that specific context."