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...
|
|
|
size_t | MemSize () const noexcept |
| Returns the amount of memory explicitly allocated by the class. More...
|
|
|
constexpr | AhoCorasick () noexcept |
| Instantiates the object with default parameters (default constructor).
|
|
| ~AhoCorasick () noexcept |
| Destructor.
|
|
AhoCorasick & | assign (AhoCorasick &rhs, move_tag) |
| Corresponds to a move assignment operator.
|
|
| AhoCorasick (AhoCorasick &rhs, move_tag) |
| Corresponds to a move constructor.
|
|
| AhoCorasick (AhoCorasick &&rhs) |
| Instantiates the object (move constructor).
|
|
AhoCorasick & | operator= (AhoCorasick &&rhs) |
| Move assignment operator.
|
|
void | Reset () noexcept |
| Resets this object to the state immediately after the default constructor was executed.
|
|
|
void | Match (const char *doc, MatchCallback callback, void *user_obj) noexcept |
| Inspects the string to detect the target string. More...
|
|
void | Match (const char *doc, MatchCallback callback) noexcept |
| A parameter omitted version of the above function.
|
|
void | Match (const void *data, size_t n, MatchCallback callback, void *user_obj) noexcept |
| Inspects the data to detect the target pattern. More...
|
|
void | Match (const void *data, size_t n, MatchCallback callback) noexcept |
| A parameter omitted version of the above function.
|
|
|
bool | Export (BinaryWriter *w) const noexcept |
| Writes the object to the file. More...
|
|
bool | Import (BinaryReader *r) noexcept |
| Reads the written object. 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 41 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 * |
user_obj |
|
) |
| |
|
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] | user_obj | Pointer to the user-specified object. |
Definition at line 43 of file AhoCorasick.h.
◆ Match() [2/2]
nn::nlib::succinct::AhoCorasick::Match |
( |
const void * |
data, |
|
|
size_t |
n, |
|
|
MatchCallback |
callback, |
|
|
void * |
user_obj |
|
) |
| |
|
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] | user_obj | Pointer to the user-specified object. |
◆ MemSize()
nn::nlib::succinct::AhoCorasick::MemSize |
( |
| ) |
const |
|
noexcept |
Returns the amount of memory explicitly allocated by the class.
- Returns
- Returns the number of bytes.
- 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.
The documentation for this class was generated from the following files: