Skip to content

Commit 42ab843

Browse files
committed
Update README.md
1 parent 6b94753 commit 42ab843

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<div align="center">
22
<h1>Privacy Filter</h1>
33
<p>
4-
<a href="https://github.com/DirectoryTree/PrivacyFilter/actions/workflows/run-tests.yml"><img src="https://github.com/DirectoryTree/PrivacyFilter/actions/workflows/run-tests.yml/badge.svg?branch=master" alt="Tests status"></a>
4+
<a href="https://github.com/DirectoryTree/PrivacyFilter/actions"><img src="https://img.shields.io/github/actions/workflow/status/DirectoryTree/PrivacyFilter/run-tests.yml?branch=master&style=flat-square" alt="Tests status"></a>
5+
<a href="https://packagist.org/packages/directorytree/privacy-filter"><img src="https://img.shields.io/packagist/dt/directorytree/privacy-filter.svg?style=flat-square" alt="Total downloads"></a>
6+
<a href="https://packagist.org/packages/directorytree/privacy-filter"><img src="https://img.shields.io/packagist/v/directorytree/privacy-filter.svg?style=flat-square" alt="Latest version"></a>
7+
<a href="https://packagist.org/packages/directorytree/privacy-filter"><img src="https://img.shields.io/github/license/DirectoryTree/PrivacyFilter?style=flat-square" alt="License"></a>
58
</p>
69
<p>Install and use compiled <a href="https://github.com/DirectoryTree/PrivacyFilterBinaries"><code>privacy-filter.cpp</code></a> binaries from Laravel applications.</p>
710
</div>
@@ -113,6 +116,25 @@ Each entity contains the detected type, original text, byte offsets, and confide
113116
$length = $entity->length();
114117
```
115118

119+
You may use the detected entities to redact personal information from text:
120+
121+
```php
122+
use DirectoryTree\PrivacyFilter\Facades\PrivacyFilter;
123+
124+
$text = 'Contact John Doe at jdoe@example.com or 555-0100.';
125+
126+
$entities = PrivacyFilter::entities($text);
127+
128+
$redacted = str($entities)->reduce(
129+
fn ($text, $entity) => str_replace($entity->text, '[redacted]', $text),
130+
$text,
131+
);
132+
133+
echo $redacted;
134+
135+
// Contact [redacted] at [redacted] or [redacted].
136+
```
137+
116138
## Thresholds
117139

118140
The classifier uses a default threshold of `0.5`. The threshold is the minimum confidence score an entity must meet before it is returned. Increasing the threshold returns fewer, higher-confidence entities, while decreasing it may return more entities with lower confidence.

0 commit comments

Comments
 (0)