ModErn Text Analysis
META Enumerates Textual Applications
|
Filter that either removes or keeps tokens from a given list. More...
#include <list_filter.h>
Public Types | |
enum | type { ACCEPT, REJECT } |
Strongly typed flag to indicate whether the list_filter rejects tokens in the list or only accepts tokens in the list. | |
Public Member Functions | |
list_filter (std::unique_ptr< token_stream > source, const std::string &filename, type method=type::REJECT) | |
Creates a list_filter reading tokens from the given source and filtering based on the tokens specified in the given file. More... | |
list_filter (const list_filter &other) | |
Copy constructor. More... | |
void | set_content (const std::string &content) override |
Sets the content for the beginning of the filter chain. More... | |
std::string | next () override |
operator bool () const override | |
Determines whether there are more tokens available in the stream. | |
Public Member Functions inherited from meta::util::multilevel_clonable< Root, Base, Derived > | |
virtual std::unique_ptr< Root > | clone () const |
Clones the given object. More... | |
Static Public Attributes | |
static const std::string | id = "list" |
Identifier for this filter. | |
Private Member Functions | |
void | next_token () |
Advances internal state to the next valid token. | |
Private Attributes | |
std::unique_ptr< token_stream > | source_ |
The source to read tokens from. | |
util::optional< std::string > | token_ |
The next buffered token. | |
std::unordered_set< std::string > | list_ |
The set of tokens used for filtering. | |
type | method_ |
Whether or not this filter accepts or rejects tokens in the list. | |
Filter that either removes or keeps tokens from a given list.
meta::analyzers::filters::list_filter::list_filter | ( | std::unique_ptr< token_stream > | source, |
const std::string & | filename, | ||
type | method = type::REJECT |
||
) |
Creates a list_filter reading tokens from the given source and filtering based on the tokens specified in the given file.
The method by default is to reject any tokens specified in the file, but it may be optionally set to type::ACCEPT to allow only tokens that appear in that list.
source | The source to construct the filter from |
filename | A file that lists tokens that should either be accepted or rejected |
method | Whether to accept or reject tokens from the list |
meta::analyzers::filters::list_filter::list_filter | ( | const list_filter & | other | ) |
Copy constructor.
other | The list_filter to copy into this one |
|
override |
Sets the content for the beginning of the filter chain.
content | The string content to set |
|
override |