ModErn Text Analysis
META Enumerates Textual Applications
porter2_stemmer.h
Go to the documentation of this file.
1 
9 #ifndef META_FILTER_PORTER2_STEMMER_H_
10 #define META_FILTER_PORTER2_STEMMER_H_
11 
12 #include <memory>
13 #include "analyzers/token_stream.h"
14 #include "util/clonable.h"
15 #include "util/optional.h"
16 
17 namespace meta
18 {
19 namespace analyzers
20 {
21 namespace filters
22 {
23 
28 class porter2_stemmer : public util::clonable<token_stream, porter2_stemmer>
29 {
30  public:
36  porter2_stemmer(std::unique_ptr<token_stream> source);
37 
42  porter2_stemmer(const porter2_stemmer& other);
43 
48  void set_content(const std::string& content) override;
49 
53  std::string next() override;
54 
58  operator bool() const override;
59 
61  const static std::string id;
62 
63  private:
67  void next_token();
68 
70  std::unique_ptr<token_stream> source_;
71 
74 };
75 }
76 }
77 }
78 #endif
std::unique_ptr< token_stream > source_
The stream to read tokens from.
Definition: porter2_stemmer.h:70
void next_token()
Finds the next valid token for this filter.
Definition: porter2_stemmer.cpp:43
Filter that stems words according to the porter2 stemmer algorithm.
Definition: porter2_stemmer.h:28
util::optional< std::string > token_
The buffered next token.
Definition: porter2_stemmer.h:73
Template class to facilitate polymorphic cloning.
Definition: clonable.h:28
porter2_stemmer(std::unique_ptr< token_stream > source)
Constructs a new porter2 stemmer filter, reading tokens from the given source.
Definition: porter2_stemmer.cpp:18
The ModErn Text Analysis toolkit is a suite of natural language processing, classification, information retreival, data mining, and other applications of text processing.
Definition: analyzer.h:24
static const std::string id
Identifier for this filter.
Definition: porter2_stemmer.h:61
std::string next() override
Obtains the next token in the sequence.
Definition: porter2_stemmer.cpp:36
void set_content(const std::string &content) override
Sets the content for the beginning of the filter chain.
Definition: porter2_stemmer.cpp:30