LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
Paragraph.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
6/************************************************************************
7 *
8 * @file Paragraph.h
9 * @author Faiza GARA
10 * @date April 2008
11 * copyright Copyright (C) 2007 by CEA LIST
12 * version $Id:
13 *
14 * @brief
15 *
16 *
17 ***********************************************************************/
18
19#ifndef PARAGRAPH_H
20#define PARAGRAPH_H
21
22
23#include "EventAnalysisExport.h"
24#include <deque>
25#include <string>
26#include <iostream>
27
30
31namespace Lima {
32namespace LinguisticProcessing
33{
34
35namespace EventAnalysis
36{
37
45{
46public:
47 Paragraph();
48 ~Paragraph();
49
50 void addSentence(LinguisticGraphVertex);
52 void addEventEntities(Paragraph *p);
53 void addEntities(Paragraph *p);
54 void addEventEntities(std::pair<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> >);
55 void addEntities(std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> >);
56 void addSentences(Paragraph *p);
58 void addDate(std::string,LinguisticGraphVertex);
59 void setLength(uint64_t);
60 void setPosition(uint64_t);
61 void setId(uint64_t);
62 bool toFilter();
63 uint64_t getDatesSize();
64 uint64_t getSentencesSize();
65 std::pair<std::string,LinguisticGraphVertex> getDate();
66 std::pair<std::string,LinguisticGraphVertex> extractDate();
67
68 LinguisticGraphVertex extractSentence();
69 uint64_t getPosition();
70 uint64_t getLength();
71 uint64_t getId();
72
73 bool has_entity(Common::MediaticData::EntityType t) const;
74 std::pair<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > extractEventEntitiesBeforeVertex(LinguisticGraphVertex v,LinguisticGraph* graph);
75
76 std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > extractEntitiesBeforeVertex(LinguisticGraphVertex v,LinguisticGraph* graph);
77
78 std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > getOtherEntities() const;
79
80 std::pair<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > getEventEntities() const;
81
82private:
83 std::deque<LinguisticGraphVertex> m_sentences;
84 std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> >m_otherentities;
85 std::pair<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > m_evententities;
86 std::deque<std::pair<std::string, LinguisticGraphVertex> > m_dates;
87 uint64_t m_length;
88 uint64_t m_position;
89 uint64_t m_id;
90
91 std::deque<LinguisticGraphVertex> getSentences();
92 std::deque<std::pair<std::string, LinguisticGraphVertex> >getDates();
93
94 std::pair<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > extractEventEntitiesBeforeVertex(LinguisticGraphVertex);
95
96 std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > extractEntitiesBeforeVertex(LinguisticGraphVertex);
97};
98
99inline std::pair<std::string,LinguisticGraphVertex> Paragraph::getDate()
100{
101 return m_dates.front();
102}
103
104inline std::pair<std::string,LinguisticGraphVertex> Paragraph::extractDate()
105{
106 std::pair<std::string,LinguisticGraphVertex> date=m_dates.front();
107 m_dates.pop_front();
108 return date;
109}
110
112{
113 LinguisticGraphVertex s=m_sentences.front();
114 m_sentences.pop_front();
115 return s;
116}
117
119{
120 return (m_evententities.second.size()==0);
121}
122
123inline uint64_t Paragraph::getDatesSize()
124{
125 return (m_dates.size());
126}
127
129{
130 return (m_sentences.size());
131}
132
133
134
135inline uint64_t Paragraph::getPosition()
136{
137 return m_position;
138}
139
140inline uint64_t Paragraph::getId()
141{
142 return m_id;
143}
144
145inline uint64_t Paragraph::getLength()
146{
147 return m_length;
148}
149
150inline std::pair<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > Paragraph::getEventEntities() const
151{
152 return m_evententities;
153}
154
155inline std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > Paragraph::getOtherEntities() const
156{
157 return m_otherentities;
158}
159
160inline std::deque<LinguisticGraphVertex> Paragraph::getSentences()
161{
162 return m_sentences;
163}
164
165
166inline void Paragraph::setLength( uint64_t length ) {
167 m_length=length;
168}
169
170inline void Paragraph::setId( uint64_t id ) {
171 m_id=id;
172}
173
174inline void Paragraph::addDate(std::string date, LinguisticGraphVertex v) {
175 m_dates.push_back(make_pair(date,v));
176}
177
178inline void Paragraph::setPosition( uint64_t p ) {
179 m_position=p;
180}
181
182
184 if (m_otherentities.find(t) == m_otherentities.end())
185 {
186 std::deque<LinguisticGraphVertex> d;
187 d.push_back(e);
188 m_otherentities.insert(make_pair(t,d));
189 }
190 else
191 {
192 m_otherentities[t].push_back(e);
193 }
194
195}
196
198 m_sentences.push_back(s);
199}
200
201
203 if (m_evententities.first == t)
204 m_evententities.second.push_back(e);
205 else
206 {
207 m_evententities.first=t;
208 std::deque<LinguisticGraphVertex> d;
209 d.push_back(e);
210 m_evententities.second=d;
211 }
212}
213
215 std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > e = p->getOtherEntities();
216 for(std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> >::const_iterator iT=e.begin();iT!=e.end();iT++)
217 {
218 m_otherentities[(*iT).first].insert(m_otherentities[(*iT).first].end(),(*iT).second.begin(),(*iT).second.end());
219 }
220
221}
222
223inline void Paragraph::addEntities(std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > e) {
224 for(std::map<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> >::const_iterator iT=e.begin();iT!=e.end();iT++)
225 {
226 m_otherentities[(*iT).first].insert(m_otherentities[(*iT).first].end(),(*iT).second.begin(),(*iT).second.end());
227 }
228}
229
231 std::deque<LinguisticGraphVertex> s =p->getSentences();
232 m_sentences.insert(m_sentences.end(),s.begin(),s.end());
233}
234
235
237 std::deque<LinguisticGraphVertex> e =p->getEventEntities().second;
238 m_evententities.first=p->getEventEntities().first;
239 m_evententities.second.insert(m_evententities.second.begin(),e.begin(),e.end());
240}
241
242inline void Paragraph::addEventEntities(std::pair<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > e) {
243 m_evententities.first=e.first;
244 m_evententities.second.insert(m_evententities.second.begin(),e.second.begin(),e.second.end());
245}
246
247}
248}
249}// namespace Lima
250#endif
#define LIMA_EVENTANALISYS_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.
This class represents a list of elements, that are pointers on polymmorphic annotations that can be d...
Definition Paragraph.h:45
std::pair< std::string, LinguisticGraphVertex > extractDate()
Definition Paragraph.h:104
void addEntity(Common::MediaticData::EntityType, LinguisticGraphVertex)
Definition Paragraph.h:183
std::map< Common::MediaticData::EntityType, std::deque< LinguisticGraphVertex > > getOtherEntities() const
Definition Paragraph.h:155
std::pair< std::string, LinguisticGraphVertex > getDate()
Definition Paragraph.h:99
void addDate(std::string, LinguisticGraphVertex)
Definition Paragraph.h:174
void addEventEntity(Common::MediaticData::EntityType, LinguisticGraphVertex)
Definition Paragraph.h:202
std::pair< Common::MediaticData::EntityType, std::deque< LinguisticGraphVertex > > getEventEntities() const
Definition Paragraph.h:150
NAUTITIA.