zhixiangli / keyword-search

Implemented with Aho-Corasick Automaton, with an Example of Mobile Detect.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

keyword-search

Keyword Search is implemented with Aho-Corasick Automaton, with a case of mobile detect.

Time Complexity: O(n), faster than other algorithms, such as indexOf().

Environmental Requirements

JDK 1.8+

Instructions

Add Dependency

<dependency>
	<groupId>com.zhixiangli</groupId>
	<artifactId>keyword-search</artifactId>
	<version>0.0.1</version>
</dependency>

Example

KeywordSearch keywordSearch = new KeywordSearch();
// [must] add all keyword at one time.
keywordSearch.addAll(new String[] {"a", "bc", "def"});
System.out.println(keywordSearch.contains("bef")); // false
System.out.println(keywordSearch.contains("bobcome")); // true

About

Implemented with Aho-Corasick Automaton, with an Example of Mobile Detect.


Languages

Language:Java 100.0%