LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
setTransition.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 : setTransition.cpp
9* Author : Romaric Besan�n (besanconr@zoe.cea.fr)
10* Created on : Fri Sept 19 2003
11* Copyright : (c) 2003 by CEA
12*
13*************************************************************************/
14
15
16#include "setTransition.h"
17#include <iostream>
18#include <sstream>
19
20using namespace std;
22
23namespace Lima
24{
25namespace LinguisticProcessing
26{
27namespace Automaton
28{
29
30/***********************************************************************/
31// constructors
32/***********************************************************************/
37
38SetTransition::SetTransition(const std::set<Tword>& words,
39 bool keep):
40 TransitionUnit(keep),
41 m_words(words)
42{}
43
46 m_words()
47{
48 copy(t);
49}
50
51/***********************************************************************/
52// destructor
53/***********************************************************************/
55{
56 clean();
57}
58
59/***********************************************************************/
60// copy
61/***********************************************************************/
63{
64 if (this != &t)
65 {
66 clean();
67 copy(t);
69 }
70 return *this;
71}
72
73//helper functions for copy constructor and assignment operator
74void SetTransition::clean()
75{
76 m_words.clear();
77}
78
79void SetTransition::copy(const SetTransition& t)
80{
81 m_words=t.m_words;
82}
83
84std::string SetTransition::printValue() const
85{
86 ostringstream oss;
87 oss << "setT:";
88 if (m_words.empty())
89 {
90 return oss.str();
91 }
92 set<Tword>::const_iterator w=m_words.begin();
93 oss << *w;
94 w++;
95 int printMaxV=8;
96 for (; w!=m_words.end(); w++)
97 {
98 oss << ";" << *w;
99 if(--printMaxV==0) {
100 oss << "..." << *w;
101 break;
102 }
103 }
104 return oss.str();
105}
106
107
108/***********************************************************************/
109// comparison tests
110/***********************************************************************/
112{
113 if (type() == tright.type())
114 {
115 const SetTransition& other=static_cast<const SetTransition&>(tright);
116 if ( m_words == other.m_words)
117 {
118 return compareProperties(tright);
119 }
120 }
121 return false;
122}
123
126 const LinguisticGraphVertex& /*vertex*/,
127 AnalysisContent& /*analysis*/,
130{
131 if (m_words.find(token->form())!=m_words.end())
132 {
133 return true;
134 }
135/* std::vector<StringsPoolIndex>::const_iterator
136 it=token->orthographicAlternatives().begin(),
137 it_end=token->orthographicAlternatives().end();
138 for (; it!=it_end; it++)
139 {
140 if (m_words.find(*it)!=m_words.end())
141 {
142 return true;
143 }
144 }*/
145
146 StringsPoolIndex current = static_cast<StringsPoolIndex>(0);
147 for (MorphoSyntacticData::const_iterator it=data->begin();
148 it!=data->end();
149 it++)
150 {
151 if (it->inflectedForm == current) continue;
152 current = it->inflectedForm;
153 if (m_words.find(current)!=m_words.end())
154 {
155 return true;
156 }
157 }
158 return false;
159}
160
161} // namespace end
162} // namespace end
163} // namespace end
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
SetTransition & operator=(const SetTransition &)
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...
bool compareProperties(const TransitionUnit &t) const
An AnalysisData containing a LinguisticGraph with a language and an id.
NAUTITIA.
STL namespace.