/usr/include/hfst/implementations/XfsmTransducer.h is in libhfst42-dev 3.9.0~r4595-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _XFSM_TRANSDUCER_H_
#define _XFSM_TRANSDUCER_H_
#include "HfstSymbolDefs.h"
#include "HfstExceptionDefs.h"
#include "HfstExtractStrings.h"
#include "HfstFlagDiacritics.h"
#include <stdlib.h>
#ifndef _XFSMLIB_H_
#define _XFSMLIB_H_
#include "xfsm/xfsm_api.h"
#endif
#include <cstdio>
#include <string>
#include <sstream>
#include <iostream>
#include "../FormatSpecifiers.h"
/** @file XfsmTransducer.h
\brief Declarations of functions and datatypes that form a bridge between
HFST API and xfsm. */
namespace hfst {
namespace implementations
{
/* A class for reading XFSM binary transducers from a file. */
class XfsmInputStream
{
private:
/* The name of the file where transducers will be read from. */
std::string filename;
/* A list of transducers that will return transducers one by one when
read_transducer() is called. */
NVptr net_list;
/* The size of net_list. */
int list_size;
/* The position of the transducer that read_transducer() will return. */
int list_pos;
public:
/* Throws an error. */
XfsmInputStream(void);
/* A stream that will read transducers from file \a filename. */
XfsmInputStream(const std::string &filename);
/* Frees the memory allocated for this XfsmInputStream. */
void close(void);
/* Whether there are any transducers left in net_list. */
bool is_eof(void);
/* Whether the stream is bad for reading, always false. */
bool is_bad(void);
/* Whether the stream is good for reading, always true. */
bool is_good(void);
/* Whether the next item returned by read_transducer() is a valid
XFSM transducer. Basically always true, except if is_eof() is true. */
bool is_fst(void);
/* Delayed read, returns a transducer from net_list. */
NETptr read_transducer();
};
/* A class for writing XFSM transducers in binary format to a file. */
class XfsmOutputStream
{
private:
/* The name of the file where transducers will be written. */
std::string filename;
/* A list of transducers to be written when flush() is called. */
NVptr net_list;
public:
/* Throws an error. */
XfsmOutputStream(void);
/* A stream that will write transducers into file \a filename. */
XfsmOutputStream(const std::string &filename);
/* Writes the contents of net_list into file filename. */
void flush();
/* Does nothing. */
void close();
/* Delayed write, stores a copy of \a transducer in net_list. */
void write_transducer(NETptr transducer);
};
class XfsmTransducer {
private:
static bool minimize_even_if_already_minimal_;
public:
static void initialize_xfsm();
static NETptr create_xfsm_unknown_to_unknown_transducer();
static NETptr create_xfsm_identity_to_identity_transducer();
static id_type hfst_symbol_to_xfsm_symbol(const std::string & symbol);
static std::string xfsm_symbol_to_hfst_symbol(id_type id);
static void label_id_to_symbol_pair(id_type label_id, std::string & isymbol, std::string & osymbol);
static id_type symbol_pair_to_label_id(const std::string & isymbol, const std::string & osymbol);
static NETptr create_empty_transducer(void);
static NETptr create_epsilon_transducer(void);
static NETptr define_transducer(const hfst::StringPairVector &spv);
static NETptr define_transducer
(const hfst::StringPairSet &sps, bool cyclic=false);
static NETptr define_transducer(const std::vector<StringPairSet> &spsv);
static NETptr define_transducer
(const std::string &symbol);
static NETptr define_transducer
(const std::string &isymbol, const std::string &osymbol);
static NETptr copy(NETptr t);
static NETptr minimize(NETptr t);
static NETptr compose(NETptr t1, const NETptr t2);
static NETptr concatenate(NETptr t1, const NETptr t2);
static NETptr disjunct(NETptr t1, const NETptr t2);
static NETptr intersect(NETptr t1, const NETptr t2);
static NETptr subtract(NETptr t1, const NETptr t2);
static bool are_equivalent(NETptr t1, NETptr t2);
static bool is_cyclic(NETptr t);
static unsigned int number_of_states(NETptr t);
static unsigned int number_of_arcs(NETptr t);
static NETptr eliminate_flags_xfsm(NETptr t);
static NETptr eliminate_flag_xfsm(NETptr t, const std::string & flag);
static NETptr repeat_star(NETptr t);
static NETptr repeat_plus(NETptr t);
static NETptr repeat_n(NETptr t, unsigned int n);
static NETptr repeat_le_n(NETptr t, unsigned int n);
static NETptr repeat_n_plus(NETptr t, unsigned int n);
static NETptr repeat_n_to_k(NETptr t, unsigned int n, unsigned int k);
static NETptr optionalize(NETptr t);
static NETptr invert(NETptr t);
static NETptr reverse(NETptr t);
static NETptr extract_input_language(NETptr t);
static NETptr extract_output_language(NETptr t);
static NETptr insert_freely(NETptr t, const NETptr ins);
static StringSet get_alphabet(const NETptr t);
static void add_symbol_to_alphabet(NETptr t, const std::string & symbol);
static void add_symbols_to_alphabet(NETptr t, const StringSet & symbols);
static void remove_symbols_from_alphabet(NETptr t, const StringSet & symbols);
// for debugging
static void set_minimize_even_if_already_minimal(bool value);
static void set_compose_flag_as_special(bool value);
static void write_in_att_format(NETptr t, const char * filename);
static void write_in_prolog_format(NETptr t, const char * filename);
static NETptr prolog_file_to_xfsm_transducer(const char * filename);
} ;
} }
#endif
|