30using namespace boost::tuples;
41namespace LinguisticProcessing {
42namespace EventAnalysis {
65 LERROR <<
"No segmentationData specified in "<<unitConfiguration.
getName()
66 <<
" configuration group for language " << language;
75 LERROR <<
"No segmentType specified in "<<unitConfiguration.
getName()
76 <<
" configuration group for language " << language;
82 for(deque<string>::iterator it=
entities.begin(),it_end=
entities.end();it!=it_end;it++)
88 LERROR <<
"Error: unknown entity type '"<< *it <<
"' : ignored";
94 LERROR <<
"No entities specified in "<<unitConfiguration.
getName()
95 <<
" configuration group for language " << language;
104 LDEBUG <<
"start SimpleEventBuilder";
107 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.
getData(
"AnnotationData"));
108 if (annotationData==0)
110 LERROR <<
"no annotation graph available !";
115 auto data = analysis.
getData(m_segmData);
117 LERROR <<
"Missing data '" << m_segmData <<
"'";
120 auto segmData = std::dynamic_pointer_cast<SegmentationData>(data);
123 LERROR <<
"Failed to interpret data '" << m_segmData <<
"' as SegmentationData";
128 string graphId=segmData->getGraphId();
129 auto graph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(graphId));
131 LERROR <<
"Cannot get graph '" << graphId <<
"' (from segmentation data)";
136 LDEBUG <<
"set new data EventData of type EventData";
137 analysis.
setData(
"EventData", eventData);
142 for (std::vector<Segment>::const_iterator it=(segmData->getSegments()).begin(),it_end=(segmData->getSegments()).end();it!=it_end;it++) {
143 if ((*it).getType()==m_segmentType) {
144 LDEBUG <<
"in segment " << m_segmentType <<
" [" << (*it).getPosBegin() <<
"," << (*it).getLength() <<
"]";
146 getEntitiesFromSegment(
entities, graph.get(), (*it).getFirstVertex(),(*it).getLastVertex(), annotationData.get());
153 LDEBUG <<
"ignored segment " << (*it).getType();
160 it_end=
entities.end();it!=it_end;it++) {
161 if ((*it).second.size()!=0) {
163 LDEBUG <<
"set main for entity of type " << (*it).first <<
" at pos " << (*it).second[0].getPosition();
165 (*it).second[0].setMain(
true);
181 std::queue<LinguisticGraphVertex> toVisit;
182 std::set<LinguisticGraphVertex> visited;
186 toVisit.push(firstVertex);
190 while (!toVisit.empty()) {
196 if (v == lastVertex) {
200 for (boost::tie(outItr,outItrEnd)=out_edges(v,*graph); outItr!=outItrEnd; outItr++)
203 if (visited.find(next)==visited.end())
205 visited.insert(next);
232 std::set< AnnotationGraphVertex > matches = annotationData->
matches(graph->
getGraphId(),v,
"annot");
233 LDEBUG <<
"vertex " << v <<
" has " << matches.size() <<
" annotations";
234 for (std::set< AnnotationGraphVertex >::const_iterator it = matches.begin();
235 it != matches.end(); it++)
243 pointerValue<SpecificEntityAnnotation>();
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
#define SIMPLEEVENTBUILDER_CLASSID
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
std::string & getParamsValueAtKey(const std::string &key)
std::deque< std::string > & getListsValueAtKey(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
The main LIMA exception class.
std::map< Common::MediaticData::EntityType, std::vector< Entity > > & getEntities()
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.
An AnalysisData containing a LinguisticGraph with a language and an id.
const std::string & getGraphId(void) const
const LinguisticGraphVertex & lastVertex(void) const
Returns the last vertex of the graph.
const LinguisticGraph * getGraph(void) const
Returns the underlying graph structure.
A representation of a specific entity to store in the annotation graph.
const Automaton::EntityFeatures & getFeatures() const
uint64_t getLength() const
Common::MediaticData::EntityType getType() const
uint64_t getPosition() const
static const MediaticData & single()
const singleton accessor
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
LimaString utf8stdstring2limastring(const std::string &src)
SimpleFactory< MediaProcessUnit, SimpleEventBuilder > SimpleEventBuilderFactory(SIMPLEEVENTBUILDER_CLASSID)
static const struct TextHtmlEntity entities[]