LAL: Linear Arrangement Library 23.01.00
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 - 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 <cstdint>
46#if defined DEBUG
47#include <cassert>
48#endif
49#ifdef SWIG
50#include <string>
51#else
52#include <string_view>
53#endif
54
55namespace lal {
56namespace io {
57
68enum class treebank_feature {
69 // STRUCTURAL PROPERTIES
70
97
122
144 hubiness,
195
196 // C
197
229
230 // D
231
308
309 // FLUXES
310
338
366
394
422
450
478
479 // TYPES OF TREES
480
490 tree_type,
491
504
505 /*
506 * @brief The last value of the enumeration.
507 *
508 * <b>This is used for internal purposes only.</b> Do not use this feature.
509 */
510 __last_value
511};
512
520inline constexpr
522 static_cast<std::size_t>(treebank_feature::__last_value);
523
529inline constexpr
530#ifdef SWIG
531std::string
532#else
533std::string_view
534#endif
536noexcept
537{
538 switch (tf) {
539 case treebank_feature::num_nodes: return "n";
540 case treebank_feature::second_moment_degree: return "second_moment_degree";
541 case treebank_feature::second_moment_degree_out: return "second_moment_degree_out";
542 case treebank_feature::third_moment_degree: return "third_moment_degree";
543 case treebank_feature::third_moment_degree_out: return "third_moment_degree_out";
544 case treebank_feature::sum_squared_degrees: return "sum_squared_degrees";
545 case treebank_feature::sum_squared_out_degrees: return "sum_squared_out_degrees";
546 case treebank_feature::sum_cubed_degrees: return "sum_cubed_degrees";
547 case treebank_feature::sum_cubed_out_degrees: return "sum_cubed_out_degrees";
548 case treebank_feature::num_pairs_independent_edges: return "num_pairs_independent_edges";
549 case treebank_feature::head_initial: return "head_initial";
550 case treebank_feature::hubiness: return "hubiness";
551 case treebank_feature::sum_hierarchical_distances: return "sum_hierarchical_distance";
552 case treebank_feature::mean_hierarchical_distance: return "mean_hierarchical_distance";
553 case treebank_feature::tree_centre: return "tree_centre";
554 case treebank_feature::tree_centroid: return "tree_centroid";
555 case treebank_feature::tree_diameter: return "tree_diameter";
556 case treebank_feature::tree_caterpillar_distance: return "caterpillar_distance";
557 case treebank_feature::num_crossings: return "num_crossings";
558 case treebank_feature::predicted_num_crossings: return "predicted_num_crossings";
559 case treebank_feature::exp_num_crossings: return "exp_num_crossings";
560 case treebank_feature::var_num_crossings: return "var_num_crossings";
561 case treebank_feature::z_score_num_crossings: return "z_score_num_crossings";
562 case treebank_feature::sum_edge_lengths: return "sum_edge_lengths";
563 case treebank_feature::exp_sum_edge_lengths: return "exp_sum_edge_lengths";
564 case treebank_feature::exp_sum_edge_lengths_projective: return "exp_sum_edge_lengths_projective";
565 case treebank_feature::exp_sum_edge_lengths_planar: return "exp_sum_edge_lengths_planar";
566 case treebank_feature::var_sum_edge_lengths: return "var_sum_edge_lengths";
567 case treebank_feature::z_score_sum_edge_lengths: return "z_score_sum_edge_lengths";
568 case treebank_feature::min_sum_edge_lengths: return "min_sum_edge_lengths";
569 case treebank_feature::min_sum_edge_lengths_planar: return "min_sum_edge_lengths_planar";
570 case treebank_feature::min_sum_edge_lengths_projective: return "min_sum_edge_lengths_projective";
571 case treebank_feature::max_sum_edge_lengths_planar: return "max_sum_edge_lengths_planar";
572 case treebank_feature::max_sum_edge_lengths_projective: return "max_sum_edge_lengths_projective";
573 case treebank_feature::mean_dependency_distance: return "mean_dependency_distance";
574 case treebank_feature::flux_max_weight: return "flux_max_weight";
575 case treebank_feature::flux_mean_weight: return "flux_mean_weight";
576 case treebank_feature::flux_min_weight: return "flux_min_weight";
577 case treebank_feature::flux_max_left_span: return "flux_max_left_span";
578 case treebank_feature::flux_mean_left_span: return "flux_mean_left_span";
579 case treebank_feature::flux_min_left_span: return "flux_min_left_span";
580 case treebank_feature::flux_max_right_span: return "flux_max_right_span";
581 case treebank_feature::flux_mean_right_span: return "flux_mean_right_span";
582 case treebank_feature::flux_min_right_span: return "flux_min_right_span";
583 case treebank_feature::flux_max_RL_ratio: return "flux_max_RL_ratio";
584 case treebank_feature::flux_mean_RL_ratio: return "flux_mean_RL_ratio";
585 case treebank_feature::flux_min_RL_ratio: return "flux_min_RL_ratio";
586 case treebank_feature::flux_max_WS_ratio: return "flux_max_WS_ratio";
587 case treebank_feature::flux_mean_WS_ratio: return "flux_mean_WS_ratio";
588 case treebank_feature::flux_min_WS_ratio: return "flux_min_WS_ratio";
589 case treebank_feature::flux_max_size: return "flux_max_size";
590 case treebank_feature::flux_mean_size: return "flux_mean_size";
591 case treebank_feature::flux_min_size: return "flux_min_size";
592 case treebank_feature::tree_type: return "tree_type";
594 return "syntactic_dependency_structure_class";
595 case treebank_feature::__last_value: return "__last_value";
596 }
597 // should never happen
598 return "???";
599}
600
602inline constexpr
603std::size_t treebank_feature_to_index(const io::treebank_feature& tf) noexcept {
604 return static_cast<std::size_t>(tf);
605}
606
608inline constexpr
610#if defined DEBUG
611 assert(idx < treebank_feature_to_index(treebank_feature::__last_value));
612#endif
613 return static_cast<io::treebank_feature>(idx);
614}
615
617inline constexpr
618#ifdef SWIG
619std::string
620#else
621std::string_view
622#endif
623treebank_feature_index_to_string(std::size_t idx) noexcept {
625}
626
627} // -- namespace io
628} // -- namespace lal
constexpr std::string_view treebank_feature_string(const io::treebank_feature &tf) noexcept
Converts a lal::io::treebank_feature value into a string.
Definition: treebank_feature.hpp:535
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
@ exp_num_crossings
First moment of expectation of , .
@ flux_min_size
Minimum flux size.
@ tree_centroid
Centroid of the tree.
@ z_score_num_crossings
z-score of , .
@ second_moment_degree_out
Second moment of out-degree .
@ num_nodes
Number of nodes of the tree.
@ flux_mean_right_span
Mean right span.
@ mean_hierarchical_distance
Mean hierarchical distance of the tree.
@ third_moment_degree
Third moment of degree .
@ min_sum_edge_lengths_projective
Minimum sum of length of edges under the planary constraint.
@ flux_mean_RL_ratio
Mean R/L ratio.
@ flux_max_size
Maximum flux size.
@ head_initial
Headedness of the tree.
@ flux_mean_WS_ratio
Mean W/S ratio.
@ predicted_num_crossings
Prediction of the number of crossings .
@ max_sum_edge_lengths_planar
Maximum sum of length of edges under the planary constraint.
@ sum_cubed_out_degrees
Sum of cube out-degrees.
@ hubiness
Hubiness of the tree.
@ flux_mean_weight
Mean flux weight.
@ flux_min_left_span
Minimum left span.
@ flux_min_RL_ratio
Minimum R/L ratio.
@ flux_mean_size
Mean flux size.
@ third_moment_degree_out
Third moment of out-degree .
@ sum_edge_lengths
Sum of length of edges .
@ flux_max_WS_ratio
Maximum W/S ratio.
@ mean_dependency_distance
Mean dependency distance of the tree.
@ max_sum_edge_lengths_projective
Maximum sum of length of edges under the planary constraint.
@ flux_min_right_span
Minimum right span.
@ num_crossings
Number of edge crossings .
@ flux_max_left_span
Maximum left span.
@ sum_squared_degrees
Sum of squared degrees.
@ var_num_crossings
Variance of , .
@ syntactic_dependency_structure_class
The type of syntactic dependency structure.
@ flux_max_RL_ratio
Maximum R/L ratio.
@ flux_max_right_span
Maximum right span.
@ sum_cubed_degrees
Sum of cube degrees.
@ second_moment_degree
Second moment of degree .
@ tree_centre
Centre of the tree.
@ min_sum_edge_lengths_planar
Minimum sum of length of edges under the planary constraint.
@ num_pairs_independent_edges
Size of the set of this tree .
@ z_score_sum_edge_lengths
z-score of , .
@ exp_sum_edge_lengths_planar
Expectation of constrained to planar arrangements, .
@ exp_sum_edge_lengths
Expectation of , .
@ var_sum_edge_lengths
Variance of , .
@ tree_caterpillar_distance
Caterpillar distance of the tree.
@ exp_sum_edge_lengths_projective
Expectation of constrained to projective arrangements, .
@ flux_max_weight
Maximum flux weight.
@ tree_type
The type of tree.
@ min_sum_edge_lengths
Unconstrained minimum sum of length of edges.
@ sum_squared_out_degrees
Sum of squared out-degrees.
@ sum_hierarchical_distances
Sum of hierarchical distances of the tree.
@ flux_mean_left_span
Mean left span.
@ flux_min_WS_ratio
Minimum W/S ratio.
@ tree_diameter
Diameter of the tree.
@ flux_min_weight
Minimum flux weight.
constexpr io::treebank_feature index_to_treebank_feature(std::size_t idx) noexcept
Returns the treebank feature corresponding to the input index.
Definition: treebank_feature.hpp:609
constexpr std::size_t treebank_feature_to_index(const io::treebank_feature &tf) noexcept
Returns the index of the input treebank feature.
Definition: treebank_feature.hpp:603
Main namespace of the library.
Definition: basic_types.hpp:50