|
void | set_join_files (bool v) noexcept |
| Join the resulting files into a single file.
|
|
void | set_number_threads (size_t n_threads) noexcept |
| Set the number of threads.
|
|
size_t | get_num_errors () const noexcept |
| Returns the number of errors that arised during processing.
|
|
const treebank_error & | get_error_type (size_t i) const noexcept |
| Get the ith error.
|
|
const std::string & | get_error_treebank_filename (size_t i) const noexcept |
| Get the treebank's file name where the ith error happened.
|
|
const std::string & | get_error_treebank_name (size_t i) const noexcept |
| Get the treebank's name for where the ith error happened.
|
|
treebank_error | init (const std::string &main_file, const std::string &output_directory) noexcept |
| Initialise the processor with a new collection.
|
|
treebank_error | process (const std::string &result_filename="") noexcept |
| Process the treebank collection.
|
|
void | add_feature (const treebank_feature &fs) noexcept |
| Adds a feature to the processor.
|
|
void | remove_feature (const treebank_feature &fs) noexcept |
| Removes a feature from the processor.
|
|
void | set_check_before_process (bool v) noexcept |
| Should the treebank file or collection be checked for errors prior to processing?
|
|
void | clear_features () noexcept |
| Clear the features in the processor.
|
|
void | set_separator (char c) noexcept |
| Sets the separator character.
|
|
void | set_verbosity (int k) noexcept |
| Sets the level of verbosity of the process methods.
|
|
void | set_output_header (bool h) noexcept |
| Output a hedaer for the treebank result file.
|
|
bool | has_feature (const treebank_feature &fs) const noexcept |
| Is a given feature to be calculated?
|
|
Automatic processing of treebank collections.
This class, the objects of which will be referred to as the "processors", has the goal to ease the processing a whole treebank collection and produce data for a fixed set of features available in the library. See the enumeration lal::io::treebank_feature for details on the features available.
This class is meant to process a treebank collection only. A treebank collection is a set of treebank files, each containing several syntactic dependency trees of sentences. Each file is referred to as a treebank file. Each of these files is referenced within a "main file list", henceforth called the "main
file". The main file is a two-column formatted file, the first of which contains a self-descriptive name of the treebank that is indicated in the next column.
For example, the main file of a treebank collection of languages could contain:
arb path/to/file/ar-all.heads2
eus path/to/file/eu-all.heads2
ben path/to/file/bn-all.heads2
...
where the first column contains a string referencing the treebank of a language (in this case, by giving an ISO code of a language), and the second column contains the full path to the file with the syntactic dependency trees.
Every processor must be initialised prior to processing the collection. This is done via method init, which requires the path to the main file and the output directory where the results are going to be stored. It also requires a Boolean value indicating whether all (or none) of the features should be used. Moreover, it also admits an optional parameter indicating the number of threads to be used to parallelise the processing of the files.
When initialised, a processor can be removed or added features: when the number of features to calculate is low, it can be initialised with no features, and then be added some via method add_feature. Conversely, if the number of features is high, but not all features are needed, a processer can be initialised with all features, and then be removed some of them via method remove_feature.
Processing a treebank collection with this class will produce a file for every treebank in the collection. These files can be merged together by indicating so via method set_join_files. A new file will be created, regardless of the number of treebanks in the collection.
Finally, the treebank collection is processed via method process. If all the files produced (one for each treebank) are to be joined in a single file, users can give this new file a name by passing it to method process as a string. Also, users can indicate via an optional Boolean parameter whether the individual files are to be removed or not.
Method process returns a value of the enumeration treebank_error. Further errors can be checked via methods get_num_errors, get_error_type, get_error_treebank_filename, get_error_treebank_name.
The usage of this class is a lot simpler than that of class treebank_collection_reader. For example:
tbproc.
init(main_file, output_dir, 4);
void add_feature(const treebank_feature &fs) noexcept
Adds a feature to the processor.
Definition process_treebank_base.hpp:68
Automatic processing of treebank collections.
Definition treebank_collection_processor.hpp:128
treebank_error init(const std::string &main_file, const std::string &output_directory) noexcept
Initialise the processor with a new collection.
treebank_error process(const std::string &result_filename="") noexcept
Process the treebank collection.
@ num_crossings
Number of edge crossings .
@ var_num_crossings
Variance of , .