nlib
nn::nlib::succinct::WordFilter Class Referencefinal

Class that checks whether text contains the predefined set of words. More...

#include "nn/nlib/succinct/WordFilter.h"

Public Types

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...
 

Public Member Functions

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.
 
Importing and Exporting
bool Export (BinaryWriter *w) const noexcept
 Writes the object to the file. More...
 
bool Import (BinaryReader *r) noexcept
 Reads the written object. More...
 

Basic Member Functions

 WordFilter () noexcept
 Instantiates the object.
 
 ~WordFilter () noexcept
 Destructor.
 
 WordFilter (WordFilter &rhs, move_tag) noexcept
 Instantiates the object by using swap for a move.
 
WordFilterassign (WordFilter &rhs, move_tag) noexcept
 Assigns the object by using swap for a move.
 
 WordFilter (WordFilter &&rhs) noexcept
 Instantiates the object (move constructor). This function is useful when using C++11.
 
void swap (WordFilter &rhs) noexcept
 Swaps the contents of an object.
 

Detailed Description

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.

Member Typedef Documentation

§ MatchCallback

nn::nlib::succinct::WordFilter::MatchCallback

The callback that is called when the pattern is matched.

Parameters
[in]firstPointer to the start of the matched pattern.
[in]lastPointer to the end of the matched pattern.
[in]nodeidThe ID of the matched pattern.
[in]user_objPointer to the user-specified object.

Definition at line 18 of file WordFilter.h.

Member Function Documentation

§ Export()

nn::nlib::succinct::WordFilter::Export ( BinaryWriter w) const
noexcept

Writes the object to the file.

Parameters
[in]wWrite out object.
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()

nn::nlib::succinct::WordFilter::Import ( BinaryReader r)
noexcept

Reads the written object.

Parameters
[in]rRead out object.
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]docString that terminates at null.
[in]callbackCallback function called when the term is detected.
[in,out]user_objPointer 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]dataPointer to the head of the data to be inspected.
[in]nData size.
[in]callbackCallback function called when the pattern is detected.
[in,out]user_objPointer to the user-specified object.

The documentation for this class was generated from the following files: