CoNLL-U
Loading...
Searching...
No Matches
tg::conllu::Parser Class Referencefinal

Parses CoNLL-U formatted input into a Treebank. More...

#include <parser.hpp>

Public Member Functions

Constructors
constexpr Parser () noexcept=default
 Default constructor. Initializes a parser with default options.
constexpr Parser (ParserOptions options) noexcept
 Constructs a parser with the given options.
Parsing
std::expected< std::unique_ptr< Treebank >, std::error_code > parse (std::istream &&stream) noexcept
 Parses a CoNLL-U formatted stream into a new Treebank.
std::expected< std::unique_ptr< Treebank >, std::error_code > parse_file (const std::filesystem::path &path) noexcept
 Opens the file at path and parses its contents as CoNLL-U formatted text into a new Treebank.
std::expected< std::unique_ptr< Treebank >, std::error_code > parse_memory (std::string_view data) noexcept
 Parses CoNLL-U formatted text already held in memory into a new Treebank.
template<typename DataType>
requires (sizeof(DataType) == sizeof(std::uint8_t))
std::expected< std::unique_ptr< Treebank >, std::error_code > parse_memory (const DataType *data, std::size_t size) noexcept
 Parses CoNLL-U formatted text from a raw byte buffer into a new Treebank.
Destructor
constexpr ~Parser () noexcept=default
 Destructor.

Detailed Description

Parses CoNLL-U formatted input into a Treebank.

Constructor & Destructor Documentation

◆ Parser()

tg::conllu::Parser::Parser ( ParserOptions options)
explicitconstexprnoexcept

Constructs a parser with the given options.

Parameters
[in]optionsParsing configuration to use.

Member Function Documentation

◆ parse()

std::expected< std::unique_ptr< Treebank >, std::error_code > tg::conllu::Parser::parse ( std::istream && stream)
nodiscardnoexcept

Parses a CoNLL-U formatted stream into a new Treebank.

Parameters
[in]streamInput stream to read from.
Returns
The parsed treebank, or an error_code describing the first failure encountered.

◆ parse_file()

std::expected< std::unique_ptr< Treebank >, std::error_code > tg::conllu::Parser::parse_file ( const std::filesystem::path & path)
nodiscardnoexcept

Opens the file at path and parses its contents as CoNLL-U formatted text into a new Treebank.

Parameters
[in]pathPath to the CoNLL-U file to read.
Returns
The parsed treebank, or an error_code describing why the file could not be opened/read or why parsing failed.

◆ parse_memory() [1/2]

template<typename DataType>
requires (sizeof(DataType) == sizeof(std::uint8_t))
std::expected< std::unique_ptr< Treebank >, std::error_code > tg::conllu::Parser::parse_memory ( const DataType * data,
std::size_t size )
nodiscardnoexcept

Parses CoNLL-U formatted text from a raw byte buffer into a new Treebank.

Template Parameters
DataTypeElement type of data; must be exactly one byte wide.
Parameters
[in]dataPointer to the start of the buffer to parse.
[in]sizeNumber of elements (bytes) pointed to by data.
Returns
The parsed treebank, or an error_code describing the first failure encountered.

◆ parse_memory() [2/2]

std::expected< std::unique_ptr< Treebank >, std::error_code > tg::conllu::Parser::parse_memory ( std::string_view data)
nodiscardnoexcept

Parses CoNLL-U formatted text already held in memory into a new Treebank.

Parameters
[in]dataCoNLL-U formatted text to parse.
Returns
The parsed treebank, or an error_code describing the first failure encountered.

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