LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
HomoSyntagmaticConstraints.cpp
Go to the documentation of this file.
1// Copyright 2002-2020 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
10// clazy:exclude=rule-of-two-soft
11
13#include "DependencyGraph.h"
14#include "SyntacticData.h"
15#include "SyntagmaticMatrix.h"
16
28
29#include <string>
30#include <map>
31#include <queue>
32#include <QtCore/QStringList>
33#include <QtCore/QRegularExpression>
34
35//using namespace boost;
36using namespace Lima::Common;
37using namespace Lima::Common::AnnotationGraphs;
38using namespace Lima::Common::MediaticData;
39using namespace Lima::Common::Misc;
40using namespace Lima::Common::PropertyCode;
43
44namespace Lima
45{
47{
48namespace SyntacticAnalysis
49{
50
51//**********************************************************************
52// factories for constraint functions defined in this file
53Automaton::ConstraintFunctionFactory<SecondUngovernedBy>
55
58
61
64
67
70
73
76
79
82
85
88
91
94
97
100
103
106
107//**********************************************************************
109 MediaId language,
110 const LimaString& complement):
111 ConstraintFunction(language,complement),
112 m_relation(0)
113{
114// SAPLOGINIT;
115 if (! complement.isEmpty())
116 {
117 std::string str=limastring2utf8stdstring(complement);
118 if (str == "ANY")
119 {
120 m_relation=0; // default value=0
121 }
122 else
123 {
124 m_relation=static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(language)).getSyntacticRelationId(str);
125 if (m_relation == 0)
126 {
127 SALOGINIT;
128 LIMA_EXCEPTION( "undefined syntactic relation [" << str.c_str() << "]" );
129 }
130 }
131 }
132// LDEBUG << "ConstraintWithRelationComplement::ConstraintWithRelationComplement" << language << complement << m_relation;
133}
134
135//**********************************************************************
137 MediaId language,
138 const LimaString& complement):
139 ConstraintWithRelationComplement(language,complement)
140{}
141
144 const LinguisticGraphVertex& v1,
145 const LinguisticGraphVertex& v2,
146 AnalysisContent& analysis ) const
147{
148#ifdef DEBUG_LP
150 LDEBUG << "testing SecondUngovernedBy for " << v1 << " and " << v2 << " with relation: " << m_relation;
151#endif
152
153 auto syntacticData = std::dynamic_pointer_cast<const SyntacticData>(analysis.getData("SyntacticData"));
154
155 if (v1 == graph.firstVertex() || v1 == graph.lastVertex() ||
156 v2 == graph.firstVertex() || v2 == graph.lastVertex() )
157 {
158// LDEBUG << "SecondUngovernedBy: false";
159 return false;
160 }
161 CEdgeDepRelTypePropertyMap map = get(edge_deprel_type, *(syntacticData-> dependencyGraph()));
162 DependencyGraphVertex dv1 = syntacticData->depVertexForTokenVertex(v1);
163 DependencyGraphVertex dv2 = syntacticData->depVertexForTokenVertex(v2);
164 DependencyGraphOutEdgeIt it, it_end;
165
166 // Modif YJE 2007-07-13
167 // On ne peut pas utiliser edge_range pour trouver les arcs entre
168 // dv1 et dv2 car le conteneur stockant les arcs dans le graphe
169 // n'est pas ordonné.
170 // Il faut donc parcourir tous les arcs sortant de dv1, et filtrer
171 // ceux entrant dans dv2.
172 // std::tie(it, it_end) = edge_range(dv1, dv2, *(syntacticData-> dependencyGraph()));
173 auto g = syntacticData-> dependencyGraph();
174 std::tie(it, it_end) = out_edges(dv1, *g);
175 for (; it != it_end; it++)
176 {
177 // Modif YJE 2007-07-13
178 // On ne garde que les arcs entrant dans dv2.
179 if(target(*it, *g) != dv2)
180 continue;
181
182 if ( (map[*it] == m_relation)
183 || (m_relation == 0) )
184 {
185// LDEBUG << "SecondUngovernedBy: false";
186 return false;
187 }
188 }
189 // LDEBUG << "SecondUngovernedBy: true";
190 return true;
191}
192
193GovernorOf::GovernorOf(MediaId language,
194 const LimaString& complement):
195 ConstraintWithRelationComplement(language,complement)
196{
197 // ConstraintFunction::addFunction("GovernorOf",this);
198}
199
201 const LinguisticGraphVertex& v1,
202 AnalysisContent& analysis) const
203{
204#ifdef DEBUG_LP
206 LDEBUG << "testing GovernorOf for " << v1 << " with relation : " << m_relation;
207#endif
208
209 auto syntacticData = std::dynamic_pointer_cast<const SyntacticData>(analysis.getData("SyntacticData"));
210
211 if (v1 == graph.firstVertex() || v1 == graph.lastVertex() )
212 {
213// LDEBUG << "GovernorOf: false";
214 return false;
215 }
216 CEdgeDepRelTypePropertyMap map = get(edge_deprel_type, *(syntacticData-> dependencyGraph()));
217 DependencyGraphVertex dv1 = syntacticData-> depVertexForTokenVertex(v1);
218 DependencyGraphOutEdgeIt it, it_end;
219 std::tie(it, it_end) = out_edges(dv1, *(syntacticData-> dependencyGraph()));
220 for (; it != it_end; it++)
221 {
222 if ( (map[*it] == m_relation)
223 || (m_relation == 0) )
224 {
225// LDEBUG << "GovernorOf: true";
226 return true;
227 }
228 }
229// LDEBUG << "GovernorOf: false";
230 return false;
231}
232
233
234GovernedBy::GovernedBy(MediaId language,
235 const LimaString& complement):
236 ConstraintWithRelationComplement(language,complement)
237{
238 // ConstraintFunction::addFunction("GovernedBy",this);
239}
240
242 const LinguisticGraphVertex& v1,
243 AnalysisContent& analysis) const
244{
245#ifdef DEBUG_LP
247 LDEBUG << "testing GovernedBy for " << v1 << " with relation: " << m_relation;
248#endif
249 auto syntacticData = std::dynamic_pointer_cast<const SyntacticData>(analysis.getData("SyntacticData"));
250 if (v1 == graph.firstVertex() || v1 == graph.lastVertex() )
251 {
252// LDEBUG << "GovernedBy: false";
253 return false;
254 }
255 CEdgeDepRelTypePropertyMap map = get(edge_deprel_type, *(syntacticData-> dependencyGraph()));
256 DependencyGraphVertex dv1 = syntacticData-> depVertexForTokenVertex(v1);
257 DependencyGraphInEdgeIt it, it_end;
258 std::tie(it, it_end) = in_edges(dv1, *(syntacticData-> dependencyGraph()));
259 for (; it != it_end; it++)
260 {
261 if ( (map[*it] == m_relation)
262 || (m_relation == 0) )
263 {
264// LDEBUG << "GovernedBy: true";
265 return true;
266 }
267 }
268
269// LDEBUG << "GovernedBy: false";
270 return false;
271}
272
274 const LimaString& complement):
275 ConstraintFunction(language,complement)
276{
277 // no complement
278}
279
283 const LinguisticGraphVertex& v1,
284 const LinguisticGraphVertex& v2,
285 AnalysisContent& /*ac*/) const
286{
287#ifdef DEBUG_LP
289 LDEBUG << "testing SameNominalChain for " << v1 << " and " << v2;
290#endif
291
293 VertexChainIdProp::const_iterator it1 = map[v1].begin();
294 VertexChainIdProp::const_iterator it1_end = map[v1].end();
295
296
297 for (; it1 != it1_end; it1++)
298 {
299 VertexChainIdProp::const_iterator it2 = map[v2].begin();
300 VertexChainIdProp::const_iterator it2_end = map[v2].end();
301 for (; it2 != it2_end; it2++)
302 {
303// LDEBUG << v1 << "/" << v2 << " : " << (*it1) << " =?= " << (*it2);
304 if ( ( (*it1).chainType() == (*it2).chainType() ) &&
305 ( (*it1).chainType() == NOMINAL) &&
306 // ( (*it1).pathId() == (*it2).pathId() ) &&
307 ( (*it1).chainId() == (*it2).chainId() ) )
308 {
309// LDEBUG << " : yes";
310 return true;
311 }
312// LDEBUG << " : no";
313 }
314 }
315 return false;
316
317}
318
320 const LimaString& complement):
321 ConstraintFunction(language,complement)
322{}
323
327 const LinguisticGraphVertex& v1,
328 const LinguisticGraphVertex& v2,
329 AnalysisContent& /*ac*/) const
330{
331#ifdef DEBUG_LP
333 LDEBUG << "testing SameVerbalChain for " << v1 << " and " << v2;
334#endif
336 VertexChainIdProp::const_iterator it1 = map[v1].begin();
337 VertexChainIdProp::const_iterator it1_end = map[v1].end();
338
339 for (; it1 != it1_end; it1++)
340 {
341 VertexChainIdProp::const_iterator it2 = map[v2].begin();
342 VertexChainIdProp::const_iterator it2_end = map[v2].end();
343 for (; it2 != it2_end; it2++)
344 {
345 ChainIdStruct s1 = (*it1);
346 ChainIdStruct s2 = (*it2);
347// LDEBUG << v1 << "/" << v2 << " : " << s1 << " =?= " << s2;
348 if ( ( s1.chainType() == s2.chainType() ) &&
349 ( s1.chainType() == VERBAL ) &&
350 // ( (*it1).pathId() == (*it2).pathId() ) &&
351 ( s1.chainId() == s2.chainId() ) )
352 {
353// LDEBUG << " : return yes";
354 return true;
355 }
356// LDEBUG << " : no";
357 }
358 }
359// LDEBUG << " : return no";
360 return false;
361
362}
363
364
365//**********************************************************************
366
368 MediaId language,
369 const LimaString& complement):
370 ConstraintWithRelationComplement(language,complement)
371{}
372
374 const LinguisticGraphVertex& v1,
375 const LinguisticGraphVertex& v2,
376 AnalysisContent& analysis ) const
377{
378#ifdef DEBUG_LP
380 LDEBUG << "testing CreateRelationBetween for " << v1 << " and "
381 << v2 << " with relation: " << static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(m_language_id)).getSyntacticRelationName(m_relation);
382#endif
383 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
384 bool res = syntacticData->relation(v1, v2, m_relation);
385// LDEBUG << "CreateRelationBetween: " << (res?"yes":"no");
386 return res;
387}
388
389//**********************************************************************
390
392 const LimaString& complement):
393 ConstraintWithRelationComplement(language,complement)
394{
395/*
396 Critical function : comment logging message
397*/
398// SAPLOGINIT;
399// LDEBUG << "RemoveOutRelationFrom::RemoveOutRelationFrom" << language << complement << m_relation;
400}
401
403 const LinguisticGraphVertex& v1,
404 AnalysisContent& analysis) const
405{
406/*
407 Critical function : comment logging message
408*/
409// SAPLOGINIT;
410// LDEBUG << "testing RemoveOutRelationFrom for " << v1 << " with relation: " << m_relation;
411 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
412 if ( v1 == graph.firstVertex() || v1 == graph.lastVertex() )
413 {
414// LDEBUG << "RemoveOutRelationFrom: false";
415 return false;
416 }
417 EdgeDepRelTypePropertyMap map = get(edge_deprel_type, *(syntacticData-> dependencyGraph()));
418 DependencyGraphVertex dv1 = syntacticData-> depVertexForTokenVertex(v1);
419 DependencyGraphOutEdgeIt it, it_end;
420 std::tie(it, it_end) = out_edges(dv1, *(syntacticData-> dependencyGraph()));
421 for (; it != it_end; it++)
422 {
423 if ( map[*it] == m_relation )
424 {
425// LDEBUG << "RemoveOutRelationFrom: remove_edge" << source(*it,*(syntacticData-> dependencyGraph())) << boost::target(*it,*(syntacticData-> dependencyGraph()));
426 boost::remove_edge(source(*it,*(syntacticData-> dependencyGraph())) , boost::target(*it,*(syntacticData-> dependencyGraph())),*(syntacticData-> dependencyGraph()));
427 }
428 }
429
430// LDEBUG << "RemoveOutRelationFrom: true";
431 return true;
432}
433
434
435//**********************************************************************
436
438 const LimaString& complement):
439 Automaton::ConstraintFunction(language,complement),
440 m_relations(complement.split(","))
441{
442/*
443 Critical function : comment logging message
444*/
446 LDEBUG << "CopyRelationsOutOfTo::CopyRelationsOutOfTo" << language << complement << m_relations;
447}
448
450 const LinguisticGraphVertex& v1,
451 const LinguisticGraphVertex& v2,
452 AnalysisContent& analysis) const
453{
454/*
455 Critical function : comment logging message
456*/
458 LDEBUG << "CopyRelationsOutOfTo" << v1 << v2;
459 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
460 if ( v1 == graph.firstVertex() || v1 == graph.lastVertex()
461 || v2 == graph.firstVertex() || v2 == graph.lastVertex() )
462 {
463// LDEBUG << "CopyRelationsOutOfTo: false";
464 return false;
465 }
466 EdgeDepRelTypePropertyMap map = get(edge_deprel_type, *(syntacticData-> dependencyGraph()));
467 DependencyGraphVertex dv1 = syntacticData-> depVertexForTokenVertex(v1);
468 DependencyGraphOutEdgeIt it, it_end;
469 std::tie(it, it_end) = out_edges(dv1, *(syntacticData-> dependencyGraph()));
470 bool res = false;
471 for (; it != it_end; it++)
472 {
473 QString relation = QString::fromUtf8(static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(m_language_id)).getSyntacticRelationName(map[*it]).c_str());
474 LDEBUG << "CopyRelationsOutOfTo" << relation << m_relations;
475 if (m_relations.contains(relation))
476 {
477 LDEBUG << "CopyRelationsOutOfTo copying" << relation;
478 LinguisticGraphVertex target = syntacticData->tokenVertexForDepVertex(boost::target(*it,*(syntacticData-> dependencyGraph())));
479
480 if (syntacticData->relation(v2, target, map[*it]))
481 res = true;
482 }
483 }
484
485 LDEBUG << "CopyRelationsOutOfTo:" << res;
486 return true;
487}
488
489//**********************************************************************
490
492 const LimaString& complement):
493 Automaton::ConstraintFunction(language,complement),
494 m_relations(complement.split(","))
495{
496/*
497 Critical function : comment logging message
498*/
500 LDEBUG << "CopyIncomingRelationsTo::CopyIncomingRelationsTo" << language << complement << m_relations;
501}
502
504 const LinguisticGraphVertex& v1,
505 const LinguisticGraphVertex& v2,
506 AnalysisContent& analysis) const
507{
508/*
509 Critical function : comment logging message
510*/
512 LDEBUG << "CopyIncomingRelationsTo" << v1 << v2;
513 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
514 if ( v1 == graph.firstVertex() || v1 == graph.lastVertex()
515 || v2 == graph.firstVertex() || v2 == graph.lastVertex() )
516 {
517 LDEBUG << "CopyIncomingRelationsTo: false";
518 return false;
519 }
520 EdgeDepRelTypePropertyMap map = get(edge_deprel_type, *(syntacticData-> dependencyGraph()));
521
522 DependencyGraphVertex dv1 = syntacticData-> depVertexForTokenVertex(v1);
523 DependencyGraphInEdgeIt it, it_end;
524 std::tie(it, it_end) = in_edges(dv1, *(syntacticData-> dependencyGraph()));
525 bool res = false;
526 for (; it != it_end; it++)
527 {
528 LinguisticGraphVertex source = syntacticData->tokenVertexForDepVertex(boost::source(*it,*(syntacticData-> dependencyGraph())));
529 QString relation = QString::fromUtf8(static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(m_language_id)).getSyntacticRelationName(map[*it]).c_str());
530 LDEBUG << "CopyIncomingRelationsTo" << relation << m_relations;
531 if (m_relations.contains(relation))
532 {
533 LDEBUG << "CopyIncomingRelationsTo copying" << relation;
534 if (syntacticData->relation(source, v2, map[*it]))
535 res = true;
536 }
537 }
538
539 LDEBUG << "CopyIncomingRelationsTo:" << res;
540 return true;
541}
542
543
544
545//**********************************************************************
546
548 MediaId language,
549 const LimaString& complement):
550 ConstraintWithRelationComplement(language,complement)
551{}
552
554 const LinguisticGraphVertex& v1,
555 AnalysisContent& analysis) const
556{
557/*
558 Critical function : comment logging message
559*/
560// SAPLOGINIT;
561// LDEBUG << "testing FindRelationFRom for " << v1;
562 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
563 DependencyGraph* depGraph=syntacticData->dependencyGraph();
564
565
566 DependencyGraphVertex dv1 = syntacticData->depVertexForTokenVertex(v1);
567 DependencyGraphOutEdgeIt outItr,outItrEnd;
568
569 std::queue<DependencyGraphVertex> toVisit;
570 toVisit.push(dv1);
571 while (!toVisit.empty())
572 {
573
574 DependencyGraphVertex dv=toVisit.front();
575 toVisit.pop();
576// LDEBUG << "visit dep vertex " << dv;
577
578 for (std::tie(outItr,outItrEnd)=out_edges(dv,*depGraph);
579 outItr!=outItrEnd;
580 outItr++)
581 {
582 if ( get(edge_deprel_type,*depGraph,*outItr) == m_relation)
583 {
584// LDEBUG << "find relation " << m_relation << " for edge " << *outItr;
585 syntacticData->relation(
586 syntacticData->tokenVertexForDepVertex(dv),
587 syntacticData->tokenVertexForDepVertex(target(*outItr,*depGraph)),
588 m_relation);
589 return true;
590 }
591 toVisit.push(target(*outItr,*depGraph));
592 }
593 }
594// LDEBUG << "FindRelationFrom: no";
595 return false;
596}
597
598
599//**********************************************************************
600
602 MediaId language,
603 const LimaString& complement):
604 ConstraintFunction(language,complement),
607{
608 std::string str=limastring2utf8stdstring(complement);
609
610 //parse complement: contains two relation names separated by a comma
611 // uint64_t i=str.find(","); portage 32 64
612 std::string::size_type i=str.find(",");
613 if (i == std::string::npos)
614 {
616 LIMA_EXCEPTION( "Error: CreateRelationWithRelated complement must have two types");
617 }
618 m_relationToCreate=static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(language)).getSyntacticRelationId(std::string(str,i+1));
619
620 //relations to follow : may be several separated by a "|"
621 std::string rel(str,0,i);
622 //uint64_t j=rel.find("|"); portage 32 64
623 std::string::size_type j=rel.find("|");
624 while (j!=std::string::npos)
625 {
627 insert(static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(language)).getSyntacticRelationId(std::string(rel,0,j)));
628 rel.erase(0,j+1);
629 j=rel.find("|");
630 }
631 if (! rel.empty())
632 {
634 insert(static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(language)).getSyntacticRelationId(rel));
635 }
636}
637
638std::vector<LinguisticGraphVertex> CreateRelationWithRelated::
640 SyntacticData* syntacticData) const
641{
642
643// SAPLOGINIT;
644
645 std::vector<LinguisticGraphVertex> vfollow=
646 syntacticData->findRelated(v2,m_relationsToFollow);
647
648// if (vfollow.empty())
649// {
650// if (logger.isDebugEnabled())
651// {
652// std::ostringstream oss;
653// std::set<MediaticData::SyntacticRelationId>::const_iterator
654// it=m_relationsToFollow.begin(),
655// it_end=m_relationsToFollow.end();
656// for (; it!=it_end; it++)
657// {
658// oss << *it<< ",";
659// }
660// LDEBUG << "CreateRelationWithRelated: no relation "
661// << oss.str() << " attached to vertex " << v2;
662// }
663// }
664 return vfollow;
665}
666
668 const AnalysisGraph&,
669 const LinguisticGraphVertex& v1,
670 const LinguisticGraphVertex& v2,
671 AnalysisContent& analysis ) const
672{
673/*
674 Critical function : comment logging message
675*/
676// SAPLOGINIT;
677// LDEBUG << "testing CreateRelationWithRelated for " << v1
678// << " and " << v2;
679
680 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
681
682 std::vector<LinguisticGraphVertex> vfollow=
683 findRelatedVertices(v2, syntacticData.get());
684
685 if (vfollow.empty())
686 {
687 return false;
688 }
689
690 // add the relations
691 std::vector<LinguisticGraphVertex>::const_iterator
692 v=vfollow.begin(),
693 v_end=vfollow.end();
694 for (; v!=v_end; v++)
695 {
696// LDEBUG << "storing relation " << m_relationToCreate
697// << " between " << v1 << " and " << *v;
698 syntacticData->relation(v1, *v, m_relationToCreate);
699 }
700// LDEBUG << "CreateRelationWithRelated: yes";
701 return true;
702}
703
704//**********************************************************************
706 MediaId language,
707 const LimaString& complement):
708 CreateRelationWithRelated(language,complement)
709{}
710
712 const AnalysisGraph&,
713 const LinguisticGraphVertex& v1,
714 const LinguisticGraphVertex& v2,
715 AnalysisContent& analysis ) const
716{
717/*
718 Critical function : comment logging message
719*/
720// SAPLOGINIT;
721// LDEBUG << "CreateRelationReverseWithRelated::operator()" << v1 << v2 << m_relationToCreate;
722
723 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
724
725 std::vector<LinguisticGraphVertex> vfollow=
726 findRelatedVertices(v2, syntacticData.get());
727
728 if (vfollow.empty())
729 {
730 return false;
731 }
732
733 // add the relations
734 for (auto v=vfollow.begin(), v_end=vfollow.end(); v!=v_end; v++)
735 {
736// LDEBUG << "storing relation " << m_relationToCreate
737// << " between " << v1 << " and " << *v;
738 syntacticData->relation(*v, v1, m_relationToCreate);
739 }
740// LDEBUG << "CreateRelationReverseWithRelated: yes";
741 return true;
742}
743
744//**********************************************************************
745// complement contains symbols for auxiliary macro, micro and tense
746// (e.g.: V;V;PRES)
747// Time to set to result is given by the resource compoundTenses-<lang>.bin
749 const LimaString& complement):
750 ConstraintFunction(language,complement),
751 m_tempCompType(0)
752{
753#ifdef DEBUG_LP
755 LDEBUG << "CreateCompoundTense::CreateCompoundTense()" << language << complement;
756#endif
758
759 auto complementList = complement.split(";");
760 if (complementList.size() != 3)
761 {
762 SAPLOGINIT;
763 LIMA_EXCEPTION( "CreateCompoundTense::CreateCompoundTense() complement should be a list of three semicolon separated elements while it is:" << complement );
764 }
765 m_macro=codeManager.getPropertyManager("MACRO").getPropertyValue(complementList[0].toUtf8().constData());
766
767 m_micro=codeManager.getPropertyManager("MICRO").getPropertyValue(complementList[1].toUtf8().constData());
768
769 m_tempCompType=static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(language)).getSyntacticRelationId("aux");
770#ifdef DEBUG_LP
771 LDEBUG << "CreateCompoundTense::CreateCompoundTense() m_tempCompType" << m_tempCompType;
772#endif
773
774 QString macroCode = static_cast<const Common::MediaticData::LanguageData&>(
776 m_macroAccessor=&codeManager.getPropertyAccessor(macroCode.toUtf8().constData());
777 QString microCode = static_cast<const Common::MediaticData::LanguageData&>(
779 m_microAccessor=&codeManager.getPropertyAccessor(microCode.toUtf8().constData());
780 QString genderCode = static_cast<const Common::MediaticData::LanguageData&>(
782 m_genderAccessor=&codeManager.getPropertyAccessor(genderCode.toUtf8().constData());
783 QString numberCode = static_cast<const Common::MediaticData::LanguageData&>(
785 m_numberAccessor=&codeManager.getPropertyAccessor(numberCode.toUtf8().constData());
786 QString timeCode = static_cast<const Common::MediaticData::LanguageData&>(
788 m_timeAccessor=&codeManager.getPropertyAccessor(timeCode.toUtf8().constData());
789 m_tense=codeManager.getPropertyManager(timeCode.toUtf8().constData()).getPropertyValue(complementList[2].toUtf8().constData());
790
791
792 QString syntaxCode = static_cast<const Common::MediaticData::LanguageData&>(
794 m_syntaxAccessor=&codeManager.getPropertyAccessor(syntaxCode.toUtf8().constData());
795 QString personCode = static_cast<const Common::MediaticData::LanguageData&>(
797 m_personAccessor=&codeManager.getPropertyAccessor(personCode.toUtf8().constData());
798}
799
801 const LinguisticGraphVertex& pastPartVertex,
802 const LinguisticGraphVertex& auxVertex,
803 AnalysisContent& analysis ) const
804{
805#ifdef DEBUG_LP
807 LDEBUG << "creating compound tense for " << auxVertex << " and " << pastPartVertex;
808#endif
809
810 if (m_macroAccessor->empty(m_macro) || m_microAccessor->empty(m_micro))
811 {
812#ifdef DEBUG_LP
813 LDEBUG << "CreateCompoundTense: false because macro="
814 << m_macro << " and micro=" << m_micro;
815#endif
816 return false;
817 }
818
819 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
820 auto metadata = std::dynamic_pointer_cast<LinguisticMetaData>(analysis.getData("LinguisticMetaData"));
821 auto annotationData = std::dynamic_pointer_cast< AnnotationData >(analysis.getData("AnnotationData"));
822 if (annotationData==0)
823 {
824 return false;
825 }
826
827 // getting data
828 DependencyGraph& depGraph= *(syntacticData->dependencyGraph());
829 LinguisticGraph* graph = const_cast<LinguisticGraph*>(anagraph.getGraph());
830 VertexTokenPropertyMap tokenMap = get(vertex_token, *graph);
831 VertexDataPropertyMap dataMap = get(vertex_data, *graph);
832 VertexChainIdPropertyMap chainsIdsMap = get(vertex_chain_id, *graph);
833
834 MediaId language = Common::MediaticData::MediaticData::single().media(metadata->getMetaData("Lang"));
835
836 Token* tokenAux = tokenMap[auxVertex];
837 Token* tokenPastPart = tokenMap[pastPartVertex];
838 const MorphoSyntacticData* dataAux = dataMap[auxVertex];
839 if (dataAux->empty())
840 {
842 LERROR << "CreateCompoundTense::operator() morphosyntactic data is empty for aux. Abort.";
843 return false;
844 }
845 const MorphoSyntacticData* dataPastPart = dataMap[pastPartVertex];
846 if (dataPastPart->empty())
847 {
849 LERROR << "CreateCompoundTense::operator() morphosyntactic data is empty for past participle. Abort.";
850 return false;
851 }
852 auto dataAuxMicro = dataAux->firstValue(*m_microAccessor);
853 if (dataAuxMicro != m_micro)
854 {
856 LWARN << "CreateCompoundTense: false because expected micro="
857 << m_micro << " and actual micro=" << dataAuxMicro;
858 return false;
859 }
860
861 auto dataAuxTime = dataAux->firstValue(*m_timeAccessor);
862 if (dataAuxTime != m_tense)
863 {
865 LWARN << "CreateCompoundTense: false because expected tense="
866 << m_tense << " and actual tense=" << dataAuxTime;
867 return false;
868 }
869 auto tense = static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(language)).compoundTense(dataAuxMicro, dataAuxTime);
870#ifdef DEBUG_LP
871 LDEBUG << "Tense = '" << tense << "' ";
872#endif
873
874 // creer un full token
875 // this version changes the head verb of the sentence to be the past participle verb
876 LimaString verbFlex = tokenAux->stringForm() + utf8stdstring2limastring("_") + tokenPastPart->stringForm();
877 StringsPoolIndex verbLemma = *((dataPastPart->allLemma()).begin());
878
879 // this version keeps the auxiliary verb
880// LimaString verbFlex = tokenAux->stringForm() ;
881 LinguisticElement elem(*(dataPastPart->begin()));
882// StringsPoolIndex verbLemma = elem.normalizedForm;
883
884 Token* tokenNewVerb = new Token(Common::MediaticData::MediaticData::changeable().stringsPool(language)[verbFlex],
885 verbFlex,
886 tokenAux->position(),
887 verbFlex.size());
888 tokenNewVerb->setStatus(tokenMap[auxVertex]->status());
889
891 if (!anagraph.ownsTokens())
892 {
893 syntacticData->ownedTokens().push_back(tokenNewVerb);
894 }
895
896 // creer un MorphoSyntacticData
897#ifdef DEBUG_LP
898 LDEBUG << "Creating a DicoWord: " << m_macro << " / " << verbFlex << " / " << m_micro << " / " << verbLemma;
899#endif
900 MorphoSyntacticData* dataNewVerb = new MorphoSyntacticData();
902 if (!anagraph.ownsMorphData())
903 {
904 syntacticData->ownedMorphosyntacticData().push_back(dataNewVerb);
905 }
907 elem.lemma = verbLemma;
908 elem.normalizedForm = *((dataPastPart->allNormalizedForms()).begin());
909 m_macroAccessor->writeValue( m_macro, elem.properties);
910 m_microAccessor->writeValue( m_micro, elem.properties);
911 // set the new morphosyntactic data tense to be the found tense
912 m_timeAccessor->writeValue( tense, elem.properties);
913 // keeps the genre and syntax from the participle
914 // copies the person and number from the auxiliary
915 m_personAccessor->writeValue( dataAux->firstValue(*m_personAccessor), elem.properties);
916 m_numberAccessor->writeValue( dataAux->firstValue(*m_numberAccessor), elem.properties);
917 dataNewVerb->push_back(elem);
918
919 // creer le noeud et ses 2 arcs
920
921 LinguisticGraphVertex newVertex;
922 DependencyGraphVertex newDepVertex;
923 std::tie (newVertex, newDepVertex) = syntacticData->addVertex();
924#ifdef DEBUG_LP
925 LDEBUG << "New vertices are " << newVertex << " (pos) and " << newDepVertex << " (dep)";
926#endif
927
928 tokenMap[newVertex] = tokenNewVerb;
929 dataMap[newVertex] = dataNewVerb;
930
931
932 // affecter les chaines verbales (ensemble des chaines comprises dans
933 // l'intersection des ensembles de chaines de l'auxiliaire et du participe
934 VertexChainIdProp& auxChains = chainsIdsMap[auxVertex];
935 VertexChainIdProp& pastPartChains = chainsIdsMap[pastPartVertex];
936 std::set< uint64_t> auxChainsIds;
937 VertexChainIdProp::iterator auxChainsIt, auxChainsIt_end;
938 auxChainsIt = auxChains.begin(); auxChainsIt_end = auxChains.end();
939 for (; auxChainsIt != auxChainsIt_end; auxChainsIt++)
940 auxChainsIds.insert((*auxChainsIt).chainId());
941 std::set< uint64_t > pastPartChainsIds;
942 VertexChainIdProp::iterator pastPartChainsIt, pastPartChainsIt_end;
943 pastPartChainsIt = pastPartChains.begin(); pastPartChainsIt_end = pastPartChains.end();
944 for (; pastPartChainsIt != pastPartChainsIt_end; pastPartChainsIt++)
945 pastPartChainsIds.insert((*pastPartChainsIt).chainId());
946 std::set< uint64_t > newVerbChainsIds;
947 std::set_intersection(
948 auxChainsIds.begin(), auxChainsIds.end(),
949 pastPartChainsIds.begin(), pastPartChainsIds.end(),
950 std::insert_iterator< std::set< uint64_t > >(newVerbChainsIds, newVerbChainsIds.end()));
951
952 std::set< LinguisticAnalysisStructure::ChainIdStruct > newVerbChains;
953 auxChainsIt = auxChains.begin(); auxChainsIt_end = auxChains.end();
954 for (; auxChainsIt != auxChainsIt_end; auxChainsIt++)
955 {
956 if ( newVerbChainsIds.find( (*auxChainsIt).chainId() ) != newVerbChainsIds.end() )
957 {
958 newVerbChains.insert(*auxChainsIt);
959 }
960 }
961
962 chainsIdsMap[auxVertex] = newVerbChains;
963 chainsIdsMap[pastPartVertex] = newVerbChains;
964 chainsIdsMap[newVertex] = newVerbChains;
965
966 // creer les relations necessaires dans le graphe morphosyntaxique
967 // les relations sont creees entre noeuds ayant au moins une chaine en commun
968 std::set< std::pair< LinguisticGraphVertex, LinguisticGraphVertex > > edgesToRemove;
969
970 // on ne doit pas creer d'arc en double, il faut donc garder trace des arcs ajoutes
971 std::set< std::pair< LinguisticGraphVertex, LinguisticGraphVertex > > addedEdges;
972
973 //1. entre les noeuds avant l'auxiliaire et le nouveau noeud
974#ifdef DEBUG_LP
975 LDEBUG << "The auxiliary has " << in_degree(auxVertex, *graph) << " in edges.";
976#endif
977 LinguisticGraphInEdgeIt auxInEdgesIt, auxInEdgesIt_end;
978 std::tie(auxInEdgesIt, auxInEdgesIt_end) = in_edges(auxVertex, *graph);
979 for (; auxInEdgesIt != auxInEdgesIt_end; auxInEdgesIt++)
980 {
981#ifdef DEBUG_LP
982 LDEBUG << "auxInEdge: " << source(*auxInEdgesIt, *graph) << " -> " << target(*auxInEdgesIt, *graph);
983#endif
984 LinguisticGraphVertex auxInVertex = source(*auxInEdgesIt, *graph);
985 if (addedEdges.find(std::make_pair(auxInVertex,newVertex)) != addedEdges.end())
986 {
987 // l'arc a deja ete ajoute, abandonner
988 continue;
989 }
990#ifdef DEBUG_LP
991 LDEBUG << "edge to add (step1): " << auxInVertex << " -> " << newVertex;
992#endif
993 edgesToRemove.insert(std::make_pair(source(*auxInEdgesIt,*graph),target(*auxInEdgesIt,*graph)));
994 addedEdges.insert(std::make_pair(auxInVertex,newVertex));
995 }
996 //2. entre le nouveau noeud et les noeuds qui etaient entre l'auxiliaire et
997 // le verbe
998 LinguisticGraphOutEdgeIt auxOutEdgesIt, auxOutEdgesIt_end;
999 std::tie(auxOutEdgesIt, auxOutEdgesIt_end) = out_edges(auxVertex, *graph);
1000 for (; auxOutEdgesIt != auxOutEdgesIt_end; auxOutEdgesIt++)
1001 {
1002 LinguisticGraphVertex auxOutVertex = target(*auxOutEdgesIt, *graph);
1003 if (auxOutVertex == pastPartVertex) continue;
1004 chainsIdsMap[auxOutVertex] = newVerbChains;
1005 if (addedEdges.find(std::make_pair(newVertex,auxOutVertex)) != addedEdges.end())
1006 {
1007 // l'arc a deja ete ajoute, abandonner
1008 continue;
1009 }
1010// bool success;
1011// LinguisticGraphEdge e;
1012// std::tie(e, success) = add_edge(newVertex, auxOutVertex, *graph);
1013// if (success)
1014// {
1015#ifdef DEBUG_LP
1016 LDEBUG << "edge to add (step2): " << newVertex << " -> " << auxOutVertex;
1017#endif
1018 edgesToRemove.insert(std::make_pair(source(*auxOutEdgesIt,*graph),target(*auxOutEdgesIt,*graph)));
1019 addedEdges.insert(std::make_pair(newVertex,auxOutVertex));
1020// break;
1021// }
1022 }
1023 //3. entre les noeuds qui etaient entre l'auxiliaire et le participe (avant
1024 // le participe) et les noeuds qui etaient apres le participe ;
1025 // egalement, relie le nouveau noeud aux noeuds qui etaient apres
1026 // l'auxiliaire au cas ou l'auxiliaire et le participe etaient contigus
1027 LinguisticGraphInEdgeIt pastPartInEdgesIt, pastPartInEdgesIt_end;
1028 std::tie(pastPartInEdgesIt, pastPartInEdgesIt_end) = in_edges(pastPartVertex, *graph);
1029 for (; pastPartInEdgesIt != pastPartInEdgesIt_end; pastPartInEdgesIt++)
1030 {
1031 LinguisticGraphVertex pastPartInVertex = source(*pastPartInEdgesIt, *graph);
1032 if (pastPartInVertex == auxVertex)
1033 {
1034#ifdef DEBUG_LP
1035 LDEBUG << "no vertex between past participle and auxiliary";
1036#endif
1037 pastPartInVertex = newVertex;
1038
1039 }
1040#ifdef DEBUG_LP
1041 LDEBUG << "past participle in vertex " << pastPartInVertex;
1042#endif
1043 edgesToRemove.insert(std::make_pair(source(*pastPartInEdgesIt,*graph),target(*pastPartInEdgesIt,*graph)));
1044
1045 LinguisticGraphOutEdgeIt pastPartOutEdgesIt, pastPartOutEdgesIt_end;
1046 std::tie(pastPartOutEdgesIt, pastPartOutEdgesIt_end) = out_edges(pastPartVertex, *graph);
1047 for (; pastPartOutEdgesIt != pastPartOutEdgesIt_end; pastPartOutEdgesIt++)
1048 {
1049 LinguisticGraphVertex pastPartOutVertex = target(*pastPartOutEdgesIt, *graph);
1050#ifdef DEBUG_LP
1051 LDEBUG << "past participle out vertex " << pastPartOutVertex;
1052#endif
1053
1054 chainsIdsMap[pastPartInVertex] = newVerbChains;
1055 if (addedEdges.find(std::make_pair(pastPartInVertex,pastPartOutVertex)) != addedEdges.end())
1056 {
1057 // l'arc a deja ete ajoute, abandonner
1058 continue;
1059 }
1060// bool success;
1061// LinguisticGraphEdge e;
1062// std::tie(e, success) = add_edge(pastPartInVertex, pastPartOutVertex, *graph);
1063// if (success)
1064// {
1065#ifdef DEBUG_LP
1066 LDEBUG << "edge to add (step3): " << pastPartInVertex << " -> " << pastPartOutVertex;
1067#endif
1068 edgesToRemove.insert(std::make_pair(source(*pastPartOutEdgesIt,*graph),target(*pastPartOutEdgesIt,*graph)));
1069 addedEdges.insert(std::make_pair(pastPartInVertex,pastPartOutVertex));
1070// break;
1071// }
1072 }
1073 }
1074 std::set< std::pair< LinguisticGraphVertex, LinguisticGraphVertex > >::const_iterator
1075 edgesToRemoveIt, edgesToRemoveIt_end;
1076 edgesToRemoveIt = edgesToRemove.begin();
1077 edgesToRemoveIt_end = edgesToRemove.end();
1078 for (; edgesToRemoveIt != edgesToRemoveIt_end; edgesToRemoveIt++)
1079 {
1080#ifdef DEBUG_LP
1081 LDEBUG << "remove edge " << (*edgesToRemoveIt).first << " -> " << (*edgesToRemoveIt).second;
1082#endif
1083 remove_edge( (*edgesToRemoveIt).first, (*edgesToRemoveIt).second,*graph);
1084 }
1085
1086 std::set< std::pair< LinguisticGraphVertex, LinguisticGraphVertex > >::const_iterator addedEdgesIt, addedEdgesIt_end;
1087 addedEdgesIt = addedEdges.begin(); addedEdgesIt_end = addedEdges.end();
1088 for (; addedEdgesIt != addedEdgesIt_end; addedEdgesIt++)
1089 {
1090 bool success;
1092 std::tie(e, success) = add_edge(addedEdgesIt->first, addedEdgesIt->second, *graph);
1093 if (success)
1094 {
1095#ifdef DEBUG_LP
1096 LDEBUG << "edge added : " << e.m_source << " -> " << e.m_target;
1097#endif
1098 }
1099 else
1100 {
1101 SAPLOGINIT;
1102 LERROR << "could not add edge : " << addedEdgesIt->first << " -> " << addedEdgesIt->second;
1103 }
1104 }
1105
1106 // copier vers le noeud du nouveau verbe toutes les relations de
1107 // dépendance (sauf aux) qui avaient pour source ou destination
1108 // l'auxiliaire ou le participe passé
1109 EdgeDepRelTypePropertyMap edgeTypeMap = get( edge_deprel_type, depGraph);
1110
1111 DependencyGraphVertex auxDepVertex =
1112 syntacticData-> depVertexForTokenVertex(auxVertex);
1113 DependencyGraphInEdgeIt auxDepVertexInEdgeIt, auxDepVertexInEdgeIt_end;
1114 std::tie(auxDepVertexInEdgeIt, auxDepVertexInEdgeIt_end) =
1115 in_edges(auxDepVertex,depGraph);
1116 for (; auxDepVertexInEdgeIt != auxDepVertexInEdgeIt_end;
1117 auxDepVertexInEdgeIt++)
1118 {
1120 bool success;
1121 std::tie(e, success) = add_edge(source(*auxDepVertexInEdgeIt,depGraph),newDepVertex,depGraph);
1122 if (success)
1123 {
1124#ifdef DEBUG_LP
1125 LDEBUG << "edge added : " << e.m_source << " -> " << e.m_target;
1126#endif
1127 edgeTypeMap[e] = edgeTypeMap[*auxDepVertexInEdgeIt];
1128 }
1129 }
1130 DependencyGraphOutEdgeIt auxDepVertexOutEdgeIt, auxDepVertexOutEdgeIt_end;
1131 std::tie(auxDepVertexOutEdgeIt, auxDepVertexOutEdgeIt_end) =
1132 out_edges(auxDepVertex,depGraph);
1133 for (; auxDepVertexOutEdgeIt != auxDepVertexOutEdgeIt_end;
1134 auxDepVertexOutEdgeIt++)
1135 {
1137 bool success;
1138 std::tie(e, success) = add_edge(newDepVertex, target(*auxDepVertexOutEdgeIt,depGraph),depGraph);
1139 if (success)
1140 {
1141#ifdef DEBUG_LP
1142 LDEBUG << "edge added : " << e.m_source << " -> " << e.m_target;
1143#endif
1144 edgeTypeMap[e] = edgeTypeMap[*auxDepVertexOutEdgeIt];
1145 }
1146 }
1147 clear_vertex(auxDepVertex, depGraph);
1148
1149 DependencyGraphVertex pastPartDepVertex =
1150 syntacticData-> depVertexForTokenVertex(pastPartVertex);
1151 DependencyGraphInEdgeIt pastPartDepVertexInEdgeIt, pastPartDepVertexInEdgeIt_end;
1152 std::tie(pastPartDepVertexInEdgeIt, pastPartDepVertexInEdgeIt_end) =
1153 in_edges(pastPartDepVertex,depGraph);
1154 for (; pastPartDepVertexInEdgeIt != pastPartDepVertexInEdgeIt_end;
1155 pastPartDepVertexInEdgeIt++)
1156 {
1158 bool success;
1159 std::tie(e, success) =
1160 add_edge(source(*pastPartDepVertexInEdgeIt,depGraph),newDepVertex,depGraph);
1161 if (success)
1162 {
1163#ifdef DEBUG_LP
1164 LDEBUG << "edge added : " << e.m_source << " -> " << e.m_target;
1165 #endif
1166 edgeTypeMap[e] = edgeTypeMap[*pastPartDepVertexInEdgeIt];
1167 }
1168 }
1169 DependencyGraphOutEdgeIt pastPartDepVertexOutEdgeIt, pastPartDepVertexOutEdgeIt_end;
1170 std::tie(pastPartDepVertexOutEdgeIt, pastPartDepVertexOutEdgeIt_end) =
1171 out_edges(pastPartDepVertex,depGraph);
1172 for (; pastPartDepVertexInEdgeIt != pastPartDepVertexInEdgeIt_end;
1173 pastPartDepVertexInEdgeIt++)
1174 {
1176 bool success;
1177 std::tie(e, success) =
1178 add_edge(newDepVertex, target(*pastPartDepVertexOutEdgeIt,depGraph),depGraph);
1179 if (success)
1180 {
1181#ifdef DEBUG_LP
1182 LDEBUG << "edge added : " << e.m_source << " -> " << e.m_target;
1183#endif
1184 edgeTypeMap[e] = edgeTypeMap[*pastPartDepVertexOutEdgeIt];
1185 }
1186 }
1187 clear_vertex(pastPartDepVertex, depGraph);
1188
1189
1192 AnnotationGraphVertex agv = annotationData->createAnnotationVertex();
1193 annotationData->annotate(agv,utf8stdstring2limastring("PosGraph"),newVertex);
1194 annotationData->addMatching("PosGraph",newVertex,"annot",agv);
1195 annotationData->annotate(agv,utf8stdstring2limastring("CpdTense"),1);
1196 AnnotationGraphVertex annotAuxVertex = *(annotationData->matches("PosGraph",auxVertex,"annot").begin());
1197 AnnotationGraphVertex annotPastPartVertex = *(annotationData->matches("PosGraph",pastPartVertex,"annot").begin());
1198 annotationData->annotate(agv, annotAuxVertex, utf8stdstring2limastring("Aux"), 1);
1199 annotationData->annotate(agv, annotPastPartVertex, utf8stdstring2limastring("PastPart"), 1);
1200
1201
1202 bool res = syntacticData->relation(auxVertex,
1203 pastPartVertex,
1204 m_tempCompType);
1205
1206#ifdef DEBUG_LP
1207 LDEBUG << "CreateCompoundTense: " << m_tempCompType << res;
1208#endif
1209 auto recoData = std::dynamic_pointer_cast<RecognizerData>(analysis.getData("RecognizerData"));
1210 if (recoData == 0)
1211 {
1212 recoData = std::make_shared<RecognizerData>();
1213 analysis.setData("RecognizerData", recoData);
1214 }
1215#ifdef DEBUG_LP
1216 LDEBUG << "CreateCompoundTense setNextVertex:" << newVertex;
1217#endif
1218 recoData->setNextVertex(newVertex);
1219
1220#ifdef DEBUG_LP
1221 LDEBUG << "aux vertex "<<auxDepVertex<<" out edges num: " << out_degree(auxDepVertex, depGraph);
1222 LDEBUG << "past part vertex "<<pastPartDepVertex<<" out edges num: " << out_degree(pastPartDepVertex, depGraph);
1223#endif
1224 return res;
1225
1226 // return false;
1227}
1228
1230 const LimaString& complement):
1231 ConstraintFunction(language,complement),
1232 m_tempCompType(0)
1233{
1234 const std::string str=
1235 limastring2utf8stdstring(complement);
1236
1237 size_t firstSepPos = str.find_first_of(';');
1238 const PropertyCodeManager& codeManager=static_cast<const LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(language)).getPropertyCodeManager();
1239 m_macro=codeManager.getPropertyManager("MACRO").getPropertyValue(str.substr(0, firstSepPos));
1240
1241 size_t secondSepPos = str.find_first_of(';', firstSepPos+1);
1242 m_micro=codeManager.getPropertyManager("MICRO").getPropertyValue(str.substr(firstSepPos + 1, secondSepPos - firstSepPos - 1));
1243
1244 m_tempCompType=static_cast<const LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(language)).getSyntacticRelationId("aux");
1245
1246 m_macroAccessor=&(codeManager.getPropertyAccessor("MACRO"));
1247 m_microAccessor=&(codeManager.getPropertyAccessor("MICRO"));
1248 m_genderAccessor=&(codeManager.getPropertyAccessor("GENDER"));
1249 m_numberAccessor=&(codeManager.getPropertyAccessor("NUMBER"));
1250 m_timeAccessor=&(codeManager.getPropertyAccessor("TIME"));
1251 m_syntaxAccessor=&(codeManager.getPropertyAccessor("SYNTAX"));
1252 m_personAccessor=&(codeManager.getPropertyAccessor("PERSON"));
1253}
1254
1256 const LinguisticGraphVertex& pastPartVertex,
1257 const LinguisticGraphVertex& auxVertex,
1258 AnalysisContent& analysis ) const
1259{
1260 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
1261
1262
1263 bool res = syntacticData->relation(auxVertex,
1264 pastPartVertex,
1265 m_tempCompType);
1266
1267 return res;
1268}
1269
1271 MediaId language,
1272 const LimaString& complement)
1273 : ConstraintFunction(language, complement), m_language(language)
1274{
1275#ifdef DEBUG_LP
1276 SAPLOGINIT;
1277 LDEBUG << "Initializing EnforcePropertiesConstraints";
1278#endif
1279
1280 QRegularExpression linere("[^,]+");
1281 auto& codeManager =
1282 static_cast<const Common::MediaticData::LanguageData&>(
1284 ).getPropertyCodeManager();
1285 auto it = linere.globalMatch(complement);
1286 while (it.hasNext())
1287 {
1288 auto match = it.next();
1289 auto category = match.captured(0);
1290
1291#ifdef DEBUG_LP
1292 LDEBUG << " adding category: " << category;
1293#endif
1294
1295
1296 auto& categ = codeManager.getPropertyAccessor(category.toStdString());
1297 m_categories.push_back(categ);
1298 }
1299}
1300
1302 const LinguisticGraphVertex& v1,
1303 const LinguisticGraphVertex& v2,
1304 AnalysisContent& analysis ) const
1305{
1306/*
1307 Critical function : comment logging message
1308*/
1309
1310#ifdef DEBUG_LP
1311 SAPLOGINIT;
1312 LDEBUG << "testing EnforcePropertiesConstraints for "
1313 << v1 << " and " << v2;
1314#endif
1315 bool result = true;
1316
1317 // cannot use AnalysisGraph because it is const -> use AnalysisContent
1318 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.getData("PosGraph"));
1319 LinguisticGraph* posgraph=anagraph->getGraph();
1320
1321 // SyntacticData* syntacticData = dynamic_cast<SyntacticData*>(analysis.getData("SyntacticData"));
1322
1323 VertexDataPropertyMap map = get(vertex_data, *posgraph);
1324 MorphoSyntacticData* data1 = map[v1];
1325 MorphoSyntacticData* data2 = map[v2];
1326
1327 auto categ = m_categories.begin(), categ_end = m_categories.end();
1328 for (; categ != categ_end; categ++)
1329 {
1330 std::set< LinguisticCode > categ1 = data1->allValues(*categ);
1331 std::set< LinguisticCode > categ2 = data2->allValues(*categ);
1332#ifdef DEBUG_LP
1333 LDEBUG << " on property " << (*categ).getPropertyName() << ", there is "
1334 << categ1.size() << " and " << categ2.size() << " values";
1335#endif
1336 if (categ1.size()!=0 && categ2.size()!=0)
1337 {
1338#ifdef DEBUG_LP
1339 for (auto it=categ1.begin(); it!=categ1.end(); it++)
1340 {
1341 std::string str1 = static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(m_language)).getPropertyCodeManager().getPropertyManager((*categ).getPropertyName()).getPropertySymbolicValue(*it);
1342 LDEBUG << " categ1 " << str1;
1343 }
1344 for (auto it = categ2.begin(); it != categ2.end();it++)
1345 {
1346 std::string str2 = static_cast<const Common::MediaticData::LanguageData&>(Common::MediaticData::MediaticData::single().mediaData(m_language)).getPropertyCodeManager().getPropertyManager((*categ).getPropertyName()).getPropertySymbolicValue(*it);
1347 LDEBUG << " categ2 " << str2;
1348 }
1349#endif
1350 std::set< LinguisticCode > common;
1351 std::set_intersection(categ1.begin(), categ1.end(),
1352 categ2.begin(), categ2.end(),
1353 std::insert_iterator< std::set< LinguisticCode> >(common, common.end()));
1354 ExcludePropertyPredicate epp(*categ, common);
1355#ifdef DEBUG_LP
1356 LDEBUG << " sizes before erase: " << data1->size() << " / " << data2->size();
1357#endif
1358 MorphoSyntacticData data1Copy = *data1;
1359 data1->erase(std::remove_if(data1->begin(),data1->end(),epp),data1->end());
1360 if (data1->empty() ) {
1361 *data1 = data1Copy;
1362 result = false;
1363 break;
1364 }
1365 MorphoSyntacticData data2Copy = *data2;
1366 data2->erase(std::remove_if(data2->begin(),data2->end(),epp),data2->end());
1367 if (data2->empty()) {
1368 *data2 = data2Copy;
1369 result = false;
1370 break;
1371 }
1372#ifdef DEBUG_LP
1373 LDEBUG << " sizes after erase: " << data1->size() << " / " << data2->size();
1374#endif
1375 }
1376 }
1377
1378 if (!result)
1379 {
1380 SAPLOGINIT;
1381 LINFO << "EnforcePropertiesConstraints: "
1382 << (result?"true":"false");
1383 LINFO << " but returns true: constraints checking "
1384 << "should have been done with agreement constraints";
1385 }
1386#ifdef DEBUG_LP
1387 else
1388 {
1389 LDEBUG << "EnforcePropertiesConstraints: "
1390 << (result?"true":"false");
1391 }
1392#endif
1393 return true;
1394}
1395
1396
1397//----------------------------------------------------------------------
1399 const LimaString& complement):
1400 ConstraintWithRelationComplement(language,complement)
1401{}
1402
1405 const LinguisticGraphVertex& src,
1406 const LinguisticGraphVertex& dest,
1407 AnalysisContent& analysis ) const
1408{
1409// SAPLOGINIT;
1410// LDEBUG << "adding new relation in the dependency graph";
1411
1412 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
1413
1414 try
1415 {
1416 syntacticData->addRelationNoChain(m_relation, src, dest);
1417 }
1418 catch (const std::exception& )
1419 {
1420 SAPLOGINIT;
1421 LERROR << "relation (" << m_relation << "," << src << ","
1422 << dest << ") not added";
1423 return false;
1424 }
1425 return true;
1426}
1427
1429{
1430
1431// SAPLOGINIT;
1432// LDEBUG << "adding stored relations in the dependency graph";
1433
1434 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.getData("PosGraph"));
1435 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
1436
1437 LinguisticGraphVertex src, dest;
1439
1440 std::tie(src,dest,relation) = syntacticData->relation();
1441 uint64_t nbAdded(0);
1442
1443 std::set<std::pair<LinguisticGraphVertex,Common::MediaticData::SyntacticRelationId> > relationsAdded;
1444
1445 while (!((src == anagraph->firstVertex()) &&
1446 (dest == anagraph->lastVertex()) &&
1447 (relation == 0)))
1448 {
1449
1450 if (relation == 0)
1451 {
1452 SAPLOGINIT;
1453 LERROR << "no type specified for relation between " << src
1454 << " and " << dest << ": ignored";
1455 std::tie(src,dest,relation) = syntacticData->relation();
1456 continue;
1457 }
1458
1459 try
1460 {
1461 syntacticData->addRelationNoChain(relation, src, dest);
1462 nbAdded++;
1463 relationsAdded.insert(std::make_pair(src,relation));
1464 }
1465 catch (const std::exception& )
1466 {
1467 SAPLOGINIT;
1468 LERROR << "relation (" << relation << "," << src << ","
1469 << dest << ") not added";
1470 }
1471 std::tie(src,dest,relation) = syntacticData->relation();
1472 }
1473
1474 // return true is some additions worked (even if some did not work)
1475 return (nbAdded>0);
1476}
1477
1478//----------------------------------------------------------------------
1480 const LimaString& complement):
1481 ConstraintWithRelationComplement(language,complement)
1482{}
1483
1485 const LinguisticGraphVertex& ,
1486 const LinguisticGraphVertex& ,
1487 AnalysisContent& /*ac*/) const
1488{
1489 SAPLOGINIT;
1490 LERROR << "invalid action ! modify relation in the dependency graph !";
1491 return true;
1492}
1493
1495{
1496
1497// SAPLOGINIT;
1498// LDEBUG << "modify stored relations in the dependency graph";
1499
1500 auto anagraph = std::dynamic_pointer_cast<AnalysisGraph>(analysis.getData("PosGraph"));
1501 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
1502
1503 LinguisticGraphVertex src, dest;
1505
1506 std::tie(src,dest,relation) = syntacticData->relation();
1507 uint64_t nbModified(0);
1508
1509 while (!((src == anagraph->firstVertex()) &&
1510 (dest == anagraph->lastVertex()) &&
1511 (relation == 0)))
1512 {
1513
1514 if (relation == 0)
1515 {
1516 SAPLOGINIT;
1517 LERROR << "no type specified for relation between " << src
1518 << " and " << dest << ": ignored";
1519 std::tie(src,dest,relation) = syntacticData->relation();
1520 continue;
1521 }
1522
1523 try
1524 {
1525 syntacticData->modifyRelationNoChain(relation, src, dest, m_relation);
1526 nbModified++;
1527 }
1528 catch (const std::exception& )
1529 {
1530 SAPLOGINIT;
1531 LERROR << "relation (" << relation << "," << src << ","
1532 << dest << ") not modified";
1533 }
1534 std::tie(src,dest,relation) = syntacticData->relation();
1535 }
1536
1537 // return true is some additions worked (even if some did not work)
1538 return (nbModified>0);
1539}
1540
1541//----------------------------------------------------------------------
1543 const LimaString& complement):
1544 ConstraintFunction(language,complement)
1545{}
1546
1548{
1549/*
1550 Critical function : comment logging messages
1551*/
1552
1553// SAPLOGINIT;
1554// LDEBUG << "clearing stored relations";
1555
1556 auto syntacticData = std::dynamic_pointer_cast<SyntacticData>(analysis.getData("SyntacticData"));
1557
1558 syntacticData->clearStoredRelations();
1559 return true;
1560}
1561
1562} // end namespace
1563} // end namespace
1564} // end namespace
This file is the main header file for the data related to annotation graphs.
A graph that stores the relations of syntactic dependency between the elements of a DependencyGraph.
DependencyGraph::edge_descriptor DependencyGraphEdge
typedefs to simplify the acces to various graphs elements
DependencyGraph::in_edge_iterator DependencyGraphInEdgeIt
DependencyGraph::out_edge_iterator DependencyGraphOutEdgeIt
boost::property_map< DependencyGraph, edge_deprel_type_t >::type EdgeDepRelTypePropertyMap
DependencyGraph::vertex_descriptor DependencyGraphVertex
#define SAPLOGINIT
boost::property_map< DependencyGraph, edge_deprel_type_t >::const_type CEdgeDepRelTypePropertyMap
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, DepVertexProperties, DepEdgeProperties > DependencyGraph
The dependency graph class.
@ edge_deprel_type
#define SecondUngovernedById
#define CopyIncomingRelationsToId
#define FindRelationFromId
#define RemoveOutRelationFromId
#define CopyRelationsOutOfToId
#define EnforcePropertiesConstraintsId
#define ModifyRelationInGraphId
#define CreateEasyCompoundTenseId
#define SameVerbalChainId
#define AddRelationInGraphId
#define CreateRelationReverseWithRelatedId
#define SameNominalChainId
#define ClearStoredRelationsId
#define CreateRelationWithRelatedId
#define GovernedById
#define CreateRelationBetweenId
#define GovernorOfId
#define CreateCompoundTenseId
#define LWARN
Definition LimaCommon.h:160
#define LIMA_EXCEPTION(X)
This macro writes the message X to a previously configured error stream before throwing a LimaExcepti...
Definition LimaCommon.h:293
#define LDEBUG
Definition LimaCommon.h:157
#define LINFO
Definition LimaCommon.h:158
#define LERROR
Definition LimaCommon.h:161
LinguisticGraph::in_edge_iterator LinguisticGraphInEdgeIt
std::set< Lima::LinguisticProcessing::LinguisticAnalysisStructure::ChainIdStruct > VertexChainIdProp
Property to identify the chains in the graph.
boost::property_map< LinguisticGraph, vertex_chain_id_t >::type VertexChainIdPropertyMap
boost::property_map< LinguisticGraph, vertex_data_t >::type VertexDataPropertyMap
boost::graph_traits< LinguisticGraph >::edge_descriptor LinguisticGraphEdge
typedefs to simplify the access to various graphs elements
boost::property_map< LinguisticGraph, vertex_token_t >::type VertexTokenPropertyMap
@ vertex_token
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
boost::property_map< LinguisticGraph, vertex_chain_id_t >::const_type CVertexChainIdPropertyMap
@ vertex_data
LinguisticGraph::out_edge_iterator LinguisticGraphOutEdgeIt
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
@ vertex_chain_id
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.
Holds linguistic data for one language.
QString getLimaToLanguageCodeMappingValue(const QString &code) const
Access to an element of the code mapping.
SyntacticRelationId getSyntacticRelationId(const std::string &name) const
const PropertyCode::PropertyCodeManager & getPropertyCodeManager() const
const FsaStringsPool & stringsPool(MediaId med) const
const MediaData & mediaData(MediaId media) const
const std::string & media(MediaId media) const
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.
const PropertyAccessor & getPropertyAccessor(const std::string &propertyName) const
Get the PropertyAccessor associated to a property.
LinguisticCode getPropertyValue(const std::string &symbolicValue) const
Get the coded property value from the symbolic value.
ConstraintFunction(MediaId language, const LimaString &complement=LimaString())
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.
LinguisticCode firstValue(const Common::PropertyCode::PropertyAccessor &propertyAccessor) const
Return the first non empty value for the given accessor.
std::set< LinguisticCode > allValues(const Common::PropertyCode::PropertyAccessor &propertyAccessor) const
void setStatus(const TStatus &status)
Set the TStatus of a token.
Definition Token.h:100
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
AddRelationInGraph(MediaId language, const LimaString &complement=LimaString())
bool operator()(AnalysisContent &analysis) const override
zero-ary constraint function : applies the function without a vertex indication (used for actions,...
ClearStoredRelations(MediaId language, const LimaString &complement=LimaString())
ConstraintWithRelationComplement(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
CopyIncomingRelationsTo(MediaId language, const LimaString &complement=LimaString())
CopyRelationsOutOfTo(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
CreateCompoundTense(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
CreateEasyCompoundTense(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
CreateRelationBetween(MediaId language, const LimaString &complement=LimaString())
CreateRelationReverseWithRelated(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
CreateRelationWithRelated(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
std::vector< LinguisticGraphVertex > findRelatedVertices(const LinguisticGraphVertex &v, SyntacticData *syntacticData) const
std::set< Common::MediaticData::SyntacticRelationId > m_relationsToFollow
EnforcePropertiesConstraints(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
FindRelationFrom(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
GovernedBy(MediaId language, const LimaString &complement=LimaString())
GovernorOf(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
ModifyRelationInGraph(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, AnalysisContent &analysis) const override
unary constraint function : the constraint only applies on one vertices in the graph (the graph is al...
RemoveOutRelationFrom(MediaId language, const LimaString &complement=LimaString())
SameNominalChain(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
SameVerbalChain(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
SecondUngovernedBy(MediaId language, const LimaString &complement=LimaString())
bool operator()(const LinguisticAnalysisStructure::AnalysisGraph &graph, const LinguisticGraphVertex &v1, const LinguisticGraphVertex &v2, AnalysisContent &analysis) const override
binary constraint function : the constraint only applies on two vertices in the graph (the graph is a...
This class points to a graph, its dependency graph and the structure that holds the maping between th...
std::vector< LinguisticGraphVertex > findRelated(const LinguisticGraphVertex, const Common::MediaticData::SyntacticRelationId &relation)
find vertices related to a given vertex by a given relation (related vertices can be either source or...
static const MediaticData & single()
Definition Singleton.h:51
static MediaticData & changeable()
Definition Singleton.h:71
AnnotationGraph::vertex_descriptor AnnotationGraphVertex
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)
Automaton::ConstraintFunctionFactory< CreateRelationBetween > CreateRelationBetweenFactory(CreateRelationBetweenId)
Automaton::ConstraintFunctionFactory< AddRelationInGraph > AddRelationInGraphFactory(AddRelationInGraphId)
Automaton::ConstraintFunctionFactory< RemoveOutRelationFrom > RemoveOutRelationFromFactory(RemoveOutRelationFromId)
Automaton::ConstraintFunctionFactory< CreateEasyCompoundTense > CreateEasyCompoundTenseFactory(CreateEasyCompoundTenseId)
Automaton::ConstraintFunctionFactory< EnforcePropertiesConstraints > EnforcePropertiesConstraintsFactory(EnforcePropertiesConstraintsId)
Automaton::ConstraintFunctionFactory< CopyIncomingRelationsTo > CopyIncomingRelationsToFactory(CopyIncomingRelationsToId)
Automaton::ConstraintFunctionFactory< CreateRelationReverseWithRelated > CreateRelationReverseWithRelatedFactory(CreateRelationReverseWithRelatedId)
Automaton::ConstraintFunctionFactory< CreateRelationWithRelated > CreateRelationWithRelatedFactory(CreateRelationWithRelatedId)
Automaton::ConstraintFunctionFactory< ModifyRelationInGraph > ModifyRelationInGraphFactory(ModifyRelationInGraphId)
Automaton::ConstraintFunctionFactory< GovernedBy > GovernedByFactory(GovernedById)
Automaton::ConstraintFunctionFactory< CopyRelationsOutOfTo > CopyRelationsOutOfToFactory(CopyRelationsOutOfToId)
Automaton::ConstraintFunctionFactory< SameNominalChain > SameNominalChainFactory(SameNominalChainId)
Automaton::ConstraintFunctionFactory< CreateCompoundTense > CreateCompoundTenseFactory(CreateCompoundTenseId)
Automaton::ConstraintFunctionFactory< SecondUngovernedBy > SecondUngovernedByFactory(SecondUngovernedById)
Automaton::ConstraintFunctionFactory< GovernorOf > GovernorOfFactory(GovernorOfId)
Automaton::ConstraintFunctionFactory< ClearStoredRelations > ClearStoredRelationsFactory(ClearStoredRelationsId)
Automaton::ConstraintFunctionFactory< FindRelationFrom > FindRelationFromFactory(FindRelationFromId)
Automaton::ConstraintFunctionFactory< SameVerbalChain > SameVerbalChainFactory(SameVerbalChainId)
NAUTITIA.
QString LimaString
Definition LimaString.h:33