The lexicon
The lexicon is the set of word lists the filter checks against. It ships with the package, and you can read it through the Lexicon class:
use NoNepaliProfanity\Lexicon;
array_filter(Lexicon::WORDS, fn ($e) => $e['language'] === 'romanized' && $e['strictness'] === 'standard');Entries
Every entry is an array with three keys:
[
'text' => 'muji', // the word, stem or phrase
'language' => 'romanized', // 'english', 'romanized' or 'devanagari'
'strictness' => 'lenient', // the lowest strictness that turns it on
]Entries are grouped into three lists, and each list is matched differently:
| List | Matched how | Example |
|---|---|---|
Lexicon::WORDS | The whole word, with or without a postposition. | muji catches muji and mujiko, not mujibur. |
Lexicon::STEMS | Any word that starts with the stem. | fuck catches fucking and fucker. |
Lexicon::PHRASES | The words in order, separated by any whitespace. | sasto manche catches sasto manche, not sasto ra manche. |
Two more lists hold the postpositions that are removed before a whole-word check: Lexicon::LATIN_SUFFIXES (ko, lai, haru…) and Lexicon::DEVANAGARI_SUFFIXES (को, लाई, हरू…).
Languages
| Language | Contains |
|---|---|
| English | English profanity and insults. |
| Romanized | Nepali written in Latin letters, and Hindi slang common in Nepal. |
| Devanagari | Anything written in Devanagari. |
Strictness levels
| Strictness | Contains |
|---|---|
| Lenient | Severe profanity, sexual terms and slurs. |
| Standard | Milder insults that some sites allow, like idiot, murkha, sala and sasto manche. |
| Strict | Entries that are offensive but are also ordinary words, like damn and prick, and stems that start ordinary words or names, like rand and cond. The names and words those stems hit most, like Randip and conditions, are on a built-in allow list. |
A filter set to one level uses the entries at that level and every level below it.
What's deliberately left out
- Words that are also common names, or the start of names, unless they're whole words that can't be a name.
- Caste names and surnames. A word list can't tell a slur from someone's name.
- Everyday words that are only insulting in context, like fohor (dirty), lato (mute) or kukur (dog).
To suggest additions or removals, see Contributing.
Flat lists
For convenience, Lexicon also has methods that return every entry in one script, at every strictness, as a list of strings: latinWords(), latinStems(), latinPhrases(), devanagariWords(), devanagariStems() and devanagariPhrases().