Class that checks whether text contains the predefined set of words.
More...
#include "nn/nlib/succinct/WordFilter.h"
|
typedef bool(* | MatchCallback) (const char *first, const char *last, uint32_t nodeid, void *user_obj) |
| The callback that is called when the pattern is matched. More...
|
|
|
bool | Init () noexcept |
| Initializes an object. More...
|
|
void | Match (const char *doc, MatchCallback callback, void *user_obj) noexcept |
| Inspects the string to detect the registered string. More...
|
|
void | Match (const char *data, size_t n, MatchCallback callback, void *user_obj) noexcept |
| Inspects the data to detect the target pattern. More...
|
|
void | Reset () noexcept |
| Returns the object to the state immediately after the constructor is called.
|
|
|
bool | Export (BinaryWriter *w) const noexcept |
| Writes the object to the file. More...
|
|
bool | Import (BinaryReader *r) noexcept |
| Reads the written object. More...
|
|
Class that checks whether text contains the predefined set of words.
- Description
- This class is similar to the
AhoCorasick
class, but the callback is not made if the matched term is part of the specified excluded terms.
- When a specified term is found, the
MatchCallback
function is called. The callback is not called when the matched term is part or whole of a predefined excluded term.
- Consider the behavior when you are matching the pattern "abc" but "zabc" is an excluded term.
-
"abcd" matches "abc" so the callback is called.
-
"zabcd" matches "abc" but "zabc" is an excluded term, so the callback is not called even though it matches the pattern.
Definition at line 16 of file WordFilter.h.
§ MatchCallback
nn::nlib::succinct::WordFilter::MatchCallback |
The callback that is called when the pattern is matched.
- Parameters
-
[in] | first | Pointer to the start of the matched pattern. |
[in] | last | Pointer to the end of the matched pattern. |
[in] | nodeid | The ID of the matched pattern. |
[in] | user_obj | Pointer to the user-specified object. |
Definition at line 18 of file WordFilter.h.
§ Export()
nn::nlib::succinct::WordFilter::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.
§ Init()
nn::nlib::succinct::WordFilter::Init |
( |
| ) |
|
|
noexcept |
Initializes an object.
- Returns
- Returns
true
when successful.
§ Match() [1/2]
nn::nlib::succinct::WordFilter::Match |
( |
const char * |
doc, |
|
|
MatchCallback |
callback, |
|
|
void * |
user_obj |
|
) |
| |
|
inlinenoexcept |
Inspects the string to detect the registered 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 38 of file WordFilter.h.
§ Match() [2/2]
nn::nlib::succinct::WordFilter::Match |
( |
const char * |
data, |
|
|
size_t |
n, |
|
|
MatchCallback |
callback, |
|
|
void * |
user_obj |
|
) |
| |
|
noexcept |
Inspects the data to detect the target pattern.
- Parameters
-
[in] | data | Pointer to the head of the data to be inspected. |
[in] | n | Data size. |
[in] | callback | Callback function called when the pattern is detected. |
[in,out] | user_obj | Pointer to the user-specified object. |
The documentation for this class was generated from the following files: