HFST - Helsinki Finite-State Transducer Technology - C++ API  version 3.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HfstLookupFlagDiacritics.h
1 // Copyright (c) 2016 University of Helsinki
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 3 of the License, or (at your option) any later version.
7 // See the file COPYING included with this distribution for more
8 // information.
9 
10 #ifndef _LOOKUP_FLAG_DIACRITICS_H_
11 #define _LOOKUP_FLAG_DIACRITICS_H_
12 #include <set>
13 #include <map>
14 #include <string>
15 #include <cassert>
16 #include <vector>
17 #include <iostream>
18 #ifdef DEBUG
19 #include <iostream>
20 #endif
21 
22 enum DiacriticOperator
23  {
24  Pop, Nop, Dop, Rop, Cop, Uop
25  };
26 
27 typedef std::map<std::string,DiacriticOperator> DiacriticOperators;
28 typedef std::map<std::string,std::string> DiacriticFeatures;
29 typedef std::map<std::string,std::string> DiacriticValues;
30 typedef std::map<std::string,bool> DiacriticSettingMap;
31 typedef std::map<std::string,std::string> FeatureValues;
32 typedef std::map<std::string,bool> FeaturePolarities;
33 typedef std::vector<std::string> StringVector;
34 class FlagDiacriticTable
35 {
36  static DiacriticOperators diacritic_operators;
37  static DiacriticFeatures diacritic_features;
38  static DiacriticValues diacritic_values;
39  FeatureValues feature_values;
40  FeaturePolarities feature_polarities;
41  static DiacriticSettingMap diacritic_has_value;
42  bool error_flag;
43  static bool is_genuine_diacritic(const std::string &diacritic_string);
44  static void split_diacritic(const std::string &diacritic_string);
45  void set_positive_value(std::string &feature,
46  std::string &value);
47  void set_negative_value(std::string &feature,
48  std::string &value);
49  void disallow(std::string &feature,
50  std::string &value);
51  void disallow(std::string &feature);
52  void require(std::string &feature,
53  std::string &value);
54  void require(std::string &feature);
55  void unify(std::string &feature,
56  std::string &value);
57  void clear(std::string &feature);
58 
59  public:
60  FlagDiacriticTable(void);
61  /*static void define_diacritic(short diacritic_number,
62  const std::string &diacritic_string);
63  void insert_number(short key_number);*/
64  void insert_symbol(const std::string &symbol);
65  void reset(void);
66  bool fails(void);
67  static bool is_diacritic(const std::string &symbol);
68  bool is_valid_string(const StringVector & input_string);
69  StringVector filter_diacritics(const StringVector & input_string);
70 #ifdef DEBUG
71  static void display(short diacritic);
72 #endif
73 };
74 
75 #endif
std::vector< std::string > StringVector
A vector of strings.
Definition: HfstDataTypes.h:87