LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
corefSolver.h
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
17#ifndef LIMA_COREFSOLVING_COREFSOLVER_H
18#define LIMA_COREFSOLVING_COREFSOLVER_H
19
20#include "CorefSolvingExport.h"
27
28#include <string>
29
30
31namespace Lima
32{
33namespace Common {
34namespace AnnotationGraphs {
35 class AnnotationData;
36}
37}
38namespace LinguisticProcessing
39{
40namespace SyntacticAnalysis {
41class SyntacticData;
42}
43namespace LinguisticAnalysisStructure {
44class AnalysisGraph;
45}
46namespace Coreferences
47{
48class CoreferentAnnotation;
49
50#define COREFSOLVINGPU_CLASSID "CoreferencesSolving"
51
52typedef std::set<CoreferentAnnotation*> Vertices;
53typedef std::map<CoreferentAnnotation*,std::set<CoreferentAnnotation*> > VerticesRelation;
54typedef std::map< CoreferentAnnotation*,std::map <CoreferentAnnotation*,float> > WeightedVerticesRelation;
55
56
57
81{
82public:
84
85 virtual ~CorefSolver() {}
86
87 void init(
89 Manager* manager) override;
90
91 LimaStatusCode process(AnalysisContent& analysis) const override;
92
93
94 MediaId language() const;
95 uint64_t scope() const;
96 uint64_t threshold() const;
97 bool resolveDefinites() const;
98 bool resolveN3PPronouns() const;
99 std::set< LinguisticCode > inNpCategs() const;
100 std::set< LinguisticCode > definiteCategs() const;
101 LinguisticCode L_PRON() const;
102 LinguisticCode L_VERB() const;
103 LinguisticCode L_PREP() const;
104 std::map<std::string,LinguisticCode> tagLocalDef() const;
105 std::map< std::string,std::deque<std::string> > relLocalDef() const;
106 std::set<LinguisticCode> reflexiveReciprocal() const;
107 std::set<LinguisticCode> undefPronouns() const;
108 std::set<LinguisticCode> possPronouns() const;
109 const Common::PropertyCode::PropertyAccessor* macroAccessor() const;
110 const Common::PropertyCode::PropertyAccessor* microAccessor() const;
111 const Common::PropertyCode::PropertyAccessor* genderAccessor() const;
112 const Common::PropertyCode::PropertyAccessor* personAccessor() const;
113 const Common::PropertyCode::PropertyAccessor* numberAccessor() const;
114 const std::map<std::string,float> salienceWeights() const;
115 const std::map<std::string, int> slotValues() const;
116
117
118private:
119 void initSyntacticFilter(
120 AnalysisContent& ac,
124 std::deque<CoreferentAnnotation::Vertices>* npCandidates,
126
127 void bindingLexicalAnaphora(
128 AnalysisContent& ac,
132 std::deque<CoreferentAnnotation::Vertices>* npCandidates,
134
135 void bindingPotentialCandidates(
136 //Common::AnnotationGraphs::AnnotationData* ad,
138 // LinguisticProcessing::SyntacticAnalysis::SyntacticData* syntacticData,
140 std::deque<CoreferentAnnotation::Vertices>* npCandidates,
142
143 void getBest(
147// std::vector<std::pair<CoreferentAnnotation, CoreferentAnnotation> >* results,
148 std::deque<CoreferentAnnotation::Vertices>* npCandidates,
150
151 void applyEquivalentClassFilter(
152 const LinguisticGraph* graph,
153 std::deque<CoreferentAnnotation::Vertices>* npCandidates) const;
154
155 void adjustSaliences(
157 std::deque<Vertices>* npCandidates,
159 LinguisticGraphVertex endSentence,
161 AnalysisContent& ac) const;
162
163 void applyThresholdFilter(
165
166 void applyMorphoSyntacticFilter(
169 void applyCircularFilter(WeightedVerticesRelation* pBinding) const;
170
171
172protected:
173 MediaId m_language;
174 uint64_t m_scope;
175 uint64_t m_threshold;
178 std::set< LinguisticCode > m_inNpCategs;
179 std::set< LinguisticCode > m_definiteCategs;
180 std::map<std::string,LinguisticCode> m_tagLocalDef;
181 std::map< std::string,std::deque<std::string> > m_relLocalDef;
182 std::set<LinguisticCode> m_reflexiveReciprocal;
183 std::set<LinguisticCode> m_undefPronouns;
184 std::set<LinguisticCode> m_possPronouns;
187 // const Common::PropertyCode::PropertyManager& m_microManager;
192 std::map<std::string,float> m_salienceWeights;
193 std::map<std::string, int> m_slotValues;
194};
195
196inline MediaId CorefSolver::language() const
197{
198 return m_language;
199}
200inline uint64_t CorefSolver::scope() const
201{
202 return m_scope;
203}
204inline uint64_t CorefSolver::threshold() const
205{
206 return m_threshold;
207}
209{
210 return m_resolveDefinites;
211}
213{
215}
216inline std::set< LinguisticCode > CorefSolver::inNpCategs() const
217{
218 return m_inNpCategs;
219}
220inline std::set< LinguisticCode > CorefSolver::definiteCategs() const
221{
222 return m_definiteCategs;
223}
225{
226 return (*m_tagLocalDef.find("PRON")).second;
227}
229{
230 return (*m_tagLocalDef.find("V")).second;
231}
233{
234 return (*m_tagLocalDef.find("PREP")).second;
235}
236inline std::map<std::string,LinguisticCode> CorefSolver::tagLocalDef() const
237{
238 return m_tagLocalDef;
239}
240inline std::map< std::string,std::deque<std::string> > CorefSolver::relLocalDef() const
241{
242 return m_relLocalDef;
243}
244inline std::set<LinguisticCode> CorefSolver::reflexiveReciprocal() const
245{
247}
248inline std::set<LinguisticCode> CorefSolver::undefPronouns() const
249{
250 return m_undefPronouns;
251}
252inline std::set<LinguisticCode> CorefSolver::possPronouns() const
253{
254 return m_possPronouns;
255}
260inline
265inline
270inline
275inline
280inline
281 const std::map<std::string,float> CorefSolver::salienceWeights() const
282{
283 return m_salienceWeights;
284}
285 const std::map<std::string,int> CorefSolver::slotValues() const
286{
287 return m_slotValues;
288}
289
290
291
292} // closing namespace Coreferences
293} // closing namespace LinguisticProcessing
294} // closing namespace Lima
295
296#endif // LIMA_COREFSOLVING_COREFSOLVER_H
#define LIMA_COREFSOLVING_EXPORT
A graph structure for linguistic analysis.
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
Holds an annotation graph and gives an API to manipulate it.
Provide function to read write and check a property.
A process unit implementing the Lappin & Leass algorithm for coreference solving The process unit con...
Definition corefSolver.h:81
const Common::PropertyCode::PropertyAccessor * m_numberAccessor
const Common::PropertyCode::PropertyAccessor * m_macroAccessor
std::set< LinguisticCode > reflexiveReciprocal() const
std::set< LinguisticCode > inNpCategs() const
const Common::PropertyCode::PropertyAccessor * m_personAccessor
std::map< std::string, LinguisticCode > tagLocalDef() const
const std::map< std::string, int > slotValues() const
const std::map< std::string, float > salienceWeights() const
const Common::PropertyCode::PropertyAccessor * numberAccessor() const
std::map< std::string, LinguisticCode > m_tagLocalDef
std::map< std::string, std::deque< std::string > > m_relLocalDef
std::set< LinguisticCode > undefPronouns() const
const Common::PropertyCode::PropertyAccessor * m_genderAccessor
const Common::PropertyCode::PropertyAccessor * m_microAccessor
std::set< LinguisticCode > definiteCategs() const
std::set< LinguisticCode > possPronouns() const
const Common::PropertyCode::PropertyAccessor * macroAccessor() const
std::map< std::string, std::deque< std::string > > relLocalDef() const
const Common::PropertyCode::PropertyAccessor * genderAccessor() const
const Common::PropertyCode::PropertyAccessor * microAccessor() const
const Common::PropertyCode::PropertyAccessor * personAccessor() const
std::map< CoreferentAnnotation *, std::set< CoreferentAnnotation * > > VerticesRelation
std::map< CoreferentAnnotation *, std::map< CoreferentAnnotation *, float > > WeightedVerticesRelation
An AnalysisData containing a LinguisticGraph with a language and an id.
This class points to a graph, its dependency graph and the structure that holds the maping between th...
std::set< CoreferentAnnotation * > Vertices
Definition corefSolver.h:52
std::map< CoreferentAnnotation *, std::set< CoreferentAnnotation * > > VerticesRelation
Definition corefSolver.h:53
std::map< CoreferentAnnotation *, std::map< CoreferentAnnotation *, float > > WeightedVerticesRelation
Definition corefSolver.h:54
NAUTITIA.
LimaStatusCode
Definition LimaCommon.h:236