LAL: Linear Arrangement Library 24.10.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
treebank_collection_reader.hpp
1/*********************************************************************
2 *
3 * Linear Arrangement Library - A library that implements a collection
4 * algorithms for linear arrangments of graphs.
5 *
6 * Copyright (C) 2019 - 2024
7 *
8 * This file is part of Linear Arrangement Library. The full code is available
9 * at:
10 * https://github.com/LAL-project/linear-arrangement-library.git
11 *
12 * Linear Arrangement Library is free software: you can redistribute it
13 * and/or modify it under the terms of the GNU Affero General Public License
14 * as published by the Free Software Foundation, either version 3 of the
15 * License, or (at your option) any later version.
16 *
17 * Linear Arrangement Library is distributed in the hope that it will be
18 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Affero General Public License for more details.
21 *
22 * You should have received a copy of the GNU Affero General Public License
23 * along with Linear Arrangement Library. If not, see <http://www.gnu.org/licenses/>.
24 *
25 * Contact:
26 *
27 * LluĂ­s Alemany Puig (lluis.alemany.puig@upc.edu)
28 * LQMC (Quantitative, Mathematical, and Computational Linguisitcs)
29 * CQL (Complexity and Quantitative Linguistics Lab)
30 * Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
31 * Webpage: https://cqllab.upc.edu/people/lalemany/
32 *
33 * Ramon Ferrer i Cancho (rferrericancho@cs.upc.edu)
34 * LQMC (Quantitative, Mathematical, and Computational Linguisitcs)
35 * CQL (Complexity and Quantitative Linguistics Lab)
36 * Office 220, Omega building
37 * Jordi Girona St 1-3, Campus Nord UPC, 08034 Barcelona. CATALONIA, SPAIN
38 * Webpage: https://cqllab.upc.edu/people/rferrericancho/
39 *
40 ********************************************************************/
41
42#pragma once
43
44// C++ includes
45#include <string>
46
47// lal includes
48#include <lal/io/treebank_file_error.hpp>
49#include <lal/io/treebank_reader.hpp>
50
51namespace lal {
52namespace io {
53
92public:
93
105 [[nodiscard]] treebank_file_error init(const std::string& main_file) noexcept;
106
109 [[nodiscard]] bool end() const noexcept { return m_reached_end; }
110
116 void next_treebank() noexcept;
117
119 [[nodiscard]] treebank_reader& get_treebank_reader() noexcept
120 { return m_treebank_reader; }
121
122private:
130 std::string m_main_file = "none";
131
133 std::string m_cur_treebank_id = "none";
135 std::string m_cur_treebank_filename = "none";
136
138 std::ifstream m_list;
141
143 bool m_reached_end = false;
146
147private:
149 void step_line() noexcept {
151 // do nothing, there are more trees
152 }
153 else {
154 m_no_more_treebanks = true;
156 }
157 }
158};
159
160} // -- namespace io
161} // -- namespace lal
A reader for a collection of treebanks.
Definition treebank_collection_reader.hpp:91
treebank_reader m_treebank_reader
Object to process a language's treebank.
Definition treebank_collection_reader.hpp:140
treebank_file_error init(const std::string &main_file) noexcept
Initialize the reader with a new collection.
treebank_reader & get_treebank_reader() noexcept
Returns a treebank reader class instance for processing a treebank.
Definition treebank_collection_reader.hpp:119
void step_line() noexcept
Consumes one line of the main file m_main_file.
Definition treebank_collection_reader.hpp:149
bool m_no_more_treebanks
Have all trees in the file been consumed?
Definition treebank_collection_reader.hpp:145
std::ifstream m_list
Handler for main file reading.
Definition treebank_collection_reader.hpp:138
std::string m_cur_treebank_filename
The name of the current treebank file.
Definition treebank_collection_reader.hpp:135
std::string m_main_file
File containing the list of languages and their treebanks.
Definition treebank_collection_reader.hpp:130
bool m_reached_end
Did we reach the end of the file?
Definition treebank_collection_reader.hpp:143
std::string m_cur_treebank_id
The identifier of the current treebank file.
Definition treebank_collection_reader.hpp:133
bool end() const noexcept
Definition treebank_collection_reader.hpp:109
void next_treebank() noexcept
Opens the file of the next treebank in the main file.
Treebank file error report class.
Definition treebank_file_error.hpp:64
A reader for a single treebank file.
Definition treebank_reader.hpp:89
Main namespace of the library.
Definition basic_types.hpp:48