diff --git a/libcorpus2/token.h b/libcorpus2/token.h index 5cd4f61e3e3af089a6c04c2dd8c970710e143df0..4da41e326f66b1eb8b2aa1990c65bb78f8d785f1 100644 --- a/libcorpus2/token.h +++ b/libcorpus2/token.h @@ -90,6 +90,11 @@ public: void set_wa(const PwrNlp::Whitespace::Enum& wa) { wa_ = wa; } + + /// If any whitespace came before this token. + bool after_space() const { + return wa_ != PwrNlp::Whitespace::None; + } /// Lexemes getter const std::vector<Lexeme>& lexemes() const { diff --git a/swig/token.i b/swig/token.i index 0c8373f6edea713c9a1da0d12a571663ab814b5c..7e5cb2f0447906878401421236c57ff9302444fc 100644 --- a/swig/token.i +++ b/swig/token.i @@ -37,6 +37,7 @@ namespace Corpus2 { const PwrNlp::Whitespace::Enum& wa() const; void set_wa(const PwrNlp::Whitespace::Enum& wa); + bool after_space() const; const std::vector<Lexeme>& lexemes() const; std::vector<Lexeme>& lexemes();