Frog
mbma_rule.h
Go to the documentation of this file.
1 /* ex: set tabstop=8 expandtab: */
2 /*
3  Copyright (c) 2006 - 2020
4  CLST - Radboud University
5  ILK - Tilburg University
6 
7  This file is part of frog:
8 
9  A Tagger-Lemmatizer-Morphological-Analyzer-Dependency-Parser for
10  several languages
11 
12  frog is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 3 of the License, or
15  (at your option) any later version.
16 
17  frog is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program. If not, see <http://www.gnu.org/licenses/>.
24 
25  For questions and suggestions, see:
26  https://github.com/LanguageMachines/frog/issues
27  or send mail to:
28  lamasoftware (at ) science.ru.nl
29 
30 */
31 
32 #ifndef MBMA_RULE_H
33 #define MBMA_RULE_H
34 
35 #include <map>
36 #include <vector>
37 #include <string>
38 #include "unicode/unistr.h"
39 #include "ticcutils/LogStream.h"
40 #include "frog/clex.h"
41 
42 namespace Compound {
43  enum Type : int;
44 }
45 
46 class RulePart {
47 public:
48  RulePart( const std::string&, const UChar, bool );
49  bool isBasic() const;
50  void get_edits( const std::string& );
52  std::vector<CLEX::Type> RightHand;
53  icu::UnicodeString ins;
54  icu::UnicodeString del;
55  icu::UnicodeString hide;
56  icu::UnicodeString uchar;
57  icu::UnicodeString morpheme;
58  std::string inflect;
59  bool is_affix;
60  bool is_glue;
62 };
63 
64 std::ostream& operator<<( std::ostream& os, const RulePart& );
65 std::ostream& operator<<( std::ostream& os, const RulePart * );
66 
67 class BracketNest;
68 
69 class Rule {
70 public:
71  Rule( const std::vector<std::string>&,
72  const icu::UnicodeString&,
73  TiCC::LogStream&,
74  TiCC::LogStream&,
75  int );
76  ~Rule();
77  std::vector<std::string> extract_morphemes() const;
78  std::string morpheme_string( bool = false ) const;
79  std::string pretty_string() const;
80  icu::UnicodeString getKey( bool );
81  bool performEdits();
82  void getCleanInflect();
83  void reduceZeroNodes();
84  void resolveBrackets( bool );
85  void resolve_inflections();
86  std::vector<RulePart> rules;
87  int debugFlag;
89  icu::UnicodeString sortkey;
90  icu::UnicodeString orig_word;
91  std::string description;
92  std::string inflection;
95  TiCC::LogStream& myLog;
96  TiCC::LogStream& dbgLog;
97  double confidence;
98 };
99 
100 std::ostream& operator<<( std::ostream& os, const Rule& );
101 std::ostream& operator<<( std::ostream& os, const Rule * );
102 
103 #endif // MBMA_RULE_H
Rule::~Rule
~Rule()
Definition: mbma_rule.cxx:259
RulePart::ins
icu::UnicodeString ins
Definition: mbma_rule.h:53
Rule::getKey
icu::UnicodeString getKey(bool)
Definition: mbma_rule.cxx:499
Rule::inflection
std::string inflection
Definition: mbma_rule.h:92
Rule
Definition: mbma_rule.h:69
RulePart::uchar
icu::UnicodeString uchar
Definition: mbma_rule.h:56
Rule::brackets
BracketNest * brackets
Definition: mbma_rule.h:94
Rule::description
std::string description
Definition: mbma_rule.h:91
RulePart::del
icu::UnicodeString del
Definition: mbma_rule.h:54
Rule::myLog
TiCC::LogStream & myLog
Definition: mbma_rule.h:95
Rule::morpheme_string
std::string morpheme_string(bool=false) const
Definition: mbma_rule.cxx:314
Rule::compound
Compound::Type compound
Definition: mbma_rule.h:93
Rule::getCleanInflect
void getCleanInflect()
Definition: mbma_rule.cxx:521
Rule::Rule
Rule(const std::vector< std::string > &, const icu::UnicodeString &, TiCC::LogStream &, TiCC::LogStream &, int)
Definition: mbma_rule.cxx:238
Rule::reduceZeroNodes
void reduceZeroNodes()
Definition: mbma_rule.cxx:287
RulePart::hide
icu::UnicodeString hide
Definition: mbma_rule.h:55
clex.h
Rule::extract_morphemes
std::vector< std::string > extract_morphemes() const
Definition: mbma_rule.cxx:302
Rule::performEdits
bool performEdits()
Definition: mbma_rule.cxx:334
CLEX::Type
Type
all possible CELEX tags and action properties
Definition: clex.h:41
RulePart::is_affix
bool is_affix
Definition: mbma_rule.h:59
RulePart::get_edits
void get_edits(const std::string &)
Definition: mbma_rule.cxx:100
Rule::dbgLog
TiCC::LogStream & dbgLog
Definition: mbma_rule.h:96
RulePart
Definition: mbma_rule.h:46
Compound
Definition: mbma_brackets.h:55
RulePart::inflect
std::string inflect
Definition: mbma_rule.h:58
Rule::resolveBrackets
void resolveBrackets(bool)
Definition: mbma_rule.cxx:569
Rule::orig_word
icu::UnicodeString orig_word
Definition: mbma_rule.h:90
RulePart::RightHand
std::vector< CLEX::Type > RightHand
Definition: mbma_rule.h:52
Rule::pretty_string
std::string pretty_string() const
Definition: mbma_rule.cxx:329
RulePart::ResultClass
CLEX::Type ResultClass
Definition: mbma_rule.h:51
RulePart::is_participle
bool is_participle
Definition: mbma_rule.h:61
Rule::sortkey
icu::UnicodeString sortkey
Definition: mbma_rule.h:89
RulePart::morpheme
icu::UnicodeString morpheme
Definition: mbma_rule.h:57
RulePart::isBasic
bool isBasic() const
Definition: mbma_rule.cxx:50
RulePart::is_glue
bool is_glue
Definition: mbma_rule.h:60
Rule::confidence
double confidence
Definition: mbma_rule.h:97
BracketNest
Definition: mbma_brackets.h:161
Rule::rules
std::vector< RulePart > rules
Definition: mbma_rule.h:86
operator<<
std::ostream & operator<<(std::ostream &os, const RulePart &)
Definition: mbma_rule.cxx:54
Compound::Type
Type
Definition: mbma_brackets.h:56
RulePart::RulePart
RulePart(const std::string &, const UChar, bool)
Definition: mbma_rule.cxx:122
Rule::tag
CLEX::Type tag
Definition: mbma_rule.h:88
Rule::resolve_inflections
void resolve_inflections()
Definition: mbma_rule.cxx:437
Rule::debugFlag
int debugFlag
Definition: mbma_rule.h:87