32namespace LinguisticProcessing {
33namespace SyntacticAnalysis {
37 out <<
"start displaying chains" << endl;
39 std::list< std::pair< LinguisticGraphVertex, ChainIdStruct > > startPoints;
40 std::list< LinguisticGraphVertex > toLookAt;
41 std::set< LinguisticGraphVertex > alreadyVisited;
44 while (! toLookAt.empty() )
48 if (alreadyVisited.find(current) != alreadyVisited.end())
52 alreadyVisited.insert(current);
54 LDEBUG <<
"looking at " << current;
56 for (set<ChainIdStruct>::iterator chainItr=chains.begin();
57 chainItr!=chains.end();
63 startPoints.push_back(std::make_pair(current, chain));
67 boost::tie(it,itEnd)=out_edges(current,*graph);
70 toLookAt.push_back(target(*it,*graph));
73 std::list< std::pair<LinguisticGraphVertex, ChainIdStruct> >::iterator startPointsItr, startPointsItr_end;
74 startPointsItr = startPoints.begin(); startPointsItr_end = startPoints.end();
75 std::set< ChainIdStruct > alreadyDisplayed;
76 for (; startPointsItr != startPointsItr_end; startPointsItr++)
78 if (alreadyDisplayed.find((*startPointsItr).second) == alreadyDisplayed.end())
80 displayChain((*startPointsItr).second, (*startPointsItr).first, anagraph, out);
81 alreadyDisplayed.insert((*startPointsItr).second);
155 out <<
"end display chains" << endl;
165 out <<
"Chain " << chain <<
"\t";
167 auto currentVx = start;
170 while (currentVx!=lastVx)
174 if ( (token != 0) && (data != 0) && (!data->empty()) )
176 <<
"[" << currentVx <<
"]{"
177 << data->begin()->properties <<
"} ";
180 <<
"[" << currentVx <<
"]{NA} ";
181 boost::tie(it, itEnd) = out_edges(currentVx,*graph);
183 for (;it!=itEnd;it++)
186 if (chains.find(chain) != chains.end())
188 currentVx = target(*it,*graph);
198 const MediaId language,
200 const bool DisplayLemma)
203 out <<
"start display dependency graph : " << endl;
209 boost::tie(it,itEnd)=edges(*depGraph);
210 for (;it!=itEnd;it++)
226 if ( (token != 0) && (currentData != 0) && (!currentData->empty()) )
228 if (DisplayLemma ==
true)
230 <<
"[" << src <<
"|" << s <<
"]{"
231 << currentData->begin()->properties <<
"} ";
235 <<
"[" << src <<
"|" << s <<
"]{"
236 << currentData->begin()->properties <<
"} ";
240 <<
"[" << src <<
"|" << s <<
"]{NA} ";
244 if ( (token != 0) && (currentData != 0) && (!currentData->empty()) )
246 if (DisplayLemma ==
true)
248 <<
"[" << targ <<
"|" << t <<
"]{"
249 << currentData->begin()->properties <<
"} ";
253 <<
"[" << targ <<
"|" << t <<
"]{"
254 << currentData->begin()->properties <<
"} ";
258 <<
"[" << targ <<
"|" << t <<
"]{NA} ";
262 out <<
"end display dependency graph" << endl;
268 const MediaId language,
276 boost::tie(it,itEnd)=edges(*depGraph);
277 for (;it!=itEnd;it++) {
293 if (srcData==0 || tgtData==0 || srcToken==0 || tgtToken==0) {
297 uint64_t srcPosition=srcToken->
position();
298 uint64_t tgtPosition=tgtToken->
position();
300 string srcMacroCat,tgtMacroCat,srcMicroCat,tgtMicroCat;
317 if (srcPosition>tgtPosition) {
319 out <<
"TARGET:" << tgtMacroCat <<
"/" << tgtMicroCat <<
" "
320 <<
"SOURCE:" << srcMacroCat <<
"/" << srcMicroCat << endl;
324 out <<
"SOURCE:" << srcMacroCat <<
"/" << srcMicroCat <<
" "
325 <<
"TARGET:" << tgtMacroCat <<
"/" << tgtMicroCat << endl;
332 const MediaId language,
339 boost::tie(it,itEnd)=edges(*depGraph);
340 for (;it!=itEnd;it++) {
354 string srcMacroCat,tgtMacroCat,srcMicroCat,tgtMicroCat;
371 out << srcMacroCat <<
"/" << srcMicroCat <<
" "
372 << tgtMacroCat <<
"/" << tgtMicroCat <<
" ";
377 uint64_t srcPosition=srcToken->
position();
378 uint64_t tgtPosition=tgtToken->
position();
379 uint64_t srcLength=srcToken->
length();
380 uint64_t tgtLength=tgtToken->
length();
382 if (srcPosition>tgtPosition+tgtLength) {
384 out << srcPosition-(tgtPosition+tgtLength);
386 else if (tgtPosition>srcPosition+srcLength) {
388 out << tgtPosition-(srcPosition+srcLength);
400 const MediaId language,
401 std::ostream& xmlStream)
406 xmlStream <<
"<syntactic_relations>" << std::endl;
409 boost::tie(it,itEnd)=edges(*depGraph);
410 for (;it!=itEnd;it++) {
427 string srcMacroCat,tgtMacroCat,srcMicroCat,tgtMicroCat;
446 uint64_t srcPosition=srcToken->
position();
447 uint64_t tgtPosition=tgtToken->
position();
448 uint64_t srcLength=srcToken->
length();
449 uint64_t tgtLength=tgtToken->
length();
453 uint64_t pathDistance=0;
455 if (srcPosition>tgtPosition+tgtLength) {
457 pathDistance = srcPosition-(tgtPosition+tgtLength);
459 else if (tgtPosition>srcPosition+srcLength) {
461 pathDistance = tgtPosition-(srcPosition+srcLength);
468 xmlStream <<
"<syntactic_relation label=\"" << relLabel <<
"\"" <<
" dist=\"" << pathDistance<<
"\">"
469 <<
"<source position=\"" << srcPosition
470 <<
"\" length=\"" << srcLength
471 <<
"\" string=\"" << scrString
472 <<
"\" pos_cat=\"" << srcMicroCat
474 <<
"<target position=\"" << tgtPosition
475 <<
"\" length=\"" << tgtLength
476 <<
"\" string=\"" << tgtString
477 <<
"\" pos_cat=\"" << tgtMicroCat
479 <<
"</syntactic_relation>" << endl;
481 xmlStream <<
"</syntactic_relations>" << std::endl;
Lima::Common::MediaticData::SyntacticRelationId DepRelTypeProp
Property to identify the chain of the tokens graph concerned by the relation.
DependencyGraph::edge_iterator DependencyGraphEdgeIt
DependencyGraph::vertex_descriptor DependencyGraphVertex
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, DepVertexProperties, DepEdgeProperties > DependencyGraph
The dependency graph class.
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 CORECLIENTLOGINIT
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.
const std::string & getPropertySymbolicValue(const LinguisticCode &value) const
The coded property value can hold several property data.
const PropertyAccessor & getPropertyAccessor() const
give the corresponding PropertyAccessor
The main LIMA exception class.
virtual const char * what() const override
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.
Property to identify the chains in the graph.
ChainElemType elemType() const
Holds morphosyntactic informations.
LinguisticCode firstValue(const Common::PropertyCode::PropertyAccessor &propertyAccessor) const
Return the first non empty value for the given accessor.
holds surface data of a token
uint64_t position() const
const LimaString & stringForm() const
This class points to a graph, its dependency graph and the structure that holds the maping between th...
LinguisticGraphVertex tokenVertexForDepVertex(const DependencyGraphVertex &v) const
LinguisticGraph * graph()
DependencyGraph * dependencyGraph()
static const MediaticData & single()
const singleton accessor
std::string limastring2utf8stdstring(const Lima::LimaString &phrase, uint32_t size0)
Convert a wide string to a string , in dest up to size bytes.