LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
andTransition.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 : andTransition.cpp
9* Author : Romaric Besan�n (besanconr@zoe.cea.fr)
10* Created on : Fri Sept 12 2003
11* Copyright : (c) 2002 by CEA
12* Version : $Id$
13*
14*************************************************************************/
15
16
17#include "andTransition.h"
19#include <iostream>
20#include <sstream>
21
22using namespace std;
24
25namespace Lima {
26namespace LinguisticProcessing {
27namespace Automaton {
28
29/***********************************************************************/
30// constructors
31/***********************************************************************/
33
34// CAREFUL: this constructor copies the vector directly, ie copies the
35// pointers and not the object : handle with care
36AndTransition::AndTransition(const std::vector<TransitionUnit*>& transitions,
37 bool keep):
38 TransitionUnit(keep),
39 m_transitions(transitions)
40{
41}
42
43
46 m_transitions()
47{
48 copy(t);
49}
50
51/***********************************************************************/
52// destructor
53/***********************************************************************/
57
58/***********************************************************************/
59// copy
60/***********************************************************************/
62 if (this != &t) {
63 clean();
64 copy(t);
66 }
67 return *this;
68}
69
70//helper functions for copy constructor and assignment operator
71void AndTransition::clean() {
72 // clean pointers
73 for (uint64_t i(0); i<m_transitions.size(); i++) {
74 delete m_transitions[i];
75 }
76 m_transitions.clear();
77}
78
79void AndTransition::copy(const AndTransition& t) {
80 //copy values, not pointers
81 for (uint64_t i(0); i<t.m_transitions.size(); i++) {
82 m_transitions.push_back(t.m_transitions[i]->clone());
83 }
84}
85
86std::string AndTransition::printValue() const {
87 ostringstream oss;
88 oss << "andT:";
89 if (m_transitions.empty()) {
90 return oss.str();
91 }
92 oss << m_transitions[0];
93 for (uint64_t i(1); i<m_transitions.size(); i++) {
94 oss << ";" << m_transitions[i];
95 }
96 return oss.str();
97}
98
99
100/***********************************************************************/
101// comparison tests
102/***********************************************************************/
104 if (tright.type() == type()) {
105 const AndTransition& other=static_cast<const AndTransition&>(tright);
106 if (m_transitions.size() != other.m_transitions.size()) {
107 return false;
108 }
109 for (uint64_t i(0); i<m_transitions.size(); i++) {
110 if (! (m_transitions[i] == other.m_transitions[i]) ) {
111 return false;
112 }
113 }
114 return compareProperties(tright);
115 }
116 else {
117 return false;
118 }
119}
120
121// for andTransition, test the AND on same vertex
122// !!!!!!!!!! limitations : cannot prevent that matches on different parts
123// !!!!!!!!!! of and transition is on different alternatives of the vertex
124// !!!!!!!!!! (orthographic alternatives or different categories...)
127 const LinguisticGraphVertex& vertex,
128 AnalysisContent& analysis,
131{
132 for (uint64_t i(0); i<m_transitions.size(); i++) {
133 if (! m_transitions[i]->compare(graph,vertex,analysis,token,data)) {
134 return false;
135 }
136 }
137
138 return true;
139}
140
141} // namespace end
142} // namespace end
143} // namespace end
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
bool operator==(const TransitionUnit &) const override
AndTransition & operator=(const AndTransition &)
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...
␈rief A class for the description of automata
Definition automaton.h:87
bool compareProperties(const TransitionUnit &t) const
An AnalysisData containing a LinguisticGraph with a language and an id.
NAUTITIA.
STL namespace.