LAL: Linear Arrangement Library 21.07.01
A library focused on algorithms on linear arrangements of graphs.
Loading...
Searching...
No Matches
treebank_feature.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_view>
46
47// lal includes
48#include <lal/io/treebank_feature.hpp>
49
50namespace lal {
51namespace internal {
52
58inline constexpr std::string_view
59treebank_feature_string(const io::treebank_feature& tf) noexcept {
61
62 switch (tf) {
63 case treebank_feature::num_nodes: return "n";
64 case treebank_feature::second_moment_degree: return "second_moment_degree";
65 case treebank_feature::second_moment_degree_in: return "second_moment_degree_in";
66 case treebank_feature::second_moment_degree_out: return "second_moment_degree_out";
67 case treebank_feature::third_moment_degree: return "third_moment_degree";
68 case treebank_feature::third_moment_degree_in: return "third_moment_degree_in";
69 case treebank_feature::third_moment_degree_out: return "third_moment_degree_out";
70 case treebank_feature::num_pairs_independent_edges: return "num_pairs_independent_edges";
71 case treebank_feature::head_initial: return "head_initial";
72 case treebank_feature::hubiness: return "hubiness";
73 case treebank_feature::mean_hierarchical_distance: return "mean_hierarchical_distance";
74 case treebank_feature::tree_centre: return "tree_centre";
75 case treebank_feature::tree_centroid: return "tree_centroid";
76 case treebank_feature::tree_diameter: return "tree_diameter";
77 case treebank_feature::num_crossings: return "num_crossings";
78 case treebank_feature::predicted_num_crossings: return "predicted_num_crossings";
79 case treebank_feature::exp_num_crossings: return "exp_num_crossings";
80 case treebank_feature::var_num_crossings: return "var_num_crossings";
81 case treebank_feature::z_score_num_crossings: return "z_score_num_crossings";
82 case treebank_feature::sum_edge_lengths: return "sum_edge_lengths";
83 case treebank_feature::exp_sum_edge_lengths: return "exp_sum_edge_lengths";
84 case treebank_feature::exp_sum_edge_lengths_projective: return "exp_sum_edge_lengths_projective";
85 case treebank_feature::exp_sum_edge_lengths_planar: return "exp_sum_edge_lengths_planar";
86 case treebank_feature::var_sum_edge_lengths: return "var_sum_edge_lengths";
87 case treebank_feature::z_score_sum_edge_lengths: return "z_score_sum_edge_lengths";
88 case treebank_feature::min_sum_edge_lengths: return "min_sum_edge_lengths";
89 case treebank_feature::min_sum_edge_lengths_planar: return "min_sum_edge_lengths_planar";
90 case treebank_feature::min_sum_edge_lengths_projective: return "min_sum_edge_lengths_projective";
91 case treebank_feature::mean_dependency_distance: return "mean_dependency_distance";
92 case treebank_feature::flux_max_weight: return "flux_max_weight";
93 case treebank_feature::flux_mean_weight: return "flux_mean_weight";
94 case treebank_feature::flux_min_weight: return "flux_min_weight";
95 case treebank_feature::flux_max_left_span: return "flux_max_left_span";
96 case treebank_feature::flux_mean_left_span: return "flux_mean_left_span";
97 case treebank_feature::flux_min_left_span: return "flux_min_left_span";
98 case treebank_feature::flux_max_right_span: return "flux_max_right_span";
99 case treebank_feature::flux_mean_right_span: return "flux_mean_right_span";
100 case treebank_feature::flux_min_right_span: return "flux_min_right_span";
101 case treebank_feature::flux_max_RL_ratio: return "flux_max_RL_ratio";
102 case treebank_feature::flux_mean_RL_ratio: return "flux_mean_RL_ratio";
103 case treebank_feature::flux_min_RL_ratio: return "flux_min_RL_ratio";
104 case treebank_feature::flux_max_WS_ratio: return "flux_max_WS_ratio";
105 case treebank_feature::flux_mean_WS_ratio: return "flux_mean_WS_ratio";
106 case treebank_feature::flux_min_WS_ratio: return "flux_min_WS_ratio";
107 case treebank_feature::flux_max_size: return "flux_max_size";
108 case treebank_feature::flux_mean_size: return "flux_mean_size";
109 case treebank_feature::flux_min_size: return "flux_min_size";
110 case treebank_feature::tree_type: return "tree_type";
111 case treebank_feature::syntactic_dependency_structure_class:
112 return "syntactic_dependency_structure_class";
113 case treebank_feature::__last_value: return "__last_value";
114 }
115 // should never happen
116 return "???";
117}
118
119// return the index of the treebank feature
120inline constexpr
121std::size_t treebank_feature_to_index(const io::treebank_feature& tf) noexcept {
122 return static_cast<std::size_t>(tf);
123}
124
125// return the treebank feature corresponding to the index
126inline constexpr
127io::treebank_feature index_to_treebank_feature(std::size_t idx) noexcept {
128 return static_cast<io::treebank_feature>(idx);
129}
130
131} // -- namespace internal
132} // -- namespace lal
treebank_feature
The features that can be computed in automatic processing of treebanks.
Definition treebank_feature.hpp:60
Main namespace of the library.
Definition definitions.hpp:48