Uses the Aho-Corasick algorithm to detect language and patterns.
More...
#include "nn/nlib/succinct/AhoCorasick.h"
|
typedef bool(* | MatchCallback) (const char *first, const char *last, uint32_t nodeid, void *user_obj) |
| The user-defined callback function is called when the target string is detected. More...
|
|
void | Match (const char *doc, MatchCallback callback, void *userobj) noexcept |
| Inspects the string to detect the target string. More...
|
|
void | Match (const char *doc, MatchCallback callback) noexcept |
| Runs Match(doc, callback, NULL).
|
|
void | Match (const void *data, size_t n, MatchCallback callback, void *userobj) noexcept |
| Inspects the data to detect the target pattern. More...
|
|
void | Match (const void *data, size_t n, MatchCallback callback) noexcept |
| Runs Match(data, n, callback, NULL).
|
|
size_t | MemSize () const noexcept |
| Returns the amount of memory explicitly allocated by the class. More...
|
|
Uses the Aho-Corasick algorithm to detect language and patterns.
- Description
- The automaton used in the Aho-Corasick algorithm is implemented in a compact size in an implementation described in the following link with minor changes.
- The class object is built using
AhoCorasickBuilder::Build
or the AhoCorasick::Import
function.
Definition at line 31 of file AhoCorasick.h.
◆ MatchCallback
nn::nlib::succinct::AhoCorasick::MatchCallback |
The user-defined callback function is called when the target string is detected.
- 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 | Pointer to the user-specified object. |
- 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 AhoCorasick.h.
◆ Export()
nn::nlib::succinct::AhoCorasick::Export |
( |
BinaryWriter * |
w | ) |
const |
|
noexcept |
Writes the object to the file.
- Parameters
-
- Returns
- Returns
true
when successful.
- Description
- The written data can be read and restored using the
Import
function. The data is always written little endian.
◆ Import()
Reads the written object.
- Parameters
-
- Returns
- Returns
true
when import is successful.
◆ Match() [1/2]
nn::nlib::succinct::AhoCorasick::Match |
( |
const char * |
doc, |
|
|
MatchCallback |
callback, |
|
|
void * |
userobj |
|
) |
| |
|
inlinenoexcept |
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] | userobj | Pointer to the user-specified object. |
Definition at line 48 of file AhoCorasick.h.
◆ Match() [2/2]
nn::nlib::succinct::AhoCorasick::Match |
( |
const void * |
data, |
|
|
size_t |
n, |
|
|
MatchCallback |
callback, |
|
|
void * |
userobj |
|
) |
| |
|
noexcept |
Inspects the data to detect the target pattern.
- Parameters
-
[in] | data | The data to draw. |
[in] | n | Data size. |
[in] | callback | Callback function called when the pattern is detected. |
[in,out] | userobj | Pointer to the user-specified object. |
◆ MemSize()
nn::nlib::succinct::AhoCorasick::MemSize |
( |
| ) |
const |
|
noexcept |
Returns the amount of memory explicitly allocated by the class.
- Description
- The actual amount of memory allocated by the system may be larger than the value returned by this function because of alignment and space for heap management.
- Returns
- Returns the number of bytes.
◆ swap()
void nn::nlib::succinct::AhoCorasick::swap |
( |
AhoCorasick & |
rhs | ) |
|
|
inlinenoexcept |
Swaps the contents of an object.
- Deprecated:
- This function will be deleted in a future release.
Definition at line 41 of file AhoCorasick.h.
The documentation for this class was generated from the following files: