LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
Transition.h
Go to the documentation of this file.
1// Copyright 2002-2013 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6// NAUTITIA
7//
8// jys 15-JUL-2002
9//
10// Transition is the main composant of automatons. Actions
11// are performed only during transitions. Automatons evoluate
12// only with transitions.
13// Components of transitions are :
14// o "check" components to determine if transition is "open"
15// o allowed events : to compare the current character
16// class with. (mandatory)
17// o static conditions : to check characters classes
18// before and after current character class and
19// inner automaton return status. (optionnal)
20// o "action" components to determine what to do if transition
21// has been found open.
22// o next state : on the next character class, automaton
23// will be on that state (optionnal)
24// o action : move the pointer on character classes buffer,
25// take a token, flush the token memory, ... (optionnal)
26// o setting : set up flags into tokens data structure
27// o return_status if automaton is an inner one. (optionnal)
28
29#ifndef LIMA_LINGUISTICPROCESSING_FLATTOKENIZER_Transition_H
30#define LIMA_LINGUISTICPROCESSING_FLATTOKENIZER_Transition_H
31
32#include "FlatTokenizerExport.h"
35#include "ReturnStatus.h"
36#include "Text.h"
37#include "Events.h"
38#include "State.h"
39#include "Condition.h"
40
42// #include "linguisticProcessing/core/Tokenizer/ParseMarkup.h"
43
44namespace Lima
45{
46namespace LinguisticProcessing
47{
48namespace FlatTokenizer
49{
50
52{
53public:
87 static const char* SettingNames[];
88
89 explicit Transition(const State* state);
90 virtual ~Transition();
91
92 // for run-time use. Transition does its works.
93 // Returns true if open, false otherwise
94 const State* run(Text& text) const;
95
96 inline const Lima::LimaString nextStateName() const
97 {
98 if (_toState) return (_toState->name());
99 else return Common::Misc::utf8stdstring2limastring("NONE");
100 }
101
102 inline const Condition& conditions() const {return _condition;}
103 inline Condition& conditions() {return _condition;}
104
105 inline const Events& events() const {return _events;}
106 inline Events& events() {return _events;}
107
108// inline const State* toState() const {return _toState;}
109// inline State* toState() {return _toState;}
110
111 inline void setToState(State* state) {_toState = state;}
112
113/* inline const LinguisticAnalysisStructure::TStatus& setting() const {return m_status;}
114 inline LinguisticAnalysisStructure::TStatus& setting() {return m_status;}*/
115 bool setSetting(const LimaString& s);
116
117 inline bool tokenize() const {return m_tokenize;}
118 inline void setTokenize(bool b) {m_tokenize = b;}
119
120 inline bool flush() const {return m_flush;}
121 inline void setFlush(bool f) {m_flush = f;}
122
123 inline const Lima::LimaString& defaultKey() const {return m_defaultKey;}
124 inline void setDefaultKey(const Lima::LimaString& key) {m_defaultKey = key;}
125
126private:
127 Transition(const Transition&);
128 Transition& operator=(const Transition&);
129 void applySettings(Text& text) const;
130
131 const State* m_state;
132 State* _toState;
133 Events _events;
134 Condition _condition; //0 means no conditions
135 bool m_tokenize;
136 bool m_flush;
137 Lima::LimaString m_defaultKey;
138
139// LinguisticAnalysisStructure::TStatus m_status;
140
141 std::vector<Setting> m_settings;
142};
143
144} //namespace FlatTokenizer
145} // namespace LinguisticProcessing
146} // namespace Lima
147
148#endif
#define LIMA_FLATTOKENIZER_EXPORT
const Lima::LimaString & defaultKey() const
Definition Transition.h:123
void setDefaultKey(const Lima::LimaString &key)
Definition Transition.h:124
int run(int aargc, char **aargv)
Definition main.cpp:31
NAUTITIA.
QString LimaString
Definition LimaString.h:33