LAL: Linear Arrangement Library 21.07.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
treebank_processor.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#if defined DEBUG
46#include <cassert>
47#endif
48#include <vector>
49#include <string>
50
51// lal includes
52#include <lal/io/treebank_error.hpp>
53#include <lal/io/process_treebank_base.hpp>
54
55namespace lal {
56namespace io {
57
103public:
104 // PROCESS THE TREEBANK collection
105
116 const std::string& treebank_input_file,
117 const std::string& output_file,
118 const std::string& treebank_id = ""
119 )
120 noexcept;
121
140
141private:
143 template<class TREE, class OUT_STREAM>
145 (const TREE& rT, double *props, char *prop_set, OUT_STREAM& out_lab_file)
146 const noexcept;
147
148 // HEADER
149
151 template<class OUT_STREAM>
153 (OUT_STREAM& out_lab_file)
154 const noexcept;
155
157 template<class OUT_STREAM>
159 (OUT_STREAM& out_lab_file)
160 const noexcept;
161
162 // VALUES
163
165 template<class TREE_TYPE, class OUT_STREAM>
167 (TREE_TYPE& t, OUT_STREAM& out_lab_file)
168 const noexcept;
169
171 template<class TREE_TYPE, class OUT_STREAM>
173 (const TREE_TYPE& t, OUT_STREAM& out_lab_file)
174 const noexcept;
175
176private:
178 std::string m_treebank_filename = "none";
180 std::string m_output_file = "none";
182 std::string m_treebank_id = "";
183};
184
196inline
198 const std::string& treebank_file,
199 const std::string& output_file
200)
201noexcept
202{
203 treebank_processor tbproc;
204 auto err = tbproc.init(treebank_file, output_file);
205 if (err.get_error_type() != treebank_error_type::no_error) {
206 return err;
207 }
208 return tbproc.process();
209}
210
211} // -- namespace io
212} // -- namespace lal
The processor base class.
Definition process_treebank_base.hpp:60
Treebank error report class.
Definition treebank_error.hpp:64
Automatic processing of treebank files.
Definition treebank_processor.hpp:102
std::string m_treebank_filename
File containing the list of languages and their treebanks.
Definition treebank_processor.hpp:178
std::string m_treebank_id
Treebank identifier.
Definition treebank_processor.hpp:182
void output_syndepstruct_type_values(const TREE_TYPE &t, OUT_STREAM &out_lab_file) const noexcept
Output the values for the syntactic dependency tree types.
void output_tree_type_values(TREE_TYPE &t, OUT_STREAM &out_lab_file) const noexcept
Output the values for the tree types.
void process_tree(const TREE &rT, double *props, char *prop_set, OUT_STREAM &out_lab_file) const noexcept
Process a single tree in a treebank.
treebank_error process() noexcept
Process the treebank file.
void output_tree_type_header(OUT_STREAM &out_lab_file) const noexcept
Output the header for the tree types.
void output_syndepstruct_type_header(OUT_STREAM &out_lab_file) const noexcept
Output the header for the tree types.
treebank_error init(const std::string &treebank_input_file, const std::string &output_file, const std::string &treebank_id="") noexcept
Initialise the processor with a new collection.
std::string m_output_file
Output directory.
Definition treebank_processor.hpp:180
@ no_error
No error occurred.
treebank_error process_treebank(const std::string &treebank_file, const std::string &output_file) noexcept
Automatically process a treebank.
Definition treebank_processor.hpp:197
Main namespace of the library.
Definition definitions.hpp:48