25namespace LinguisticProcessing
45 uint64_t m_depGraphMaxBranchingFactor;
47 std::map< std::string, Lima::Common::MediaticData::ConceptType > m_conceptTypes;
48 std::map< Lima::Common::MediaticData::ConceptType, std::string > m_conceptNames;
50 std::map< LinguisticCode, Lima::Common::MediaticData::ConceptType > m_macro2ConceptMapping;
51 std::set< std::string > m_compoundsRels;
54CompoundsBuilderFromSyntacticDataPrivate::CompoundsBuilderFromSyntacticDataPrivate()
58CompoundsBuilderFromSyntacticDataPrivate::~CompoundsBuilderFromSyntacticDataPrivate()
80 m_d->initConceptTypes(unitConfiguration);
81 m_d->initCompoundRels(unitConfiguration);
82 m_d->initMacros2ConceptsMapping(unitConfiguration);
85void CompoundsBuilderFromSyntacticDataPrivate::initCompoundRels(
89 LINFO <<
"init compounds relations";
93 std::deque< std::string > compoundsRelsList = unitConfiguration.
getListsValueAtKey(
"CompoundsRels");
94 m_compoundsRels.insert(compoundsRelsList.begin(), compoundsRelsList.end());
98 LERROR <<
"No list 'CompoundsRels' in 'SyntacticAnalysis' group for language " << (int)m_language;
103 LERROR <<
"No group 'SyntacticAnalysis' in common language configuration file for language " << (int)m_language;
110 return (m_d->m_compoundsRels.find(rel) != m_d->m_compoundsRels.end());
113void CompoundsBuilderFromSyntacticDataPrivate::initConceptTypes(
118 LINFO <<
"CompoundsBuilderFromSyntacticDataPrivate::initConceptTypes";
123 const auto& mapping= unitConfiguration.
getMapAtKey(
"conceptTypes");
124#if __cplusplus >= 201703L
125 for (
const auto& [key, val] : mapping)
128 for (std::map<std::string,std::string>::const_iterator it=mapping.begin();
132 const std::string key = it->first;
133 const std::string val = it->second;
135 auto type =
static_cast<Lima::Common::MediaticData::ConceptType
>(atoi(val.c_str()));
137 LDEBUG <<
"read concept type " << key.c_str() <<
" -> " << type;
139 m_conceptTypes[key] = type;
140 m_conceptNames[type] = key;
147 LERROR <<
"No map 'conceptTypes' in configuration file:" << e.
what();
154 if (m_d->m_conceptTypes.find(typeName)==m_d->m_conceptTypes.end())
157 LERROR <<
"Concept type name " << typeName.c_str() <<
" not found. Returning value for LatticeDown (should be '0').";
158 return (*(m_d->m_conceptTypes.find(
"LatticeDown"))).second;
162 return (*(m_d->m_conceptTypes.find(typeName))).second;
169 if (m_d->m_conceptNames.find(type)==m_d->m_conceptNames.end())
172 LERROR <<
"Concept type " << type <<
" not found. Returning for 0 (should be 'LatticeDown').";
173 return (*(m_d->m_conceptNames.find(
static_cast<Lima::Common::MediaticData::ConceptType
>(0)))).second;
177 return (*(m_d->m_conceptNames.find(type))).second;
181void CompoundsBuilderFromSyntacticDataPrivate::initMacros2ConceptsMapping(
186 LDEBUG <<
"Initializing macro to concepts mapping:";
190 const std::map<std::string,std::string>& mapping = macro2ConceptsGroup.
getMapAtKey(
"Macros2ConceptTypes");
198 for(
auto it = mapping.begin(), it_end = mapping.end(); it != it_end; it++)
201 std::string typeName = (*it).second;
202 Lima::Common::MediaticData::ConceptType semanticConcept = (*(m_conceptTypes.find(
"LatticeDown"))).second;
203 if (m_conceptTypes.find(typeName) == m_conceptTypes.end())
206 LERROR <<
"Concept type name " << typeName.c_str() <<
" not found. Keeping LatticeDown (should be '0').";
210 semanticConcept = (*(m_conceptTypes.find(typeName))).second;
214 LDEBUG <<
" " << (*it).first <<
" (" << macro <<
") <-> "
215 << (*it).second <<
" (" << semanticConcept <<
")";
217 m_macro2ConceptMapping.insert(std::make_pair(macro, semanticConcept));
224 LERROR <<
"No map 'Macros2ConceptTypes' for group 'SemanticData' in common "
225 "language configuration file for language " << m_language;
231 LERROR <<
"No group 'SemanticData' in common language configuration file "
232 "for language " << m_language;
242 LDEBUG <<
"CompoundsBuilderFromSyntacticData::getConceptForMacro" << macro;
247 if (m_d->m_macro2ConceptMapping.find(macro) == m_d->m_macro2ConceptMapping.end())
251 LDEBUG <<
"CompoundsBuilderFromSyntacticData::getConceptForMacro" << macro <<
"not found. Returning for" <<
SYMBOLIC_NONE_1 <<
"(should be 0, 'LatticeDown').";
255 if (m_d->m_macro2ConceptMapping.find(none) == m_d->m_macro2ConceptMapping.end())
259 LDEBUG <<
"SYMBOLIC_NONE_1 Not found !!! Returning 0";
261 return static_cast<Lima::Common::MediaticData::ConceptType
>(0);
266 LDEBUG <<
"SYMBOLIC_NONE_1 Found !!! Returning " << (*(m_d->m_macro2ConceptMapping.find(none))).second;
268 return (*(m_d->m_macro2ConceptMapping.find(none))).second;
274 LDEBUG <<
"CompoundsBuilderFromSyntacticData::getConceptForMacro Found !!! Returning " << (*(m_d->m_macro2ConceptMapping.find(macro))).second;
276 return (*(m_d->m_macro2ConceptMapping.find(macro))).second;
287 LDEBUG <<
"CompoundsBuilderFromSyntacticData::process : start";
290 auto tmp=analysis.
getData(
"SyntacticData");
293 LERROR <<
"Can't Process CompoundsBuilderFromSyntacticData : missing data 'SyntacticData'";
296 auto data = std::dynamic_pointer_cast<SyntacticData>(tmp);
298 tmp = analysis.
getData(
"PosGraph");
301 LERROR <<
"Can't Process CompoundsBuilderFromSyntacticData : missing data 'AnalysisGraph'";
304 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(tmp);
306 tmp=analysis.
getData(
"SentenceBoundaries");
309 LERROR <<
"can't process CompoundsBuilderFromSyntacticData : missing SentenceBounds !";
312 auto sb = std::dynamic_pointer_cast<SegmentationData>(tmp);
313 if (sb->getGraphId() !=
"PosGraph") {
314 LERROR <<
"SentenceBounds have been computed on " << sb->getGraphId() <<
" !";
315 LERROR <<
"SyntacticAnalyzer-deps needs SentenceBounds on PosGraph";
318 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.
getData(
"AnnotationData"));
319 if (annotationData==0)
321 annotationData = std::make_shared<AnnotationData>();
322 if (std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"AnalysisGraph")) != 0)
324 std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"AnalysisGraph"))->populateAnnotationGraph(
325 annotationData.get(),
"AnalysisGraph");
327 if (std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"PosGraph")) != 0)
329 std::dynamic_pointer_cast<AnalysisGraph>(analysis.
getData(
"PosGraph"))->populateAnnotationGraph(
330 annotationData.get(),
"PosGraph");
333 analysis.
setData(
"AnnotationData",annotationData);
341 for (
const auto& bound: sb->getSegments())
347 LDEBUG <<
"process sentence from " << beginSentence <<
" to " << endSentence;
353 data->dependencyGraph() ,
357 annotationData.get());
363 std::set<LinguisticGraphVertex> visited;
364 std::queue<LinguisticGraphVertex> toVisit;
365 toVisit.push(beginSentence);
368 while (!toVisit.empty())
379 if (v == endSentence) {
383 for (boost::tie(outItr,outItrEnd)=out_edges(v,graph);
388 if (visited.find(next)==visited.end())
390 visited.insert(next);
This file is the main header file for the data related to annotation graphs.
#define COMPOUNDSBUILDERFROMSYNTACTICDATAFACTORY_CLASSID
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.
Defines a Factory to create Object of type Base.
Data used for the syntactic analyzis of texts.
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.
Provide tools to parse a property file, and deal with the property coding system.
const PropertyManager & getPropertyManager(const std::string &propertyName) const
Get the PropertyManager associated to a property.
Provide tools to manage a specific property.
LinguisticCode getPropertyValue(const std::string &symbolicValue) const
Get the coded property value from the symbolic value.
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 'group' was not found
return a message when a 'list' was not found
return a message when a 'map' 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.
virtual const char * what() const override
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.
virtual ~CompoundsBuilderFromSyntacticData()
bool isACompoundRel(const std::string &rel) const
const std::string & getConceptName(const Lima::Common::MediaticData::ConceptType &type) const
Lima::Common::MediaticData::ConceptType getConceptType(const std::string &typeName) const
CompoundsBuilderFromSyntacticData()
Lima::Common::MediaticData::ConceptType getConceptForMacro(const LinguisticCode ¯o) const
void discover_vertex(LinguisticGraphVertex v)
static const MediaticData & single()
const singleton accessor
This file contains a class to control log of informations about time, such as logging cumulated time ...
SimpleFactory< MediaProcessUnit, CompoundsBuilderFromSyntacticData > compoundsBuilderFromSyntacticDataFactory(COMPOUNDSBUILDERFROMSYNTACTICDATAFACTORY_CLASSID)