1.0.2 • Published 2 months ago

free-emoji-text-parser v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

emoji-text-parser

Parses text to replace keywords with corresponding emojis, enhancing the readability and engagement of your content.

Installation

To install the library, run:

npm install emoji-text-parser

Usage

After installation, you can use the library in your project like so:

const EmojiTextParser = require('emoji-text-parser');

const parser = new EmojiTextParser();
const text = "I love pizza and dogs";
const emojiText = parser.enhanceText(text);

console.log(emojiText); // Output: I love 🍕 and 🐶

Features

  • Keyword to Emoji Conversion: Automatically replaces keywords in your text with corresponding emojis.
  • Plural Support: Recognizes both singular and plural forms of keywords.
  • Sentiment Analysis: Optionally appends an emoji based on the overall sentiment of the input text.

API

buildEmojiMap()

Builds the internal mapping of keywords to emojis. This is called automatically upon initialization.

replaceWithEmojis(text)

Replaces keywords in the given text with emojis.

  • text: The input text to process.

Returns the processed text with emojis.

enhanceText(text)

Performs sentiment analysis on the input text and appends a relevant emoji at the end, in addition to replacing keywords with emojis throughout the text.

  • text: The input text to enhance.

Returns the enhanced text.

Contributing

Contributions are welcome! Please submit a pull request or create an issue for any feature requests or bug reports.

License

This project is licensed under the ISC License.