https://github.com/m8524769/sensitive-word-converter
An asynchronous sensitive word converter/validator based on DFA.
https://github.com/m8524769/sensitive-word-converter
dfa npm-package sensitive-word typescript
Last synced: 9 months ago
JSON representation
An asynchronous sensitive word converter/validator based on DFA.
- Host: GitHub
- URL: https://github.com/m8524769/sensitive-word-converter
- Owner: m8524769
- License: isc
- Created: 2019-03-26T16:13:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T17:21:43.000Z (over 3 years ago)
- Last Synced: 2025-08-31T14:55:28.564Z (10 months ago)
- Topics: dfa, npm-package, sensitive-word, typescript
- Language: TypeScript
- Homepage:
- Size: 171 KB
- Stars: 5
- Watchers: 0
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sensitive Word Converter
An asynchronous sensitive word converter/validator based on DFA.
[](https://travis-ci.com/m8524769/sensitive-word-converter)
[](https://www.npmjs.com/package/sensitive-word-converter)
[](https://www.npmjs.com/package/sensitive-word-converter)
### Getting Started
```shell
$ npm i sensitive-word-converter
```
### Usage
```typescript
import { Converter } from 'sensitive-word-converter';
// At least one text file containing sensitive words is required
const converter = new Converter( // Local file paths or URLs
'./sensitiveWords.txt',
'https://raw.githubusercontent.com/observerss/textfilter/master/keywords',
// ...
);
converter.isReady.then(() => {
// Sensitive word: He, World
let s0 = converter.convert('Hello World');
console.log(s0); // **llo *****
// Sensitive word: 你好骚啊
let s1 = converter.convert('你好骚啊!');
console.log(s1); // ****!
// Sensitive word: 哈
let s2 = converter.convert('哈哈哈哈啪!', '喵');
console.log(s2); // 喵喵喵喵啪!
// String validation
let r0 = converter.validate('Hello World');
console.log(r0); // { pass: false, sensitiveWords: Set { 'He', 'World' } }
}).catch(e => {
console.error(e);
// Handle error
})
```
### Sensitive Words Example
- [fwwdn/sensitive-stop-words](https://github.com/fwwdn/sensitive-stop-words)
- [observerss/textfilter](https://github.com/observerss/textfilter)
- [57ing/Sensitive-word](https://github.com/57ing/Sensitive-word)
- [qloog/sensitive_words](https://github.com/qloog/sensitive_words)
- [jim19930609/Twitter-Sensitive-Word-Detection](https://github.com/jim19930609/Twitter-Sensitive-Word-Detection)
### Todo List
- [X] String validation
- [ ] Random substitute symbol
- [ ] Craw word list with Python
- [X] Construct the Converter with fileURL
- [ ] Ignore special symbols in strings
- [X] Add support for multi-file word lists
- [ ] Set timeout for each request
### For Developers/Testers
```shell
$ git clone --depth=1 https://github.com/m8524769/sensitive-word-converter.git
$ cd ./sensitive-word-converter
$ npm i --only=dev
$ npm run build
$ npm test
```
### [ISC License](LICENSE)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fm8524769%2Fsensitive-word-converter?ref=badge_small)