LAL: Linear Arrangement Library 23.01.00
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
process_treebank_base.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 - 2023
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 (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#include <array>
47
48// lal includes
49#include <lal/io/treebank_feature.hpp>
50
51namespace lal {
52namespace io {
53
62public:
63 // MODIFIERS
64
69 void add_feature(const treebank_feature& fs) noexcept
70 { m_what_fs[ static_cast<std::size_t>(fs) ] = true; }
75 void remove_feature(const treebank_feature& fs) noexcept
76 { m_what_fs[ static_cast<std::size_t>(fs) ] = false; }
77
78 // SETTERS
79
81 void set_check_before_process(bool v) noexcept
83
85 void clear_features() noexcept
86 { std::fill(m_what_fs.begin(), m_what_fs.end(), false); }
87
94 void set_separator(char c) noexcept { m_separator = c; }
104 void set_verbosity(int k) noexcept { m_be_verbose = k; }
111 void set_output_header(bool h) noexcept { m_output_header = h; }
112
122 void set_column_name(const treebank_feature& tf, const std::string& name)
123 noexcept
124 {
125 m_column_names[static_cast<std::size_t>(tf)] = name;
126 }
127
128 // GETTERS
129
135 bool has_feature(const treebank_feature& fs) const noexcept
136 { return m_what_fs[ static_cast<std::size_t>(fs) ]; }
137
138protected:
140 std::array<std::string, __treebank_feature_size> m_column_names;
142 std::array<bool, __treebank_feature_size> m_what_fs;
143
147 char m_separator = '\t';
149 bool m_output_header = true;
150
158
159protected:
161 void initialise_column_names() noexcept {
162 for (std::size_t i = 0; i < __treebank_feature_size; ++i) {
164 }
165 }
166};
167
168} // -- namespace io
169} // -- namespace lal
The processor base class.
Definition: process_treebank_base.hpp:61
bool has_feature(const treebank_feature &fs) const noexcept
Is a given feature to be calculated?
Definition: process_treebank_base.hpp:135
void set_output_header(bool h) noexcept
Output a hedaer for the treebank result file.
Definition: process_treebank_base.hpp:111
void set_verbosity(int k) noexcept
Sets the level of verbosity of the process methods.
Definition: process_treebank_base.hpp:104
std::array< std::string, __treebank_feature_size > m_column_names
String for each column.
Definition: process_treebank_base.hpp:140
void set_check_before_process(bool v) noexcept
Should the treebank file or collection be checked for errors prior to processing?
Definition: process_treebank_base.hpp:81
char m_separator
Character used as separator.
Definition: process_treebank_base.hpp:147
void initialise_column_names() noexcept
Initialises column names m_column_names.
Definition: process_treebank_base.hpp:161
void set_separator(char c) noexcept
Sets the separator character.
Definition: process_treebank_base.hpp:94
bool m_check_before_process
Process the treebank file or collection prior to processing.
Definition: process_treebank_base.hpp:145
void set_column_name(const treebank_feature &tf, const std::string &name) noexcept
Sets a custom name for the column corresponding to a given feature.
Definition: process_treebank_base.hpp:122
std::array< bool, __treebank_feature_size > m_what_fs
The list of features to be computed.
Definition: process_treebank_base.hpp:142
void remove_feature(const treebank_feature &fs) noexcept
Removes a feature from the processor.
Definition: process_treebank_base.hpp:75
void clear_features() noexcept
Clear the features in the processor.
Definition: process_treebank_base.hpp:85
bool m_output_header
Output a header for each file.
Definition: process_treebank_base.hpp:149
void add_feature(const treebank_feature &fs) noexcept
Adds a feature to the processor.
Definition: process_treebank_base.hpp:69
int m_be_verbose
The verbosity of the processor.
Definition: process_treebank_base.hpp:157
constexpr std::size_t __treebank_feature_size
The total number of features available.
Definition: treebank_feature.hpp:521
constexpr std::string_view treebank_feature_index_to_string(std::size_t idx) noexcept
Returns the treebank feature corresponding to the index as a string.
Definition: treebank_feature.hpp:623
treebank_feature
The features that can be computed in automatic processing of treebanks.
Definition: treebank_feature.hpp:68
Main namespace of the library.
Definition: basic_types.hpp:50