LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
tstatusTransition.cpp
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/************************************************************************
7*
8* File : tstatusTransition.cpp
9* Author : Romaric Besan�n (besanconr@zoe.cea.fr)
10* Created on : Mon Jan 13 2003
11* Copyright : (c) 2002 by CEA
12* Version : $Id$
13*
14*************************************************************************/
15
16#include "tstatusTransition.h"
17
19
20#include <iostream>
21
22using namespace std;
24
25namespace Lima {
26namespace LinguisticProcessing {
27namespace Automaton {
28
29/***********************************************************************/
30// constructors
31/***********************************************************************/
36
38 TransitionUnit(keep),
39 m_status(s)
40{}
41
44 m_status(t.status())
45{
46// copyProperties(t);
47}
48
50
52 if (this != &t) {
53 m_status = t.status();
55 }
56 return *this;
57}
58
59
60std::string TStatusTransition::printValue() const {
61 ostringstream oss;
62 oss << "tsatusT_";
63 switch (m_status.getStatus()) {
64 case T_ALPHA : {
65 oss << "T_alpha";
66 switch (m_status.getAlphaCapital()) {
67 case T_CAPITAL : oss << ";capital" ; break;
68 case T_SMALL : oss << ";small" ; break;
69 case T_CAPITAL_1ST : oss << ";capital_1st" ; break;
70 case T_ACRONYM : oss << ";acronym" ; break;
71 case T_CAPITAL_SMALL : oss << ";capital_small"; break;
72 default : break;
73 }
74 switch (m_status.getAlphaRoman()) { // Roman supersedes Cardinal
75 case T_CARDINAL_ROMAN : oss << ";cardinal_roman"; break;
76 case T_ORDINAL_ROMAN : oss << ";ordinal_roman" ; break;
77 case T_NOT_ROMAN : oss << ";not_roman" ; break;
78 default : break;
79 }
80 if (m_status.isAlphaHyphen()) {
81 oss << ";hyphen";
82 }
83 if (m_status.isAlphaPossessive()) {
84 oss << ";possessive";
85 }
86 break;
87 }
88 case T_NUMERIC : {
89 oss << "T_numeric";
90 switch (m_status.getNumeric()) {
91 case T_INTEGER : oss << ";integer" ; break;
92 case T_COMMA_NUMBER : oss << ";comma_number" ; break;
93 case T_DOT_NUMBER : oss << ";dot_number" ; break;
94 case T_FRACTION : oss << ";fraction" ; break;
95 case T_ORDINAL_INTEGER : oss << ";ordinal_integer"; break;
96 default: break;
97 }
98 break;
99 }
100 case T_ALPHANUMERIC : oss << "T_alphanumeric" ; break;
101 case T_PATTERN : oss << "T_pattern" ; break;
102 case T_WORD_BRK : oss << "T_word_brk" ; break;
103 case T_SENTENCE_BRK : oss << "T_sentence_brk" ; break;
104 case T_PARAGRAPH_BRK : oss << "T_paragraph_brk" ; break;
105 default :
106 if (m_status.defaultKey().isEmpty()) {
107 oss << "T_no_status";
108 }
109 break;
110 }
111 if (!m_status.defaultKey().isEmpty()) {
112 oss << "T_default=" << Common::Misc::limastring2utf8stdstring(m_status.defaultKey());
113 }
114 return oss.str();
115}
116
117/***********************************************************************/
118// operators ==
119/***********************************************************************/
121 if ( (type() == tright.type())
122 && (compareTStatus((static_cast<const TStatusTransition&>(tright).status())))) {
123 return compareProperties(tright);
124 }
125 else {
126 return false;
127 }
128}
129
132 const LinguisticGraphVertex& /*vertex*/,
133 AnalysisContent& /*analysis*/,
136{
137 return (compareTStatus(token->status()));
138}
139
140bool TStatusTransition::compareTStatus(const Lima::LinguisticProcessing::LinguisticAnalysisStructure::TStatus& t) const {
141// #ifdef DEBUG_LP
142// AULOGINIT;
143// LDEBUG << "TStatusTransition::compareTStatus";
144// LDEBUG << " rule status: " << m_status.getStatus() << " ; " << m_status.defaultKey();
145// LDEBUG << " token status: " << t.getStatus() << " ; " << t.defaultKey();
146// #endif
147
148// if (t == 0) { LDEBUG << " FALSE"; return false; }
149 if (t == TStatus()) {
150// #ifdef DEBUG_LP
151// LDEBUG << " " << (t == m_status);
152// #endif
153 return (t == m_status);
154 }
155
156 if (!m_status.defaultKey().isEmpty()
157 && m_status.defaultKey() != Common::Misc::utf8stdstring2limastring("t_fallback") ) {
158// #ifdef DEBUG_LP
159// LDEBUG << " " << ((m_status.defaultKey()==t.defaultKey()) ? "TRUE" : "FALSE");
160// #endif
161 return (m_status.defaultKey()==t.defaultKey());
162 }
163
164 if (m_status.getStatus() != t.getStatus()) {
165// #ifdef DEBUG_LP
166// LDEBUG << " FALSE";
167// #endif
168 return false;
169 }
170 switch(m_status.getStatus()) {
171 case T_ALPHA : {
172 if (m_status.getAlphaCapital() != T_NULL_CAPITAL &&
173 m_status.getAlphaCapital() != t.getAlphaCapital() ) {
174// #ifdef DEBUG_LP
175// LDEBUG << " FALSE";
176// #endif
177 return false;
178 }
179 if (m_status.getAlphaRoman() != T_NULL_ROMAN &&
180 m_status.getAlphaRoman() != m_status.getAlphaRoman() ) {
181// #ifdef DEBUG_LP
182// LDEBUG << " FALSE";
183// #endif
184 return false;
185 }
186 if (m_status.isAlphaHyphen() && (! t.isAlphaHyphen())) {
187// #ifdef DEBUG_LP
188// LDEBUG << " FALSE";
189// #endif
190 return false;
191 }
192 if (m_status.isAlphaPossessive() && (! t.isAlphaPossessive())) {
193// #ifdef DEBUG_LP
194// LDEBUG << " FALSE";
195// #endif
196 return false;
197 }
198 break;
199 }
200 case T_NUMERIC : {
201 if (m_status.getNumeric() != T_NULL_NUM &&
202 m_status.getNumeric() != t.getNumeric() ) {
203// #ifdef DEBUG_LP
204// LDEBUG << " FALSE";
205// #endif
206 return false;
207 }
208 break;
209 }
210 case T_NULL_CAPITAL: {
211 if (m_status.defaultKey() != t.defaultKey()) {
212// #ifdef DEBUG_LP
213// LDEBUG << " FALSE";
214// #endif
215 return false;
216 }
217 break;
218 }
219 default: {
220// #ifdef DEBUG_LP
221// LDEBUG << " TRUE";
222// #endif
223 return true;
224 }
225 }
226// #ifdef DEBUG_LP
227// LDEBUG << " TRUE";
228// #endif
229 return true;
230}
231
232} // namespace end
233} // namespace end
234} // namespace end
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
const LinguisticAnalysisStructure::TStatus & status() const
bool operator==(const TransitionUnit &) const override
bool compare(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &vertex, AnalysisContent &analysis, const LinguisticAnalysisStructure::Token *token, const LinguisticAnalysisStructure::MorphoSyntacticData *data) const override
comparison of the transition with a token : can use the graph and vertex info, associated with genera...
TStatusTransition & operator=(const TStatusTransition &)
bool compareProperties(const TransitionUnit &t) const
An AnalysisData containing a LinguisticGraph with a language and an id.
std::string limastring2utf8stdstring(const Lima::LimaString &phrase, uint32_t size0)
Convert a wide string to a string , in dest up to size bytes.
LimaString utf8stdstring2limastring(const std::string &src)
NAUTITIA.
STL namespace.