LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
entityGroupTransition.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 entityGroupTransition.cpp
9 * @author Olivier Mesnard (olivier.mesnard@cea.fr)
10 * @date Mon oct 5 2015
11 * copyright (c) 2006-2015 by CEA
12 *
13 *************************************************************************/
14
15
20
21using namespace std;
23using namespace Lima::Common::MediaticData;
24using namespace Lima::Common::AnnotationGraphs;
26
27namespace Lima {
28namespace LinguisticProcessing {
29namespace Automaton {
30
31/***********************************************************************/
32// initialization of static members
33LimaString EntityGroupTransition::m_entityAnnotation=Common::Misc::utf8stdstring2limastring("SpecificEntity");
34
35/***********************************************************************/
36// constructors
37/***********************************************************************/
43
44EntityGroupTransition::EntityGroupTransition(Common::MediaticData::EntityGroupId groupId, bool keep):
45TransitionUnit(keep),
46m_entityGroupId(groupId)
47{
48}
49
51
53 ostringstream oss;
54 oss << "entityGroupT_" << m_entityGroupId;
55 return oss.str();
56}
57
58/***********************************************************************/
59// operators ==
60/***********************************************************************/
62 if ( (type() == tright.type())
63 && (m_entityGroupId == static_cast<const EntityGroupTransition&>(tright).entityGroupId())
64 ) {
65 return true;
66 }
67 else {
68 return false;
69 }
70}
71
74 const LinguisticGraphVertex& v,
75 AnalysisContent& analysis,
78{
79 // should compare to vertex ?
80 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.getData("AnnotationData"));
81 if (annotationData==0) {
83 LDEBUG << "EntityGroupTransition::compare: no annotation graph available !";
84 return false;
85 }
86
87 // find annotationGraphVertex matching the vertex of the current graph
88 std::set<AnnotationGraphVertex> matches = annotationData->matches(graph.getGraphId(), v, "annot");
89 if (matches.empty())
90 {
92 LDEBUG << "annotation ("<<graph.getGraphId()<<", "<<v<<", \"annot\") available";
93 return false;
94 }
95 AnnotationGraphVertex annotVertex = *(matches.begin());
96
97 if (!annotationData->hasAnnotation(annotVertex, m_entityAnnotation))
98 {
100 LDEBUG << "EntityGroupTransition::compare: No " << m_entityAnnotation << " annotation available on " << v;
101 return false;
102 }
103
104 const SpecificEntityAnnotation* se =
105 annotationData->annotation(annotVertex, m_entityAnnotation).
106 pointerValue<SpecificEntityAnnotation>();
108 AULOGINIT;
109 LDEBUG << "EntityGroupTransition::compare: type = " << type << ", groupId = " << type.getGroupId();
110 LDEBUG << "EntityGroupTransition::compare: m_entityGroupId = " << m_entityGroupId;
111 LDEBUG << "EntityGroupTransition::compare: tests m_entityGroupId == type.getGroupId() = " << (m_entityGroupId == type.getGroupId());
112 return( m_entityGroupId == type.getGroupId() );
113}
114
115} // namespace end
116} // namespace end
117} // namespace end
This file is the main header file for the data related to annotation graphs.
#define LDEBUG
Definition LimaCommon.h:157
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
#define AULOGINIT
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
std::shared_ptr< AnalysisData > getData(const QString &id)
return AnalysisData by id
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...
Common::MediaticData::EntityGroupId entityGroupId() const
An AnalysisData containing a LinguisticGraph with a language and an id.
A representation of a specific entity to store in the annotation graph.
AnnotationGraph::vertex_descriptor AnnotationGraphVertex
LimaString utf8stdstring2limastring(const std::string &src)
NAUTITIA.
QString LimaString
Definition LimaString.h:33
STL namespace.