LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
EventDataDumper.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 EventDataDumper.cpp
9 * @author Olivier Mesnard (olivier.mesnard@cea.fr)
10 * @date Mon Sep 19 2011
11 * copyright Copyright (C) 2011 by CEA - LIST
12 *
13 ***********************************************************************/
14#include "EventDataDumper.h"
21#include "Events.h"
22#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
41// key to access EventData in AnalysisContent
42m_eventData("EventData"),
43m_segmentationData("SegmentationData")
44{
45}
46
49
50//***********************************************************************
53 Manager* manager)
54
55{
57 LDEBUG << "EventDataDumper::init";
58
59 AbstractTextualAnalysisDumper::init(unitConfiguration,manager);
60
61 try {
62 m_eventData=unitConfiguration.getParamsValueAtKey("eventData");
63 }
65 LDEBUG << "EventDataDumper: no parameter 'eventData', use default ('"<<m_eventData << "')";
66 // not an error, keep default
67 }
68 try {
69 m_segmentationData=unitConfiguration.getParamsValueAtKey("segmentationData");
70 }
72 LDEBUG << "EventDataDumper: no parameter 'segmentationData', use default ('"<<m_segmentationData << "')";
73 // not an error, keep default
74 }
75}
76
78{
80 LDEBUG << "EventDataDumper::process";
82
83 // initialize output
84 auto dstream = AbstractTextualAnalysisDumper::initialize(analysis);
85 ostream& out=dstream->out();
86 if ((! m_eventData.empty())
87 &&(! m_segmentationData.empty())) {
88 auto data = analysis.getData(m_eventData);
89 if (data!=0) {
90 // see if the data is of type EventData
91 auto eventData = std::dynamic_pointer_cast<const EventData>(data);
92
93 if (eventData!=0) {
95 LDEBUG << "EventDataDumper::process: data '" << m_eventData << "' is of type EventData";
96 // get segmentation
97 auto data2 = analysis.getData(m_segmentationData);
98 if(data2==0) {
99 LERROR << "EventDataDumper::process: error: no SegmentationData!!";
100 return MISSING_DATA;
101 }
102 auto segmData = std::dynamic_pointer_cast<const Lima::LinguisticProcessing::SegmentationData>(data2);
103 if (segmData==0) {
104 LERROR << "EventDataDumper::process: data "<< data2.get() <<" is not an object of class SegmentationData";
105 return MISSING_DATA;
106 }
107 eventData->convertToEvents(segmData.get());
108 Events *events=eventData->convertToEvents(segmData.get());
109 LDEBUG << "EventDataDumper::process: events->write(out)...";
110 events->write(out);
111 }
112 else {
113 // see if the data is of type Events
114 auto events = std::dynamic_pointer_cast<const Events>(data);
115 if (events!=0) {
116 LDEBUG << "data '" << m_eventData << "' is of type Events";
117 events->write(out);
118 }
119 else {
120 LERROR << "data '" << m_eventData << "' is neither of type EventData nor Events";
121 return MISSING_DATA;
122 }
123 }
124 }
125 else {
127 LERROR << "no data of name " << m_eventData;
128 return MISSING_DATA;
129 }
130 }
131 else {
133 LERROR << "no key to access eventData or segmentationData! ";
134 return MISSING_DATA;
135 }
136
137
138 TimeUtils::logElapsedTime("EventDataDumper");
139 return SUCCESS_ID;
140}
141
142} // end namespace
143} // end namespace
144} // end namespace
This file is the main header file for the data related to annotation graphs.
#define EVENTDATADUMPER_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, EventDataDumper > EventDataDumperFactory(EVENTDATADUMPER_CLASSID)
NAUTITIA.
LimaStatusCode
Definition LimaCommon.h:236
@ SUCCESS_ID
Definition LimaCommon.h:237
@ MISSING_DATA
Definition LimaCommon.h:243
STL namespace.