LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
Paragraph.cpp
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 * @file Paragraph.cpp
8 * @author Faiza GARA
9 * @date October 2008
10 * @version $Id:
11 * copyright Copyright (C) 2008 by CEA LIST
12 *
13 ***********************************************************************/
14
15
16#include "Paragraph.h"
17
21
22
23
24using namespace std;
26
27namespace Lima {
28namespace LinguisticProcessing
29{
30
31namespace EventAnalysis
32{
33
34//**********************************************************************
35// constructors,destructor,copy assignment
36//**********************************************************************
37Paragraph::Paragraph(): m_sentences(),m_otherentities(),m_evententities(),m_dates(),m_length(0),m_position(0),m_id(0)
38{
39}
40
41
42
44{
45 m_otherentities.clear();
46 m_evententities.second.clear();
47 m_sentences.clear();
48 m_dates.clear();
49}
50
51std::pair<Common::MediaticData::EntityType,std::deque<LinguisticGraphVertex> > Paragraph::extractEventEntitiesBeforeVertex(LinguisticGraphVertex v,LinguisticGraph* graph)
52{
54 LDEBUG << "Paragraph::extractEventEntitiesBeforeVertex m_evententities.first " << m_evententities.first;
55 std::deque<LinguisticGraphVertex> evententities;
56 Token *token=get(vertex_token,*graph,v);
57
58 bool end =m_evententities.second.empty();
59 while (! end)
60 {
61 LinguisticGraphVertex v_event = m_evententities.second.front();
62 Token *token_event=get(vertex_token,*graph,v_event);
63 if(token_event->position() > token->position())
64 end=true;
65 else
66 {
67 evententities.push_back(v_event);
68 m_evententities.second.pop_front();
69 end =m_evententities.second.empty();
70 }
71 }
72 return make_pair(m_evententities.first,evententities);
73
74}
75
77{
78 bool res=false;
79
80 if (m_otherentities.find(t)!=m_otherentities.end())
81 {
82 return true;
83 }
84
85 if (m_evententities.first==t && m_evententities.second.size()> 0) return true;
86
87 return res;
88}
89
90std::map<Common::MediaticData::EntityType, std::deque<LinguisticGraphVertex> > Paragraph::extractEntitiesBeforeVertex(LinguisticGraphVertex v,LinguisticGraph* graph)
91{
92 std::map<Common::MediaticData::EntityType, std::deque<LinguisticGraphVertex> > entities;
93 Token *token=get(vertex_token,*graph,v);
94 for(std::map<Common::MediaticData::EntityType, std::deque<LinguisticGraphVertex> >::iterator iT =m_otherentities.begin();iT !=m_otherentities.end();iT++)
95 {
96 bool end =(*iT).second.empty();
97 std::deque<LinguisticGraphVertex> d;
98 while (! end)
99 {
100
101 LinguisticGraphVertex v_entity = (*iT).second.front();
102 Token *token_entity=get(vertex_token,*graph,v_entity);
103 if(token_entity->position() > token->position())
104 end=true;
105 else
106 {
107 d.push_back(v_entity);
108 (*iT).second.pop_front();
109 end =(*iT).second.empty();
110 }
111 }
112 if(d.size()>0) entities[(*iT).first]=d;
113 }
114
115 return entities;
116}
117
118
119
120} // namespace
121} // namespace
122} // namespace Lima
#define LDEBUG
Definition LimaCommon.h:157
@ vertex_token
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
#define EVENTANALYZERLOGINIT
std::map< Common::MediaticData::EntityType, std::deque< LinguisticGraphVertex > > extractEntitiesBeforeVertex(LinguisticGraphVertex v, LinguisticGraph *graph)
Definition Paragraph.cpp:90
std::pair< Common::MediaticData::EntityType, std::deque< LinguisticGraphVertex > > extractEventEntitiesBeforeVertex(LinguisticGraphVertex v, LinguisticGraph *graph)
Definition Paragraph.cpp:51
bool has_entity(Common::MediaticData::EntityType t) const
Definition Paragraph.cpp:76
NAUTITIA.
STL namespace.
static const struct TextHtmlEntity entities[]