LAL: Linear Arrangement Library 21.07.01
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 - 2021
7 *
8 * This file is part of Linear Arrangement Library. To see the full code
9 * visit the webpage:
10 * https://github.com/lluisalemanypuig/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 (lalemany@cs.upc.edu)
28 * LARCA (Laboratory for Relational Algorithmics, Complexity and Learning)
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 * LARCA (Laboratory for Relational Algorithmics, Complexity and Learning)
35 * CQL (Complexity and Quantitative Linguistics Lab)
36 * Office S124, 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_error.hpp>
49#include <lal/io/treebank_reader.hpp>
50
51namespace lal {
52namespace io {
53
139public:
140
152 treebank_error init(const std::string& main_file) noexcept;
153
156 inline bool end() const noexcept { return m_reached_end; }
157
163 void next_treebank() noexcept;
164
167 { return m_treebank_reader; }
168
169private:
177 std::string m_main_file = "none";
178
180 std::string m_cur_treebank_name = "none";
182 std::string m_cur_treebank_filename = "none";
183
185 std::ifstream m_list;
188
190 bool m_reached_end = false;
193
194private:
196 inline void step_line() noexcept {
198 // do nothing, there are more trees
199 }
200 else {
201 m_no_more_treebanks = true;
203 }
204 }
205};
206
207} // -- namespace io
208} // -- namespace lal
A reader for a collection of treebanks.
Definition treebank_collection_reader.hpp:138
treebank_reader m_treebank_reader
Object to process a language's treebank.
Definition treebank_collection_reader.hpp:187
treebank_reader & get_treebank_reader() noexcept
Returns a treebank reader class instance for processing a treebank.
Definition treebank_collection_reader.hpp:166
void step_line() noexcept
Consumes one line of the main file m_main_file.
Definition treebank_collection_reader.hpp:196
bool m_no_more_treebanks
Have all trees in the file been consumed?
Definition treebank_collection_reader.hpp:192
treebank_error init(const std::string &main_file) noexcept
Initialise the reader with a new collection.
std::ifstream m_list
Handler for main file reading.
Definition treebank_collection_reader.hpp:185
std::string m_cur_treebank_name
The name of the current treebank file.
Definition treebank_collection_reader.hpp:180
std::string m_cur_treebank_filename
The name of the current treebank file.
Definition treebank_collection_reader.hpp:182
std::string m_main_file
File containing the list of languages and their treebanks.
Definition treebank_collection_reader.hpp:177
bool m_reached_end
Did we reach the end of the file?
Definition treebank_collection_reader.hpp:190
bool end() const noexcept
Definition treebank_collection_reader.hpp:156
void next_treebank() noexcept
Opens the file of the next treebank in the main file.
Treebank error report class.
Definition treebank_error.hpp:64
A reader for a single treebank file.
Definition treebank_reader.hpp:113
Main namespace of the library.
Definition definitions.hpp:48