LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
numericTransition.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 : numericTransition.cpp
9* Author : Besancon Romaric (besanconr@zoe.cea.fr)
10* Created on : Tue Oct 29 2002
11* Copyright : (c) 2002 by CEA
12* Version : $Id$
13*
14*************************************************************************/
15
16
17#include "numericTransition.h"
20#include <iostream>
21#include <fstream>
22#include <sstream>
23
24using namespace std;
26
27namespace Lima {
28namespace LinguisticProcessing {
29namespace Automaton {
30
31const uint64_t NumericTransition::noValue = std::numeric_limits< uint64_t >::max();
32
33/***********************************************************************/
34// constructors
35/***********************************************************************/
37 TransitionUnit(),m_value(noValue),m_min(noValue),m_max(noValue) {}
38
40 uint64_t min,
41 uint64_t max,
42 bool keep):
43 TransitionUnit(keep),
44 m_value(val),
45 m_min(min),
46 m_max(max) {
47}
50 m_value(t.value()),
51 m_min(t.min()),
52 m_max(t.max()) {
53// copyProperties(t);
54}
55
56/***********************************************************************/
57// destructor
58/***********************************************************************/
60
61/***********************************************************************/
62// operators
63/***********************************************************************/
65 if (this != &t) {
66 m_value = t.value();
67 m_min = t.min();
68 m_max = t.max();
70 }
71 return *this;
72}
73
75 if (type() == tright.type()) {
76 const NumericTransition& other=
77 static_cast<const NumericTransition&>(tright);
78 if (m_value == other.value()
79 && (m_min == other.min())
80 && (m_max == other.max())) {
81 return compareProperties(tright);
82 }
83 }
84 return false;
85}
86
87bool NumericTransition::operator== (const uint64_t& numValue) const {
88 if (isInterval()) {
89 if (m_min == noValue) {
90 return ( numValue <= m_max);
91 }
92 else if (m_max == noValue) {
93 return ( numValue >= m_min);
94 }
95 else {
96 return ( numValue >= m_min && numValue <= m_max);
97 }
98 }
99 else {
100 return (m_value == numValue);
101 }
102}
103
106 const LinguisticGraphVertex& /*vertex*/,
107 AnalysisContent& /*analysis*/,
110{
111
112 const TStatus& status = token->status();
113 if (status.getNumeric() != T_INTEGER) {
114 return false;
115 }
116 uint64_t numValue(token->stringForm().toULong());
117 return (*this == numValue);
118}
119
120/***********************************************************************/
121// output
122/***********************************************************************/
123
124std::string NumericTransition::printValue() const {
125 ostringstream oss;
126 if (isInterval()) {
127 oss << "numericT[";
128 if (m_min == noValue) { oss << "-"; }
129 else { oss << m_min; }
130 oss << "," ;
131 if (m_max == noValue) { oss << "-"; }
132 else { oss << m_max; }
133 oss << "]";
134 }
135 else {
136 oss << "numericT(" << m_value << ")";
137 }
138 return oss.str();
139}
140
141
142} // namespace end
143} // namespace end
144} // namespace end
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
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...
NumericTransition & operator=(const NumericTransition &)
bool operator==(const TransitionUnit &) const override
bool compareProperties(const TransitionUnit &t) const
An AnalysisData containing a LinguisticGraph with a language and an id.
NAUTITIA.
STL namespace.