LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
AnnotDotGraphWriter.cpp
Go to the documentation of this file.
1// Copyright 2002-2022 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
7
17
18#include <iostream>
19
20using namespace std;
22using namespace Lima::Common::MediaticData;
24using namespace Lima::Common::AnnotationGraphs;
25
26namespace Lima
27{
28namespace LinguisticProcessing
29{
30namespace Compounds
31{
32
34
37
40
43 Manager* manager)
44
45{
51 m_language=manager->getInitializationParameters().media;
52 try
53 {
54 m_outputSuffix=unitConfiguration.getParamsValueAtKey("outputSuffix");
55 }
56 catch (NoSuchParam& )
57 {
58 LWARN << "No param 'outputSuffix' in " << unitConfiguration.getName()
59 << " group for language " << (int)m_language;
60 LWARN << "use .ag.dot";
61 m_outputSuffix=string(".ag.dot");
62 }
63 try
64 {
65 m_graphId=unitConfiguration.getParamsValueAtKey("graph");
66 }
67 catch (NoSuchParam& )
68 {
69 LWARN << "No param 'graph' in "<< unitConfiguration.getName()
70 << " group for language " << (int)m_language;
71 LWARN << "use PosGraph";
72 m_graphId=string("PosGraph");
73 }
74}
75
76
77// Each token of the specified path is
78// searched into the specified dictionary.
80{
82 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.getData(m_graphId));
83 auto metadata = std::dynamic_pointer_cast<LinguisticMetaData>(analysis.getData("LinguisticMetaData"));
84 if (metadata == 0)
85 {
87 LERROR << "no LinguisticMetaData ! abort";
88 return MISSING_DATA;
89 }
90 if (anagraph == 0)
91 {
93 LERROR << "no AnalysisGraph named " << m_graphId << " ! ";
94 return MISSING_DATA;
95 }
96 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.getData("AnnotationData"));
97 if (annotationData==0)
98 {
100 LERROR << "no annotation graph available !";
101 return MISSING_DATA;
102 }
103
104 string outputFileName=metadata->getMetaData("FileName") + m_outputSuffix;
106 *annotationData,
107 m_language);
108 gw.writeToDotFile(outputFileName);
109
110 TimeUtils::logElapsedTime("AnnotDotGraphWriter");
111 return SUCCESS_ID;
112}
113
114} // MorphologicAnalysis
115} //namespace LinguisticProcessing
116} // Lima
117
118
#define ANNOTDOTGRAPHWRITER_CLASSID
This file is the main header file for the data related to annotation graphs.
#define LWARN
Definition LimaCommon.h:160
#define LERROR
Definition LimaCommon.h:161
#define PTLOGINIT
#define COMPOUNDSLOGINIT
Defines a Factory to create Object of type Base.
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
return a message when a 'param' was not found
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
LimaStatusCode process(AnalysisContent &analysis) const override
Process on data in analysisContent.
static void logElapsedTime(const std::string &mess, const std::string &taskCategory=std::string(""))
log the number of microseconds since last UpdateCurrentTime
static void updateCurrentTime(const std::string &taskCategory=std::string(""))
store current time for new elapsed time computation
SimpleFactory< MediaProcessUnit, AnnotDotGraphWriter > annotDotGraphWriterFactory(ANNOTDOTGRAPHWRITER_CLASSID)
NAUTITIA.
LimaStatusCode
Definition LimaCommon.h:236
@ SUCCESS_ID
Definition LimaCommon.h:237
@ MISSING_DATA
Definition LimaCommon.h:243
STL namespace.
launch exception related to the configuration file parsing