1.1.0 • Published 1 year ago

word-detector v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

word-detector

npm version Build Status

A simple library for detecting specific words in a sentence.

Installation

You can install the package using npm:

npm install word-detector

Or using yarn:

yarn add word-detector

Usage

Here is a simple example of how to use the package:

node

const detectWords = require('word-detector');
const text = "This is a sample text containing some badword1 and badword2.";
const badwords = ["badword1", "badword2"];
const result = detectWords(text, badwords);
console.log(result); // Output: {detected:true, words:["badword1", "badword2"]}

React

import detectWords from "word-detector"
const MyComponent =()=> {
 const text = "This is a sample text containing some badword1 and badword2.";
 const badwords = ["badword1", "badword2"];
 const result = detectWords(text, badwords);
 onsole.log(result); // Output: {detected:true, words:["badword1", "badword2"]}
}
export default MyComponent

API

detectBadWords(text, badwords)

text: string - The text to check for inappropriate words. badwords: array - An array of strings containing the inappropriate words to detect.

Returns:

null if no specified words are found.

Contributing

If you would like to contribute, you are welcome. clone repository and open pull request.

1.1.0

1 year ago

1.0.0

1 year ago