Skip to content

Commit

Permalink
docs(readme): fix examples reliant on non-alphabetic stripping
Browse files Browse the repository at this point in the history
See #46.
  • Loading branch information
jo3-l committed Jan 5, 2024
1 parent eb3c7ff commit 34d45da
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
## Why Obscenity?

- **Accurate:** Though Obscenity is far from perfect (as with all profanity filters), it makes reducing false positives as simple as possible: adding whitelisted phrases is as easy as adding a new string to an array, and using word boundaries is equally simple.
- **Robust:** Obscenity's transformer-based design allows it to match on variants of phrases other libraries are typically unable to, e.g. `f...u c k`, `fuuuuuuuckkk`, `ʃṳ𝒸𝗄`, `wordsbeforefuckandafter` and so on. There's no need to manually write out all the variants either: just adding the pattern `fuck` will match all of the cases above by default.
- **Robust:** Obscenity's transformer-based design allows it to match on variants of phrases other libraries are typically unable to, e.g. `fuuuuuuuckkk`, `ʃṳ𝒸𝗄`, `wordsbeforefuckandafter` and so on. There's no need to manually write out all the variants either: just adding the pattern `fuck` will match all of the cases above by default.
- **Extensible:** With Obscenity, you aren't locked into anything - removing phrases that you don't agree with from the default set of words is trivial, as is disabling any transformations you don't like (perhaps you feel that leet-speak decoding is too error-prone for you).

## Installation
Expand Down Expand Up @@ -60,7 +60,7 @@ Now, we can use our matcher to search for profanities in the text. Here's two ex
**Check if there are any matches in some text:**

```javascript
if (matcher.hasMatch('f.uck you')) {
if (matcher.hasMatch('fuck you')) {
console.log('The input text contains profanities.');
}
// The input text contains profanities.
Expand All @@ -70,7 +70,7 @@ if (matcher.hasMatch('f.uck you')) {

```javascript
// Pass "true" as the "sorted" parameter so the matches are sorted by their position.
const matches = matcher.getAllMatches('ʃ𝐟ʃὗƈk ỹоứ 𝔟!!!ⁱẗ𝙘ɦ', true);
const matches = matcher.getAllMatches('ʃ𝐟ʃὗƈk ỹоứ 𝔟ⁱẗ𝙘ɦ', true);
for (const match of matches) {
const { phraseMetadata, startIndex, endIndex } =
englishDataset.getPayloadWithPhraseMetadata(match);
Expand All @@ -79,7 +79,7 @@ for (const match of matches) {
);
}
// Match for word fuck found between 0 and 6.
// Match for word bitch found between 12 and 21.
// Match for word bitch found between 12 and 18.
```

**Censoring matched text:**
Expand Down

0 comments on commit 34d45da

Please sign in to comment.