Skip to content

MentionExtractor is a Kotlin library designed to parse text and extract mentions following customizable patterns. It offers flexibility in configuring the pattern. Whether you're building a chatbot, social media analytics tool, or content moderation system.

License

Notifications You must be signed in to change notification settings

brenoepics/MentionExtractor

Repository files navigation

MentionExtractor

Maven Central Coverage Quality Gate Status

A Kotlin library for extracting mentions from a text based on specified patterns. It provides flexible configuration options for handling mentions in a text.

Usage

Arcturus Morningstar

Plugin Download

Custom

To use the MentionExtractor library:

  1. Create a MentionPattern instance and configure it according to your requirements.

  2. Use the MentionExtractor.Builder to construct an instance of MentionExtractor, providing the configured MentionPattern and any additional settings such as the maximum number of mentions to handle.

  3. Use the methods provided by MentionExtractor to extract mentions from text, check if a text contains a mention, or count the number of mentions in a text.

Here's an example of how to use MentionExtractor:

// Configure MentionPattern
val mentionPattern = MentionPattern().withSpecialChars()

// Create MentionExtractor instance
val extractor = MentionExtractor.Builder()
    .pattern(mentionPattern)
    .maxMentions(5)
    .build()

// Extract mentions from text
val text = "Hey @user1, did you see @user2's message?"
val mentions = extractor.fromString(text)

// Check if text contains a mention
val containsMention = extractor.containsMention(text)

// Count the number of mentions in text
val mentionCount = extractor.countMentions(text)

Download / Installation

The recommended way to get MentionExtractor is to use a build manager, like Gradle or Maven.

Maven-central Dependency

Gradle
implementation group: 'io.github.brenoepics', name: 'MentionExtractor', version: '1.0.0'
Maven
<dependency>
    <groupId>io.github.brenoepics</groupId>
    <artifactId>MentionExtractor</artifactId>
    <version>1.0.0</version>
</dependency>
Sbt
libraryDependencies += "io.github.brenoepics" % "MentionExtractor" % "1.0.0"

Testing

We use JUnit 5 for testing the MentionExtractor. To run the tests:

  1. Ensure you have Maven installed on your system.

  2. Navigate to the root directory of the project containing the pom.xml file.

  3. Run the following Maven command:

    mvn test

This will execute the JUnit tests defined in the test package and provide the test results.

License

This project is licensed under the Apache 2.0 License—see the LICENSE file for details.

About

MentionExtractor is a Kotlin library designed to parse text and extract mentions following customizable patterns. It offers flexibility in configuring the pattern. Whether you're building a chatbot, social media analytics tool, or content moderation system.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages