MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / addKeyword

Method addKeyword

AhoCorasick.java:15–21  ·  view source on GitHub ↗
(String keyword)

Source from the content-addressed store, hash-verified

13
14 // Step 1: Build the Trie
15 public void addKeyword(String keyword) {
16 TrieNode currentNode = root;
17 for (char c : keyword.toCharArray()) {
18 currentNode = currentNode.children.computeIfAbsent(c, k -> new TrieNode());
19 }
20 currentNode.output.add(keyword);
21 }
22
23 // Step 2: Build Failure Links
24 public void buildFailureLinks() {

Callers 1

mainMethod · 0.95

Calls 1

addMethod · 0.45

Tested by

no test coverage detected