38using namespace boost::tuples;
40typedef color_traits<default_color_type>
Color;
43 using namespace Common::XMLConfigurationFiles;
44 using namespace Common::MediaticData;
45 using namespace Common::AnnotationGraphs;
46namespace LinguisticProcessing {
47namespace AnalysisDumpers {
61 : m_language(language), m_handler( handler)
90 LERROR <<
"AnnotationGraphXmlDumper::init: Missing parameter handler in AnnotationGraphXmlDumper configuration";
98 std::string prologue(
"<?xml version='1.0' encoding='UTF-8'?>");
99 return dump( analysis, prologue );
107 auto metadata = std::dynamic_pointer_cast<LinguisticMetaData>(analysis.
getData(
"LinguisticMetaData"));
109 LERROR <<
"AnnotationGraphXmlDumper::process: no LinguisticMetaData ! abort";
113 auto h = std::dynamic_pointer_cast<AnalysisHandlerContainer>(analysis.
getData(
"AnalysisHandlerContainer"));
117 LERROR <<
"AnnotationGraphXmlDumper::process: handler " <<
m_handler <<
" has not been given to the core client";
123 std::ostream outputStream(&hsb);
125 if( !prologue.empty() )
126 outputStream << prologue << std::endl;
128 outputStream <<
"<lima_annotation_graph_dump>" << std::endl;
130 dumpLimaData(outputStream, *(std::dynamic_pointer_cast<AnnotationData>(analysis.
getData(
"AnnotationData"))));
132 outputStream <<
"</lima_annotation_graph_dump>" << std::endl;
150 os <<
"<annot-graph>" << std::endl;
154 boost::tie(i, i_end) = vertices(graph);
155 boost::depth_first_search(graph, boost::visitor(vis));
160 os <<
"</annot-graph>" << std::endl;
171 std::ostream& xmlStream)
const
173 xmlStream <<
" <vertex id=\"" << v <<
"\" >" << std::endl;
177 xmlStream <<
" </vertex>" << std::endl;
183 std::ostream& xmlStream)
const
186 auto it = map.cbegin();
auto it_end = map.cend();
189 xmlStream <<
" <iannots>" << std::endl;
190 for (; it != it_end; it++)
192 xmlStream <<
" <iannot name=\""
194 <<
"\" value=\"" << (*it).second <<
"\" />" << std::endl;
196 xmlStream <<
" </iannots>" << std::endl;
203 std::ostream& xmlStream)
const
206 auto it = map.cbegin();
auto it_end = map.cend();
210 xmlStream <<
" <sannots>" << std::endl;
211 for (; it != it_end; it++)
213 xmlStream <<
" <sannot name=\""
215 <<
"\" value=\"" << (*it).second.toStdString() <<
"\" />" << std::endl;
217 xmlStream <<
" </sannots>" << std::endl;
224 std::ostream& xmlStream)
const
227 AGGannotProp::iterator it, it_end;
231 xmlStream <<
" <annots>" << std::endl;
232 for (; it != it_end; it++)
234 xmlStream <<
" <annot name=\""
237 const_cast<AnnotationData&
>(annotData).dumpFunction((*it).first)->dump(
238 xmlStream, ((*it).second));
239 xmlStream <<
"\" />" << std::endl;
241 xmlStream <<
" </annots>" << std::endl;
248 std::ostream& xmlStream)
const
250 xmlStream <<
" <edge src=\"" << source(e, graph)
251 <<
"\" targ=\"" << target(e, graph) <<
"\">" << std::endl;
255 xmlStream <<
" </edge>" << std::endl;
261 std::ostream& xmlStream)
const
264 auto it = map.cbegin();
auto it_end = map.cend();
267 xmlStream <<
" <iannots>" << std::endl;
268 for (; it != it_end; it++)
270 xmlStream <<
" <iannot name=\""
272 <<
"\" value=\"" << (*it).second <<
"\" />" << std::endl;
274 xmlStream <<
" </iannots>" << std::endl;
281 std::ostream& xmlStream)
const
284 AGSannotProp::const_iterator it, it_end;
285 it = map.begin(); it_end = map.end();
288 xmlStream <<
" <sannots>" << std::endl;
289 for (; it != it_end; it++)
291 xmlStream <<
" <sannot name=\""
293 <<
"\" value=\"" << (*it).second.toStdString()
294 <<
"\" />" << std::endl;
296 xmlStream <<
" </sannots>" << std::endl;
303 std::ostream& xmlStream)
const
310 xmlStream <<
" <annots>" << std::endl;
311 for (; it != it_end; it++)
313 xmlStream <<
" <annot name=\""
316 const_cast<AnnotationData&
>(annotData).dumpFunction((*it).first)->dump(
317 xmlStream, ((*it).second));
318 xmlStream <<
"\" />" << std::endl;
320 xmlStream <<
" </annots>" << std::endl;
333 LDEBUG <<
"DumpGraphVisitor: examine_vertex " << v;
340 LDEBUG <<
"DumpGraphVisitor: discover_edge " << e;
342 m_dumper.outputEdge(e, g, m_data, m_os);
348 m_dumper.outputVertex(v, graph, m_data, m_os);
This file is the main header file for the data related to annotation graphs.
color_traits< default_color_type > Color
#define ANNOTATIONGRAPHXMLDUMPER_CLASSID
std::map< uint64_t, Lima::Common::AnnotationGraphs::GenericAnnotation > AGGannotProp
Property to annotate vertices with generic values.
std::map< uint64_t, Lima::LimaString > AGSannotProp
Property to annotate vertices with string values.
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, AGVertexProperties, AGEdgeProperties > AnnotationGraph
The graph class.
std::map< uint64_t, uint64_t > AGIannotProp
Property to annotate vertices with integer values.
Defines a Factory to create Object of type Base.
virtual void startAnalysis()=0
function called by the LIMA analyzer on start of a new document
virtual void endAnalysis()=0
function called by the LIMA analyzer on the end of a text part that is to be analyzed
defines callback interface
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
Holds an annotation graph and gives an API to manipulate it.
const LimaString & annotationName(uint64_t annotationId) const
Gives the name of an annotation id.
std::string & getParamsValueAtKey(const std::string &key)
return a message when a 'param' was not found
Manage initialization of InitializableObjects using configuration module and parameters.
const InitializationParameters & getInitializationParameters() const
get Initialization Parameters
Use this exception to signal an error in one of the configuration files.
a visitor for going through the graph between two points and storing a BoWToken for every vertex that...
void discover_vertex(AnnotationGraphVertex v, const AnnotationGraph &g)
void examine_vertex(AnnotationGraphVertex v, const AnnotationGraph &g)
void examine_edge(AnnotationGraphEdge e, const AnnotationGraph &g)
void outputEdgeSAnnotations(const AnnotationGraphEdge e, const AnnotationGraph &graph, const Common::AnnotationGraphs::AnnotationData &annotData, std::ostream &xmlStream) const
void outputVertexIAnnotations(const AnnotationGraphVertex v, const AnnotationGraph &graph, const Common::AnnotationGraphs::AnnotationData &annotData, std::ostream &xmlStream) const
AnnotationGraphXmlDumper()
void outputVertexGAnnotations(const AnnotationGraphVertex v, const AnnotationGraph &graph, const Common::AnnotationGraphs::AnnotationData &annotData, std::ostream &xmlStream) const
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
void outputVertex(const AnnotationGraphVertex v, const AnnotationGraph &graph, const Common::AnnotationGraphs::AnnotationData &annotData, std::ostream &xmlStream) const
void outputEdgeGAnnotations(const AnnotationGraphEdge e, const AnnotationGraph &graph, const Common::AnnotationGraphs::AnnotationData &annotData, std::ostream &xmlStream) const
LimaStatusCode dump(AnalysisContent &analysis, const std::string &prologue="") const
virtual ~AnnotationGraphXmlDumper()
void dumpLimaData(std::ostream &os, const Common::AnnotationGraphs::AnnotationData &annotData) const
void outputEdgeIAnnotations(const AnnotationGraphEdge e, const AnnotationGraph &graph, const Common::AnnotationGraphs::AnnotationData &annotData, std::ostream &xmlStream) const
LimaStatusCode process(AnalysisContent &analysis) const override
Process on data in analysisContent.
void outputVertexSAnnotations(const AnnotationGraphVertex v, const AnnotationGraph &graph, const Common::AnnotationGraphs::AnnotationData &annotData, std::ostream &xmlStream) const
void outputEdge(const AnnotationGraphEdge e, const AnnotationGraph &graph, const Common::AnnotationGraphs::AnnotationData &annotData, std::ostream &xmlStream) const
This file contains a class to control log of informations about time, such as logging cumulated time ...
AnnotationGraph & getGraph()
AnnotationGraph::vertex_iterator AnnotationGraphVertexIt
AnnotationGraph::edge_descriptor AnnotationGraphEdge
AnnotationGraph::vertex_descriptor AnnotationGraphVertex
SimpleFactory< MediaProcessUnit, AnnotationGraphXmlDumper > annotationGraphXmlDumperFactory(ANNOTATIONGRAPHXMLDUMPER_CLASSID)
launch exception related to the configuration file parsing