A closed, inclusive interval of Tokens' identifiers, spanning [first, last].
More...
#include <word.hpp>
|
| constexpr std::size_t | count () const noexcept |
| | Number of tokens covered by the range.
|
| constexpr bool | contains (TokenId id) const noexcept |
| | Checks whether a token identifier falls within the range.
|
| constexpr bool | overlaps (Range range) const noexcept |
| | Checks whether this range shares any token identifier with another range.
|
| constexpr bool | equals (Range range) const noexcept |
| | Checks whether this range has the same bounds as another range.
|
| constexpr bool | is_valid () const noexcept |
| | Checks whether the range is well-formed on its own.
|
| constexpr bool | is_valid (TokenId max) const noexcept |
| | Checks whether the range is well-formed and fits within a sentence of a given size.
|
|
|
TokenId | first |
| | Identifier of the first token in the range.
|
|
TokenId | last |
| | Identifier of the last token in the range.
|
A closed, inclusive interval of Tokens' identifiers, spanning [first, last].
◆ contains()
| bool tg::conllu::Word::Range::contains |
( |
TokenId | id | ) |
const |
|
nodiscardconstexprnoexcept |
Checks whether a token identifier falls within the range.
- Parameters
-
| [in] | id | Token identifier to check. |
- Returns
- True if first <= id <= last.
◆ count()
| std::size_t tg::conllu::Word::Range::count |
( |
| ) |
const |
|
nodiscardconstexprnoexcept |
Number of tokens covered by the range.
- Returns
- last - first + 1.
◆ equals()
| bool tg::conllu::Word::Range::equals |
( |
Range | range | ) |
const |
|
nodiscardconstexprnoexcept |
Checks whether this range has the same bounds as another range.
- Parameters
-
| [in] | range | Range to compare against. |
- Returns
- True if both ranges have identical
first and last values.
◆ is_valid() [1/2]
| bool tg::conllu::Word::Range::is_valid |
( |
| ) |
const |
|
nodiscardconstexprnoexcept |
Checks whether the range is well-formed on its own.
- Returns
- True if first < last, first > 0, and the range spans more than one token.
◆ is_valid() [2/2]
| bool tg::conllu::Word::Range::is_valid |
( |
TokenId | max | ) |
const |
|
nodiscardconstexprnoexcept |
Checks whether the range is well-formed and fits within a sentence of a given size.
- Parameters
-
| [in] | max | Highest valid token identifier (typically a sentence's token count). |
- Returns
- True if is_valid() and last <= max.
◆ overlaps()
| bool tg::conllu::Word::Range::overlaps |
( |
Range | range | ) |
const |
|
nodiscardconstexprnoexcept |
Checks whether this range shares any token identifier with another range.
- Parameters
-
| [in] | range | Range to compare against. |
- Returns
- True if the two ranges intersect, including a shared boundary token.
The documentation for this struct was generated from the following file: