/usr/include/hfst/parsers/SfstAlphabet.h is in libhfst-dev 3.13.0~r3461-2.
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 | #ifndef _SFST_ALPHABET_H_
#define _SFST_ALPHABET_H_
#if HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef INCLUDE_TR1_UNORDERED_MAP_AND_SET
#include <tr1/unordered_map>
#else
#include <unordered_map>
#endif
#ifdef USE_TR1_UNORDERED_MAP_AND_SET
using std::tr1::unordered_map;
#else
using std::unordered_map;
#endif
#include <set>
#include <vector>
#include <string.h>
#include <stdio.h>
/* @file SfstAlphabet.h
\brief Declaration of class SfstAlphabet. */
namespace hfst {
namespace implementations {
/* copied from SFST's alphabet.h|C */
class SfstAlphabet {
public:
typedef std::pair<unsigned int,unsigned int> NumberPair;
// used to map the codes back to the symbols
typedef unordered_map<unsigned int, char*> CharMap;
private:
// string comparison operators needed ???
struct eqstr {
bool operator()(const char* s1, const char* s2) const {
return strcmp(s1, s2) == 0;
}
};
// used to map the symbols to their codes
typedef unordered_map<const char*, unsigned int> SymbolMap;
// set of symbol pairs
typedef std::set<NumberPair> NumberPairSet;
SymbolMap sm; // maps symbols to codes
CharMap cm; // maps codes to symbols
// The set of string pairs
NumberPairSet pairs;
public:
SfstAlphabet();
SfstAlphabet(const SfstAlphabet &alpha);
~SfstAlphabet();
typedef NumberPairSet::const_iterator const_iterator;
const_iterator begin() const;
const_iterator end() const;
size_t size() const;
//bool contains_special_symbols(StringPair sp);
void print();
void print_pairs(FILE *file);
void insert(NumberPair sp);
void clear_pairs();
CharMap get_char_map();
void add( const char *symbol, unsigned int c );
void add_symbol( const char *symbol, unsigned int c );
int symbol2code( const char * s ) const;
const char *code2symbol( unsigned int c ) const;
unsigned int add_symbol(const char * symbol);
void complement( std::vector<unsigned int> &sym );
std::pair<unsigned int, unsigned int> next_label(char *&, bool extended=true);
int next_code( char* &string, bool extended=true, bool insert=true );
int next_mcsym( char* &string, bool insert=true );
};
}
}
#endif
|