Creates the index (automaton) used in the Aho-Corasick algorithm.
More...
#include "nn/nlib/succinct/AhoCorasickBuilder.h"
|
typedef bool(* | MatchCallback) (const char *first, const char *last, uint32_t nodeid, void *user_obj) |
| User-defined callback function. More...
|
|
|
bool | AddWord (const char *str) noexcept |
| Adds a detection target string. More...
|
|
bool | AddPattern (const void *p, size_t n) noexcept |
| Adds detection target data. More...
|
|
bool | AddWords (const char *str, size_t len) noexcept |
| Adds a string from an array containing a set of target strings. The strings must be delimited by newlines (CRLF or LF). More...
|
|
bool | AddWords (const char *str) noexcept |
| Adds a string from an array containing a set of target strings. The strings must be delimited by newlines (CRLF or LF). More...
|
|
AhoCorasick * | Build () noexcept |
| Creates an Aho-Corasick object. Constructs an Aho-Corasick algorithm automaton to detect the added string or pattern. More...
|
|
void | MatchByBuilder (const char *doc, MatchCallback callback, void *user_obj) noexcept |
| Inspects the string to detect the target string. More...
|
|
size_t | GetNumWords () const noexcept |
| Gets the number of registered strings or patterns. More...
|
|
size_t | GetNumBytes () const noexcept |
| Gets the sum size of registered strings or patterns in bytes. More...
|
|
size_t | GetNumNodes () const noexcept |
| Gets the number of created automaton nodes. More...
|
|
|
| AhoCorasickBuilder () noexcept |
| Instantiates the object with default parameters (default constructor).
|
|
| ~AhoCorasickBuilder () noexcept |
| Destructor.
|
|
bool | Init () noexcept |
| Initializes an object. Returns true if successful.
|
|
Creates the index (automaton) used in the Aho-Corasick algorithm.
- Description
- Add target strings or patterns using methods such as
AddWord
, and then create the Aho-Corasick object using the Build
function. The user must delete
the created Aho-Corasick object.
Definition at line 33 of file AhoCorasickBuilder.h.
◆ MatchCallback
nn::nlib::succinct::AhoCorasickBuilder::MatchCallback |
User-defined callback function.
- Parameters
-
[in] | first | Pointer to the head of the extracted terms. |
[in] | last | Pointer to the tail of the extracted terms. |
[in] | nodeid | The ID of the detected term (not a continuous value). |
[in,out] | user_obj | User data. |
- Returns
- Continues analysis if
true
. Ends the process when false
.
- Description
- Called when the string (pattern) is detected. Developers will write a process to handle each.
Definition at line 46 of file AhoCorasickBuilder.h.
◆ AddPattern()
nn::nlib::succinct::AhoCorasickBuilder::AddPattern |
( |
const void * |
p, |
|
|
size_t |
n |
|
) |
| |
|
noexcept |
Adds detection target data.
- Parameters
-
[in] | p | Pointer to data. |
[in] | n | Data size. |
- Returns
- Returns
true
when successful.
◆ AddWord()
nn::nlib::succinct::AhoCorasickBuilder::AddWord |
( |
const char * |
str | ) |
|
|
noexcept |
Adds a detection target string.
- Parameters
-
- Returns
- Returns
true
when successful.
◆ AddWords() [1/2]
nn::nlib::succinct::AhoCorasickBuilder::AddWords |
( |
const char * |
str, |
|
|
size_t |
len |
|
) |
| |
|
noexcept |
Adds a string from an array containing a set of target strings. The strings must be delimited by newlines (CRLF or LF).
- Parameters
-
[in] | str | Pointer to the string. |
[in] | len | The length of the string. (The strlen value.) |
- Returns
- Returns
true
when successful.
◆ AddWords() [2/2]
nn::nlib::succinct::AhoCorasickBuilder::AddWords |
( |
const char * |
str | ) |
|
|
inlinenoexcept |
Adds a string from an array containing a set of target strings. The strings must be delimited by newlines (CRLF or LF).
- Parameters
-
[in] | str | Pointer to the string. |
- Returns
- Returns
true
when successful.
Definition at line 42 of file AhoCorasickBuilder.h.
◆ Build()
nn::nlib::succinct::AhoCorasickBuilder::Build |
( |
| ) |
|
|
noexcept |
Creates an Aho-Corasick object. Constructs an Aho-Corasick algorithm automaton to detect the added string or pattern.
- Returns
- Pointer to the Aho-Corasick object.
◆ GetNumBytes()
nn::nlib::succinct::AhoCorasickBuilder::GetNumBytes |
( |
| ) |
const |
|
noexcept |
Gets the sum size of registered strings or patterns in bytes.
- Returns
- Returns the size of registered strings or patterns.
◆ GetNumNodes()
nn::nlib::succinct::AhoCorasickBuilder::GetNumNodes |
( |
| ) |
const |
|
noexcept |
Gets the number of created automaton nodes.
- Returns
- Returns the number of created automaton nodes.
◆ GetNumWords()
nn::nlib::succinct::AhoCorasickBuilder::GetNumWords |
( |
| ) |
const |
|
noexcept |
Gets the number of registered strings or patterns.
- Returns
- Returns the number of registered strings or patterns.
◆ MatchByBuilder()
nn::nlib::succinct::AhoCorasickBuilder::MatchByBuilder |
( |
const char * |
doc, |
|
|
MatchCallback |
callback, |
|
|
void * |
user_obj |
|
) |
| |
|
noexcept |
Inspects the string to detect the target string.
- Parameters
-
[in] | doc | String that terminates at null. |
[in] | callback | Callback function called when the term is detected. |
[in,out] | user_obj | User data. |
The documentation for this class was generated from the following files: