LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
EventTemplateDataDumper.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 EventTemplateDataDumper.cpp
9 * @author Romaric Besancon (romaric.besancon@cea.fr)
10 * @date Mon Sep 19 2011
11 * copyright Copyright (C) 2011 by CEA - LIST
12 *
13 ***********************************************************************/
14
22#include "Events.h"
23#include "Entity.h"
24
25using namespace std;
26using namespace Lima::Common;
27using namespace Lima::Common::AnnotationGraphs;
29using namespace boost;
30
31namespace Lima {
32namespace LinguisticProcessing {
33namespace EventAnalysis {
34
35//***********************************************************************
38
41m_eventData("EventTemplateData")
42{
43}
44
47
48//***********************************************************************
51 Manager* manager)
52
53{
55 LDEBUG << "EventTemplateDataDumper::init";
56
57 AbstractTextualAnalysisDumper::init(unitConfiguration,manager);
58
59 try {
60 m_eventData=unitConfiguration.getParamsValueAtKey("eventTemplateData");
61 }
63 LDEBUG << "EventTemplateDataDumper: no parameter 'eventTemplateData', use default ('"<<m_eventData << "')";
64 // not an error, keep default
65 }
66}
67
69{
71 LDEBUG << "EventTemplateDataDumper::process";
73
74 // initialize output
75 auto dstream=AbstractTextualAnalysisDumper::initialize(analysis);
76 ostream& out=dstream->out();
77
78 const auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.getData("AnnotationData"));
79 if (annotationData==0)
80 {
81 LERROR << "no annotation graph available !";
82 return MISSING_DATA;
83 }
84
85 if (! m_eventData.empty()) {
86 auto data = analysis.getData(m_eventData);
87 if (data!=0) {
88 // see if the data is of type Events
89 auto eventData = std::dynamic_pointer_cast<const EventTemplateData>(data);
90 if (eventData==0) {
92 LERROR << "data '" << m_eventData << "' is neither of type EventData nor Events";
93 return MISSING_DATA;
94 }
95 else {
96 Events *events=eventData->convertToEvents(annotationData.get());
97 events->write(out);
98 }
99 }
100 else {
102 LERROR << "no data of name " << m_eventData;
103 }
104 }
105
106 TimeUtils::logElapsedTime("EventTemplateDataDumper");
107 return SUCCESS_ID;
108}
109
110} // end namespace
111} // end namespace
112} // end namespace
This file is the main header file for the data related to annotation graphs.
#define EVENTTEMPLATEDATADUMPER_CLASSID
#define LDEBUG
Definition LimaCommon.h:157
#define LERROR
Definition LimaCommon.h:161
#define EVENTANALYSISLOGINIT
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
Manage initialization of InitializableObjects using configuration module and parameters.
std::shared_ptr< DumperStream > initialize(AnalysisContent &analysis) const
virtual 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.
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
virtual void write(std::ostream &file) const
Definition Events.cpp:45
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, EventTemplateDataDumper > EventTemplateDataDumperFactory(EVENTTEMPLATEDATADUMPER_CLASSID)
NAUTITIA.
LimaStatusCode
Definition LimaCommon.h:236
@ SUCCESS_ID
Definition LimaCommon.h:237
@ MISSING_DATA
Definition LimaCommon.h:243
STL namespace.