Skip to content

Effective string searching algorithm (Aho-Corasick).

License

Notifications You must be signed in to change notification settings

vanam/string-search

Repository files navigation

StringSearch

License Build Status codecov

Effective string searching algorithm (Aho-Corasick).

Instalation using Gradle

Add repository and dependency to build.gradle file:

...

repositories {
    ...
    maven {
        url = "https://maven.pkg.github.com/vanam/string-search"
        credentials {
            username = project.findProperty("gpr.user")
            password = project.findProperty("gpr.key")
        }
    }
}

dependencies {
    ...
    implementation 'com.martinvana:string-search:1.0.0'
}

...

Read about Github Tokens, generate one, and update your global gradle.properties file located in a project root directory or GRADLE_USER_HOME environment variable.

gpr.user=GITHUB_USERNAME
gpr.key=GITHUB_TOKEN

For more information visit Configuring Gradle for use with GitHub Packages

Usage

// Init algorithm with patterns
StringSearch stringSearch = new StringSearch("foo", "bar");

// Search for patterns in text
Hits hits = stringSearch.search("foo bar in a long text");

// Were matches found?
hits.isEmpty();

// How many matches were found?
hits.size();

// What was found?
Map<String, SortedSet<Integer>> pattern2positionsInTextMap = hits.hits();

Source