45using namespace boost::tuples;
57typedef boost::color_traits<boost::default_color_type>
Color;
60namespace LinguisticProcessing {
61namespace AnalysisDumpers {
83 LDEBUG <<
"EasyXmlDumper:: easyXmlDumper init!";
88 m_typeMapping = unitConfiguration.
getMapAtKey(
"typeMapping");
94 LERROR <<
"EasyXmlDumper::init: parameter not found (typeMapping, srcTag and tgtTag must be specified)";
103 LDEBUG <<
"EasyXmlDumper:: graph parameter not found, using PosGraph";
113 LERROR <<
"EasyXmlDumper::init: Missing parameter handler in EasyXmlDumper configuration";
124 if (metadata ==
nullptr) {
125 LERROR <<
"EasyXmlDumper::process no LinguisticMetaData ! abort";
128 string filename = metadata->
getMetaData(
"FileName");
129 LDEBUG <<
"EasyXmlDumper::process Filename: " << filename;
131 LDEBUG <<
"handler will be: " << m_handler;
133 auto h = std::dynamic_pointer_cast<AnalysisHandlerContainer>(analysis.
getData(
"AnalysisHandlerContainer"));
137 LERROR <<
"EasyXmlDumper::process: handler " << m_handler <<
" has not been given to the core client";
141 auto graph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
m_graph));
142 if (graph ==
nullptr)
148 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.
getData(
"SyntacticData"));
149 if (syntacticData ==
nullptr)
152 syntacticData->setupDependencyGraph();
153 analysis.
setData(
"SyntacticData",syntacticData);
156 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.
getData(
"AnnotationData"));
157 if (annotationData ==
nullptr)
159 annotationData = std::make_shared<AnnotationData>();
160 if (std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"AnalysisGraph")) != 0)
162 std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"AnalysisGraph"))->populateAnnotationGraph(annotationData,
"AnalysisGraph");
164 analysis.
setData(
"AnnotationData",annotationData);
169 std::ostream outputStream(&hsb);
171 LDEBUG <<
"EasyXmlDumper:: process before printing heading";
172 auto anaGraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"AnalysisGraph"));
173 auto posGraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"PosGraph"));
174 if (anaGraph != 0 && posGraph != 0)
176 LDEBUG <<
"EasyXmlDumper:: begin of posgraph";
177 std::vector< bool > alreadyDumpedTokens;
178 std::map< LinguisticAnalysisStructure::Token*, uint64_t > fullTokens;
181 alreadyDumpedTokens.resize(num_vertices(*posGraph->getGraph()));
182 for (boost::tie(i, i_end) = vertices(*posGraph->getGraph()); i != i_end; ++i)
184 LDEBUG <<
"EasyXmlDumper:: examine posgraph for " << id;
185 alreadyDumpedTokens[id] =
false;
186 fullTokens[get(
vertex_token, *posGraph->getGraph(), *i)] = id;
200 LDEBUG <<
"EasyXmlDumper:: retrieve sentence id " << sentIdPrefix;
204 if(sentIdPrefix.length() <= 0)
211 LDEBUG <<
"EasyXmlDumper:: inside posgraph while ";
228 LDEBUG <<
"EasyXmlDumper:: end of posgraph";
245 const std::string& graphId,
246 std::vector< bool >& alreadyDumpedTokens,
247 std::map< LinguisticAnalysisStructure::Token*, uint64_t >& fullTokens,
248 std::string sentIdPrefix)
const
252 LDEBUG <<
"EasyXmlDumper:: dumpLimaData parameters: ";
253 LDEBUG <<
"EasyXmlDumper:: begin = " << begin;
254 LDEBUG <<
"EasyXmlDumper:: end = " << end;
256 LDEBUG <<
"EasyXmlDumper:: posgraph last vertex = " << posGraph.
lastVertex();
257 LDEBUG <<
"EasyXmlDumper:: graphId = " << graphId;
258 LDEBUG <<
"EasyXmlDumper:: sentIdPrefix = " << sentIdPrefix;
261 for (uint64_t i = 0; i<alreadyDumpedTokens.size(); i++)
263 if (alreadyDumpedTokens[i])
265 LDEBUG <<
"EasyXmlDumper:: already_dumped_tokens[" << i <<
"] =" << alreadyDumpedTokens[i];
269 std::string sentIdStr = sentIdPrefix;
272 uint64_t sentIdsuffix = 0;
275 std::stringstream sentIdStream;
276 sentIdStream << sentIdPrefix << sentIdsuffix;
277 sentIdStr = sentIdStream.str();
281 LDEBUG <<
"EasyXmlDumper:: searching and extracting vertices and relations";
295 LDEBUG <<
"EasyXmlDumper:: all found vertices and relations extracted";
302 EasyDumper ed(care, m_typeMapping, m_srcTag, m_tgtTag, sentIdStr);
303 std::stringstream sentEasyStream;
304 ed.
dump(sentEasyStream);
305 if(sentEasyStream.str().length() > 0)
310 os <<
"<E id=\"" << sentIdStr <<
"\">" << std::endl;
311 os << sentEasyStream.str();
312 os <<
"</E>" << std::endl;
This file is the main header file for the data related to annotation graphs.
extracts forms and relations from boost graph (origninally, from XML file)
A graph that stores the relations of syntactic dependency between the elements of a DependencyGraph.
dump the content of the analysis graph in Easy XML format
A graph structure for linguistic analysis.
LinguisticGraph::vertex_iterator LinguisticGraphVertexIt
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
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
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
void setData(const QString &id, std::shared_ptr< AnalysisData > data)
set an analysisData with the given id.
Holds an annotation graph and gives an API to manipulate it.
std::string & getParamsValueAtKey(const std::string &key)
std::map< std::string, std::string > & getMapAtKey(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.
void splitCompoundTenses()
void constructionDesGroupes()
construit les groupes syntaxiques apres la lecture du graphe
void addLastFormsInGroups()
void constructionDesRelationsEntrantes()
construit les relations entrantes des formes
void visitBoostGraph(const LinguisticGraphVertex &v, const LinguisticGraphVertex &end, const LinguisticGraph &anaGraph, const LinguisticGraph &posGraph, const Common::AnnotationGraphs::AnnotationData &annotationData, const SyntacticAnalysis::SyntacticData &syntacticData, std::map< LinguisticAnalysisStructure::Token *, uint64_t > &fullTokens, std::vector< bool > &alreadyDumpedTokens, const MediaId &language)
void replaceSEWithCompounds()
void dump(std::ostream &out)
Dumps all the content of the analysis on an XML stream.
const Common::PropertyCode::PropertyCodeManager * m_propertyCodeManager
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 dumpLimaData(std::ostream &os, const LinguisticGraphVertex &begin, const LinguisticGraphVertex &end, const LinguisticAnalysisStructure::AnalysisGraph &anaGraph, const LinguisticAnalysisStructure::AnalysisGraph &posGraph, const Common::AnnotationGraphs::AnnotationData &annotationData, const SyntacticAnalysis::SyntacticData &syntacticData, const std::string &graphId, std::vector< bool > &alreadyDumpedTokens, std::map< LinguisticAnalysisStructure::Token *, uint64_t > &easyTokens, std::string sentIdPrefix) const
std::vector< std::string > m_sentIds
An AnalysisData containing a LinguisticGraph with a language and an id.
const LinguisticGraphVertex & lastVertex(void) const
Returns the last vertex of the graph.
const LinguisticGraph * getGraph(void) const
Returns the underlying graph structure.
const LinguisticGraphVertex & firstVertex(void) const
Returns the first vertex of the graph.
This class points to a graph, its dependency graph and the structure that holds the maping between th...
static const MediaticData & single()
const singleton accessor
static void updateCurrentTime(const std::string &taskCategory=std::string(""))
store current time for new elapsed time computation
boost::color_traits< boost::default_color_type > Color
dump the content of the analysis graph in Easy XML format
#define EASYXMLDUMPER_CLASSID
SimpleFactory< MediaProcessUnit, EasyXmlDumper > easyXmlDumperFactory(EASYXMLDUMPER_CLASSID)
launch exception related to the configuration file parsing