
eu.crydee.ahocorasick.AhoCorasickHelpers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aho-corasick Show documentation
Show all versions of aho-corasick Show documentation
Aho-Corasick search with generic alphabets
The newest version!
package eu.crydee.ahocorasick;
import com.google.common.collect.SetMultimap;
import java.util.AbstractMap;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;
public class AhoCorasickHelpers {
public static SortedSet toOccurrenceList(
SetMultimap searchResult,
List patterns,
boolean isPatternToPos) {
return searchResult.entries().stream()
.map(e -> isPatternToPos
? new AbstractMap.SimpleEntry<>(
e.getValue(),
e.getKey())
: e)
.map(e -> new Occurrence(
e.getKey()
- patterns.get(e.getValue()).length
+ 1,
e.getKey(),
e.getValue()))
.collect(Collectors.toCollection(() -> new TreeSet<>()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy