LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
EventAnalyzer.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
16#include "EventAnalyzer.h"
17#include "Events.h"
18
19
21
26
27#include <iostream>
28#include <queue>
29
30
31using namespace std;
32//using namespace boost;
33using namespace boost::tuples;
34
35using namespace Lima::Common::Misc;
36using namespace Lima::Common::MediaticData;
37using namespace Lima::Common::AnnotationGraphs;
38using namespace Lima::LinguisticProcessing;
42
43
44namespace Lima
45{
46namespace LinguisticProcessing
47{
48namespace EventAnalysis
49{
51
52
53
55m_graphId("PosGraph"),
56m_language(),
57m_dateEntity(),
58m_eventEntity(),
59m_set_otherentities(),
60m_entitiesWeights(),
61map_paragraphs()
62{}
63
64
67 Manager* manager)
68
69{
71
72 LDEBUG << "EventAnalyzer::init()...";
73 m_language=manager->getInitializationParameters().media;
74 try
75 {
76 m_graphId=unitConfiguration.getParamsValueAtKey("graph");
77 }
79 {
80
81 } // use default value Posgraph
82
83 try
84 {
85 string dateEntity=unitConfiguration.getParamsValueAtKey("DateEntity");
87 }
89 {
90 LERROR << "No DateEntity defined in "<<unitConfiguration.getName()<<" configuration group for language " << m_language;
91 }
92 try
93 {
94 string eventEntity=unitConfiguration.getParamsValueAtKey("EventEntity");
96 }
98 {
99 LERROR << "No EventEntity defined in "<<unitConfiguration.getName()<<" configuration group for language " << m_language;
100 }
101 try
102 {
103 deque<string> otherEntities = unitConfiguration.getListsValueAtKey("OtherEntities");
104 for(deque<string>::iterator itr=otherEntities.begin();itr !=otherEntities.end();itr++)
105 {
107 }
108 }
110 {
111 LERROR << "No OtherEntities defined in "<<unitConfiguration.getName()<<" configuration group for language " << m_language;
112 }
113 try
114 {
115 std::map<std::string,std::string>& weights=unitConfiguration.getMapAtKey("EntitiesWeights");
116 LDEBUG << "Weights map size =" << weights.size();
117 for (std::map<std::string,std::string>::const_iterator it=weights.begin();
118 it!=weights.end();
119 it++)
120 {
121 LDEBUG << "Init EntitiesWeights: "
122 << it->first << ", "
123 << "entityType=" << Common::MediaticData::MediaticData::single().
125 << " , weight " << atoi((it->second).c_str());
126 m_entitiesWeights[Common::MediaticData::MediaticData::single().getEntityType(Common::Misc::utf8stdstring2limastring(it->first))]=atoi((it->second).c_str());
127 }
128 }
130 {
131 LERROR << "No map 'EntitiesWeigths' in "<<unitConfiguration.getName()<<" configuration group for language " << m_language;
132
133 }
134
135}
136
143 AnalysisContent& analysis) const
144{
147 LDEBUG << "start EventAnalyzer";
148
149 // ici normalement on peut prendre soit analysis graph soit le Posgraph, cela doit être paramétré
150 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.getData(m_graphId));
151 if (anagraph==0)
152 {
153 LERROR << "no "<< m_graphId << " ! abort";
154 return MISSING_DATA;
155 }
156 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.getData("AnnotationData"));
157 if (annotationData==0)
158 {
159 LERROR << "no AnnotationData ! abort";
160 return MISSING_DATA;
161 }
162 auto sb = std::dynamic_pointer_cast<SegmentationData>(analysis.getData("SentenceBoundaries"));
163 if (sb==0)
164 {
165 LERROR << "no SentenceBoundaries ! abort";
166 return MISSING_DATA;
167 }
168 auto pb = std::dynamic_pointer_cast<SegmentationData>(analysis.getData("ParagraphBoundaries"));
169 if (pb==0)
170 {
171 LERROR << "no ParagraphBoundaries ! abort";
172 return MISSING_DATA;
173 }
174 std::vector<Paragraph*> v_paragraph;
175 compute_paragraphs(v_paragraph,anagraph->getGraph(),anagraph.get(),sb.get(), pb.get(), annotationData.get());
176
177 std::map<std::string,Event*> map_event;
178 compute_events(map_event,v_paragraph,anagraph->getGraph(), annotationData.get(), m_graphId);
179
180 Events * eventData=new Events();
181
182 // Computes entities weight of events
183 uint64_t max_weight=0;
184 Event* main_event=0;
185 for (std::map<std::string,Event*>::const_iterator iT=map_event.begin();iT!=map_event.end();iT++)
186 {
187 (*iT).second->compute_entities_weight(m_entitiesWeights, annotationData.get(), m_graphId);
188 if ((*iT).second->get_weight() > max_weight)
189 {
190 max_weight=(*iT).second->get_weight();
191 main_event=(*iT).second;
192 }
193
194 eventData->push_back((*iT).second);
195 }
196 LDEBUG << "Le nombre d'évènements différents est égal à = " << map_event.size();
197
198 LDEBUG << "set new data 'EventData' of type Events";
199 analysis.setData("EventData",eventData);
200
201 if (main_event!=0)
202 {
203 LDEBUG << "Le meilleur poids est égal à = " << max_weight;
204 main_event->setMain();
205 main_event->compute_main_entities();
206 }
207
208 int i=0;
209 for (std::vector<Event*>::const_iterator iT= eventData->begin(); iT!= eventData->end();iT++)
210 {
211 i++;
212 LDEBUG << "Event N° " << i;
213 LDEBUG << " a pour poids " << (*iT)->get_weight();
214 LDEBUG << " a pour valeur main " << (*iT)->getMain();
215 LDEBUG << " est composé des fragments de texte suivants ";
216 int j=0;
217 for(std::vector<EventParagraph*>::const_iterator iT1= (*iT)->begin(); iT1!= (*iT)->end();iT1++)
218 {
219 LDEBUG << " paragraph " << j << " position = " << (*iT1)->getPosition() << " , longueur = " << (*iT1)->getLength() ;
220 std::map<Common::MediaticData::EntityType,std::vector<Entity *> > otherEntities=(*iT1)->getOtherEntities();
221 LDEBUG << " les entités sont";
222 for(std::map<Common::MediaticData::EntityType,std::vector<Entity *> >::const_iterator iT2= otherEntities.begin(); iT2!= otherEntities.end();iT2++)
223 {
224 LDEBUG << " type=" << (*iT2).first;
225 for(std::vector<Entity *>::const_iterator iT3=(*iT2).second.begin();iT3!=(*iT2).second.end();iT3++)
226 {
227 LDEBUG << " position=" << (*iT3)->getPosition() << " ,longueur = " <<(*iT3)->getLength()<< ", main =" << (*iT3)->getMain();
228 Lima::LinguisticProcessing::Automaton::EntityFeatures features= (*iT3)->getFeatures();
229 for (Automaton::EntityFeatures::const_iterator
230 featureItr=features.begin(),features_end=features.end();
231 featureItr!=features_end; featureItr++)
232 {
233 LDEBUG << " Feature=" << featureItr->getName() << ", value=" << featureItr->getValueString();
234 }
235 }
236 }
237 std::pair<Common::MediaticData::EntityType,std::vector<Entity *> > eventEntities=(*iT1)->getEventEntities();
238 LDEBUG << " Event type=" << eventEntities.first;
239 for(std::vector<Entity *>::const_iterator iT3=eventEntities.second.begin();iT3!=eventEntities.second.end();iT3++)
240 {
241 LDEBUG << " position=" << (*iT3)->getPosition() << " ,longueur = " <<(*iT3)->getLength()<< ", main =" << (*iT3)->getMain();
242 Lima::LinguisticProcessing::Automaton::EntityFeatures features= (*iT3)->getFeatures();
243 for (Automaton::EntityFeatures::const_iterator
244 featureItr=features.begin(),features_end=features.end();
245 featureItr!=features_end; featureItr++)
246 {
247 LDEBUG << " Feature=" << featureItr->getName() << ", value=" << featureItr->getValueString();
248 }
249 }
250 j++;
251 }
252 }
253
254 TimeUtils::logElapsedTime("EventAnalyzer");
255 return SUCCESS_ID;
256}
257
258void EventAnalyzer::compute_events(std::map<std::string,Event*>& map_event, std::vector<Paragraph*> v_par,
260 std::string graphId) const
261{
263
264
265 for (uint64_t i=0; i<v_par.size();i++)
266 {
267 Paragraph *p=v_par[i];
268
269
270 if (p->toFilter() || (p->getDatesSize()==0))
271 {
272 // ignorer le paragraphe complètement et le supprimer
273 delete(v_par[i]);
274 LDEBUG << "Paragraph numéro : " << (i+1) << " a filtrer ";
275 }
276 else
277 {
278 LDEBUG << "Paragraph numéro : " << (i+1) << " a étudier ayant comme nombre de date = " << p->getDatesSize();
279 // Il faut juste ajouter le paragraphe dans l'évènement concerné
280 if (p->getDatesSize()==1)
281 {
282 LDEBUG << " La date est " << p->getDate().first;
283 std::pair<string,LinguisticGraphVertex> date=p->getDate();
284 if (map_event.find(date.first)!=map_event.end())
285 {
286 Event *ev=map_event[date.first];
287 ev->addParagraph(p,true,false,annotationData,graphId,graph);
288 map_event[date.first]=ev;
289 }
290 else
291 {
292 Event *ev=new Event();
293 ev->setDate(make_pair(m_dateEntity,date));
294 LDEBUG << "Creation d'un nouvel évènement ";
295 ev->addParagraph(p,true,false,annotationData,graphId,graph);
296 map_event[date.first]=ev;
297 }
298 }
299 else // Cas complexe
300 {
301 bool first_time=true;
302 while(p->getDatesSize()>1)
303 {
304 Paragraph *p1 =new Paragraph();
305 p1->setPosition(p->getPosition());
306 std::pair<std::string,LinguisticGraphVertex> date1=p->extractDate();
307 std::pair<std::string,LinguisticGraphVertex> date2=p->getDate();
308 Token *t_date2=get(vertex_token,*graph,date2.second);
309 p1->setPosition(p->getPosition());
310 p1->addDate(date1.first,date1.second);
311 LinguisticGraphVertex split=date2.second;
312 bool end=(p->getSentencesSize()==0);
313 while(!end)
314 {
316 Token *t_sentence=get(vertex_token,*graph,sentence);
317 if(t_sentence->position() < t_date2->position())
318 split=sentence;
319 else
320 {
321 p->addSentence(sentence);
322 end=true;
323 }
324 }
325
326 Token *t_split=get(vertex_token,*graph,split);
327 p1->setLength(t_split->position()-p->getPosition());
328 p->setPosition(t_split->position());
329 p->setLength(p->getLength()-p1->getLength());
330
331 std::map<Common::MediaticData::EntityType, std::deque<LinguisticGraphVertex> > entities = p->extractEntitiesBeforeVertex(split,graph);
332
333 std::pair<Common::MediaticData::EntityType, std::deque<LinguisticGraphVertex> > evententities = p->extractEventEntitiesBeforeVertex(split,graph);
334
335 LDEBUG << "EventAnalyzer evententities type " << evententities.first;
336 p1->addEventEntities(evententities);
338
339 if (p1->toFilter())
340 {
341 delete(p1);
342 }
343 else
344 {
345 std::pair<string,LinguisticGraphVertex> date=p1->getDate();
346 if (map_event.find(date.first)!=map_event.end())
347 {
348 Event *ev=map_event[date.first];
349 ev->addParagraph(p1,first_time,true,annotationData,graphId,graph);
350 map_event[date.first]=ev;
351 }
352 else
353 {
354 Event *ev=new Event();
355 ev->setDate(make_pair(m_dateEntity,date));
356 LDEBUG << "Creation d'un nouvel évènement ";
357 ev->addParagraph(p1,first_time,true,annotationData,graphId,graph);
358 map_event[date.first]=ev;
359 }
360 }
361 first_time=false;
362 }// end while
363 // traiter la dernière date
364 if (p->toFilter())
365 {
366 delete(p);
367 }
368 else{
369 std::pair<string,LinguisticGraphVertex> date=p->getDate();
370 if (map_event.find(date.first)!=map_event.end())
371 {
372 Event *ev=map_event[date.first];
373 ev->addParagraph(p,false,false,annotationData,graphId,graph);
374 map_event[date.first]=ev;
375 }
376 else
377 {
378 Event *ev=new Event();
379 ev->setDate(make_pair(m_dateEntity,date));
380 LDEBUG << "Creation d'un nouvel évènement ";
381 ev->addParagraph(p,false,false,annotationData,graphId,graph);
382 map_event[date.first]=ev;
383 }
384 }
385 }
386 }
387 }
388}
389
390void EventAnalyzer::compute_paragraphs(std::vector<Paragraph*>& v_par,
391 LinguisticGraph* graph,
392 AnalysisGraph* anagraph,
394 SegmentationData* pb,
395 Common::AnnotationGraphs::AnnotationData* annotationData) const
396{
398
399
400// LinguisticGraphVertex v;
401
402 const LinguisticGraphVertex firstVx = anagraph->firstVertex();
403 const LinguisticGraphVertex lastVx = anagraph->lastVertex();
404
405 std::set<LinguisticGraphVertex> visited;
406 std::queue<LinguisticGraphVertex> toVisit;
407 LDEBUG << "compute_paragraphs: push vertex " << firstVx;
408 toVisit.push(firstVx);
409
410 LinguisticGraphOutEdgeIt outItr,outItrEnd;
411
412 Paragraph *p=new Paragraph();
413 uint64_t id_paragraph=1;
414 p->setId(id_paragraph);
415
416 Token* token=0;
417 Token* previous_token=0;
418 uint64_t position;
419// uint64_t length=0;
420
421 v_par.push_back(p);
422 std::string current_date= "00-00-00";
423
424 while (!toVisit.empty())
425 {
426 LinguisticGraphVertex v=toVisit.front();
427 LDEBUG << "compute_paragraphs: pop vertex " << v;
428 toVisit.pop();
429 if (v != lastVx) {
430
431
432 for (boost::tie(outItr,outItrEnd)=out_edges(v,*graph);
433 outItr!=outItrEnd;
434 outItr++)
435 {
436 LinguisticGraphVertex next=target(*outItr,*graph);
437 if (visited.find(next)==visited.end())
438 {
439 visited.insert(next);
440 LDEBUG << "compute_paragraphs: push vertex " << next;
441 toVisit.push(next);
442 }
443 }
444 }
445 if (v != firstVx && v != lastVx)
446 {
447 LDEBUG << "Traitement du vertex " << v;
448 LDEBUG << "current_date du vertex " << current_date;
449 token = get(vertex_token, *graph, v);
450 // it is a vertex of a new paragraph
451 if(is_a_bound(v,pb) )
452 {
453
454 LDEBUG << "Je suis dans le Début d'un nouveau paragraphe ";
455 current_date= "00-00-00";
456 // créer la map du vertex
457 uint64_t par_position=v_par[v_par.size()-1]->getPosition();
458 uint64_t last_position=previous_token->position()+previous_token->length()-1;
459 v_par[v_par.size()-1]->setLength(last_position-par_position+1);
460
461 position= token->position();
462 v_par.push_back(new Paragraph());
463 id_paragraph++;
464 v_par[v_par.size()-1]->setId(id_paragraph);
465 v_par[v_par.size()-1]->setPosition(position);
466 }
467
468 if (is_specific_entity(v,annotationData))
469 {
470 LDEBUG << "Je suis dans un vertex de type Entité nommée ";
471 // verify if it is a date
472 if(is_specific_entity(v,annotationData,m_dateEntity))
473 {
474 string date= getDate(v,annotationData,m_dateEntity);
475 LDEBUG << "Je suis dans Date ";
476 LDEBUG << "Valeur de la Date =" << date;
477 if (date.compare("00-00-00")==0)
478 {
479 // ignorer la date
480 LDEBUG << "Date mal normalisée à ignorer";
481 }
482 else
483 {
484 v_par[v_par.size()-1]->addDate(date,v);
485 current_date=date;
486 }
487 }
488 // verify if it is a event
489 else if(is_specific_entity(v,annotationData,m_eventEntity))
490 {
491 // mettre l'entités nommées dans le bon para
492 LDEBUG << "Je suis dans Evenement ";
493 v_par[v_par.size()-1]->addEventEntity(m_eventEntity,v);
494 }
495 // verify if it is is the set of entities domain
496 else if(is_specific_entity_in(v,annotationData,m_set_otherentities))
497 {
498 // mettre l'entités nommées dans le bon para
499 LDEBUG << "Je suis dans les autres types d'EN ";
500 Common::MediaticData::EntityType e =getEntityType(v,annotationData,m_graphId);
501 v_par[v_par.size()-1]->addEntity(e,v);
502 }
503 //ignore if it is a another type of entity
504 }
505
506 // it is the last position of the current sentence
507 else if (is_a_bound(v,sb))
508 {
509 LDEBUG << "Je suis dans fin d'une phrase ";
510 // ajouter la position de la phrase dans le paragraphe
511 v_par[v_par.size()-1]->addSentence(v);
512 }
513 }
514 else
515 {
516 if (v == lastVx)
517 {
518 uint64_t par_position=v_par[v_par.size()-1]->getPosition();
519 uint64_t last_position=previous_token->position()+previous_token->length()-1;
520 v_par[v_par.size()-1]->setLength(last_position-par_position+1);
521 LDEBUG << "par_position " << par_position << ", last_position" << last_position;
522
523 }
524 }
525 previous_token=token;
526 }
527
528}
529
530
532{
533// ??OME2 for (SegmentationData::const_iterator it=tb->begin(),it_end=tb->end();
534 for (std::vector<Segment>::const_iterator it=(tb->getSegments()).begin(),
535 it_end=(tb->getSegments()).end();
536 it!=it_end; it++)
537 {
538 if ((*it).getLastVertex() == v) return true;
539 }
540 return false;
541}
542
544{
545 // OME
547 // OME
548 LDEBUG << "is_specific_entity at " << v << " according to annot?";
549 std::set< AnnotationGraphVertex > matches = annotationData->matches(m_graphId,v,"annot");
550 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
551 it != matches.end(); it++)
552 {
553// AnnotationGraphVertex vx=*it;
554
555 if (annotationData->hasAnnotation(*it, Common::Misc::utf8stdstring2limastring("SpecificEntity")))
556 {
557 LDEBUG << " ...return true";
558 return true;
559 }
560 }
561 LDEBUG << " ...return false";
562 return false;
563}
564
566{
568 std::set< AnnotationGraphVertex > matches = annotationData->matches(m_graphId,v,"annot");
569
570 // OME
571 std::string entityName = Common::Misc::limastring2utf8stdstring(
573 LDEBUG << "is_specific_entity(" << entityName << " at " << v << " ) ?";
574
575 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
576 it != matches.end(); it++)
577 {
579 // OME
580 LDEBUG << "Looking at annotation graph vertex " << vx << " for " << entityName;
581
582 if (annotationData->hasAnnotation(vx, Common::Misc::utf8stdstring2limastring("SpecificEntity")))
583 {
584 EntityType e;
585 e=annotationData->annotation(vx,Common::Misc::utf8stdstring2limastring("SpecificEntity")).pointerValue< SpecificEntityAnnotation>()->getType();
586 if (e==t) {
587 // OME
588 LDEBUG << "is_specific_entity(" << entityName << " at " << v << " ) return true";
589 return true;
590 }
591
592 }
593 }
594 // OME
595 LDEBUG << "is_specific_entity(" << entityName << " at " << v << " ) return false";
596 return false;
597}
598
601 ,std::string graphId) const
602{
604 std::set< AnnotationGraphVertex > matches = annotationData->matches(graphId,v,"annot");
605 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
606 it != matches.end(); it++)
607 {
609
610 if (annotationData->hasAnnotation(vx, Common::Misc::utf8stdstring2limastring("SpecificEntity")))
611 {
612
613 e=annotationData->annotation(vx,Common::Misc::utf8stdstring2limastring("SpecificEntity")).pointerValue< SpecificEntityAnnotation>()->getType();
614 return e;
615 }
616 }
617 return e;
618}
619
621{
623 std::string normalizedForm="00-00-00";
624 std::string year="00";
625 std::string month="00";
626 std::string day="00";
627
628 std::set< AnnotationGraphVertex > matches = annotationData->matches(m_graphId,v,"annot");
629 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
630 it != matches.end(); it++)
631 {
633 LDEBUG << "Looking at annotation graph vertex " << vx;
634
635 if (annotationData->hasAnnotation(vx, Common::Misc::utf8stdstring2limastring("SpecificEntity")))
636 {
637
638
639 EntityType e;
640 e=annotationData->annotation(vx,Common::Misc::utf8stdstring2limastring("SpecificEntity")).pointerValue< SpecificEntityAnnotation>()->getType();
641 if (e == t)
642 {
643 EntityFeatures features;
644 features=annotationData->annotation(vx,Common::Misc::utf8stdstring2limastring("SpecificEntity")).pointerValue< SpecificEntityAnnotation>()->getFeatures();
645 for (Automaton::EntityFeatures::const_iterator
646 featureItr=features.begin(),features_end=features.end();
647 featureItr!=features_end; featureItr++)
648 {
649 LDEBUG << "Looking for feature=" << featureItr->getName() << ", value=" << featureItr->getValueString();
650 if (featureItr->getName().compare("date") == 0)
651 return (featureItr->getValueString());
652 if (featureItr->getName().compare("year") == 0)
653 year=featureItr->getValueString();
654 if (featureItr->getName().compare("month") == 0)
655 month=featureItr->getValueString();
656 if (featureItr->getName().compare("day") == 0)
657 day=featureItr->getValueString();
658 }
659 }
660 }
661 }
662 normalizedForm= year;
663 normalizedForm.insert(normalizedForm.end(),'-');
664 normalizedForm.append(month);
665 normalizedForm.insert(normalizedForm.end(),'-');
666 normalizedForm.append(day);
667 LDEBUG << "Returned normalizedForm = " << normalizedForm;
668 return (normalizedForm);
669}
670
671bool EventAnalyzer::is_specific_entity_in(LinguisticGraphVertex v,AnnotationData* annotationData,set<EntityType> eset) const
672{
674 // OME
675 LDEBUG << "is_specific_entity_in( at " << v << " ) ?";
676 std::set< AnnotationGraphVertex > matches = annotationData->matches(m_graphId,v,"annot");
677 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
678 it != matches.end(); it++)
679 {
681 // OME
682 LDEBUG << "Looking at annotation graph vertex " << vx;
683
684 if (annotationData->hasAnnotation(vx, Common::Misc::utf8stdstring2limastring("SpecificEntity")))
685 {
686 EntityType e;
687 e=annotationData->annotation(vx,Common::Misc::utf8stdstring2limastring("SpecificEntity")).pointerValue< SpecificEntityAnnotation>()->getType();
688 if (eset.find(e)!=eset.end())
689 {
690 LDEBUG << "is_specific_entity_in( at " << v << " ) return true";
691 return true;
692 }
693 }
694 }
695 // OME
696 LDEBUG << "is_specific_entity_in( at " << v << " ) return false";
697 return false;
698}
699
700} // closing namespace EventAnalysis
701} // closing namespace LinguisticProcessing
702} // closing namespace Lima
#define EVENTANALYZERPU_CLASSID
#define LDEBUG
Definition LimaCommon.h:157
#define LERROR
Definition LimaCommon.h:161
@ vertex_token
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
LinguisticGraph::out_edge_iterator LinguisticGraphOutEdgeIt
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
#define EVENTANALYZERLOGINIT
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
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::set< AnnotationGraphVertex > matches(const std::string &first, AnnotationGraphVertex firstVx, const std::string &second) const
Gets the set of vertices matched in the second graph by the given vertex of the first graph.
const GenericAnnotation & annotation(AnnotationGraphVertex v1, AnnotationGraphVertex v2, const LimaString &annot) const
EntityType getEntityType(const LimaString &entityName) const
entity types manager
std::deque< std::string > & getListsValueAtKey(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
a list of generic features: each feature is unique (only one feature for a name)
void compute_paragraphs(std::vector< Paragraph * > &, LinguisticGraph *, LinguisticAnalysisStructure::AnalysisGraph *, SegmentationData *, SegmentationData *, Common::AnnotationGraphs::AnnotationData *) const
bool is_specific_entity(LinguisticGraphVertex, Common::AnnotationGraphs::AnnotationData *) const
void compute_events(std::map< std::string, Event * > &, std::vector< Paragraph * >, LinguisticGraph *, Common::AnnotationGraphs::AnnotationData *, std::string) const
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
std::string getDate(LinguisticGraphVertex, Common::AnnotationGraphs::AnnotationData *, Common::MediaticData::EntityType) const
LimaStatusCode process(AnalysisContent &analysis) const override
bool is_specific_entity_in(LinguisticGraphVertex, Common::AnnotationGraphs::AnnotationData *, std::set< Common::MediaticData::EntityType >) const
Common::MediaticData::EntityType getEntityType(LinguisticGraphVertex, Common::AnnotationGraphs::AnnotationData *, std::string graphId) const
bool is_a_bound(LinguisticGraphVertex, SegmentationData *) const
This class represents a list of elements, that are pointers on polymmorphic annotations that can be d...
Definition Event.h:44
void setDate(std::pair< Common::MediaticData::EntityType, std::pair< std::string, LinguisticGraphVertex > >)
Definition Event.h:99
void addParagraph(Paragraph *, bool, bool, Common::AnnotationGraphs::AnnotationData *, std::string graphId, LinguisticGraph *graph)
Definition Event.cpp:130
void compute_entities_weight(std::map< Common::MediaticData::EntityType, unsigned short >, Common::AnnotationGraphs::AnnotationData *, std::string graphId)
Definition Event.cpp:83
This class represents a list of elements, that are pointers on polymmorphic annotations that can be d...
Definition Paragraph.h:45
std::pair< std::string, LinguisticGraphVertex > extractDate()
Definition Paragraph.h:104
std::map< Common::MediaticData::EntityType, std::deque< LinguisticGraphVertex > > extractEntitiesBeforeVertex(LinguisticGraphVertex v, LinguisticGraph *graph)
Definition Paragraph.cpp:90
std::pair< std::string, LinguisticGraphVertex > getDate()
Definition Paragraph.h:99
std::pair< Common::MediaticData::EntityType, std::deque< LinguisticGraphVertex > > extractEventEntitiesBeforeVertex(LinguisticGraphVertex v, LinguisticGraph *graph)
Definition Paragraph.cpp:51
void addDate(std::string, LinguisticGraphVertex)
Definition Paragraph.h:174
An AnalysisData containing a LinguisticGraph with a language and an id.
const LinguisticGraphVertex & lastVertex(void) const
Returns the last vertex of the graph.
const LinguisticGraphVertex & firstVertex(void) const
Returns the first vertex of the graph.
const std::vector< Segment > & getSegments() const
static const MediaticData & single()
const singleton accessor
Definition Singleton.h:51
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
AnnotationGraph::vertex_descriptor AnnotationGraphVertex
bool hasAnnotation(AnnotationGraphVertex v, const LimaString &annot) const
std::string limastring2utf8stdstring(const Lima::LimaString &phrase, uint32_t size0)
Convert a wide string to a string , in dest up to size bytes.
LimaString utf8stdstring2limastring(const std::string &src)
SimpleFactory< MediaProcessUnit, EventAnalyzer > EventAnalyzerFactory(EVENTANALYZERPU_CLASSID)
NAUTITIA.
LimaStatusCode
Definition LimaCommon.h:236
@ SUCCESS_ID
Definition LimaCommon.h:237
@ MISSING_DATA
Definition LimaCommon.h:243
STL namespace.
static const struct TextHtmlEntity entities[]