LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
ngrampaths.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
16
17using namespace boost;
18
19namespace Lima
20{
21namespace LinguisticProcessing {
22namespace PosTagger
23{
24
30void buildThreeVerticesPaths(PhoenixGraphVertex& v, const PhoenixLingGraph& g,
31 std::vector<TriGramPaths>& trigramPathsVector)
32{
34
35 LDEBUG << "====> Call of buildThreeVerticesPaths(" << v << "):";
36
37 // Pile contenant les noeuds adjacents au noeud v
38 std::stack<PhoenixGraphVertex> verticesStack;
39
40 // Objet temporaire du type TriGramPaths
41 TriGramPaths tempTrigramPaths;
42
43 // Pile Contenant les categories grammaticales des noeuds adjacents au noeud v
44 std::stack<uint64_t> lingInfoStack;
45 graph_traits<PhoenixLingGraph>::adjacency_iterator first_ai, first_a_end;
46
47 // Property Map entre les noeuds du graphe et leurs informations linguistiques
48 CVertexWordPropertyMap wordMap = get
49 (vertex_word, g);
50
51 // Boucle pour visiter tous les noeuds adjacents au noeud v
52 for (boost::tie(first_ai, first_a_end) = adjacent_vertices(v, g); first_ai != first_a_end; first_ai++)
53 {
54 // Pile contenant les noeuds adjacents au noeud v
55 verticesStack.push(*first_ai);
56
57 // Pile Contenant les catégories grammaticales des noeuds adjacents (suivants) au noeud v
58 lingInfoStack.push(wordMap[*first_ai].microCategory());
59 }
60
61 // Boucle pour visiter tous les noeuds adjacents aux noeuds adjacents au noeud v
62 graph_traits<PhoenixLingGraph>::adjacency_iterator second_ai, second_a_end;
63
64 while (!verticesStack.empty() && !lingInfoStack.empty())
65 {
66 for (boost::tie(second_ai, second_a_end) = adjacent_vertices(verticesStack.top(), g); second_ai !=
67 second_a_end; second_ai++)
68 {
69 // Catégorie grammaticale du noeud v
70 tempTrigramPaths.m_firstTriGramMicroCategory = wordMap[v].microCategory();
71
72 // Catégorie grammaticale du noeud adjacent au noeud v
73 tempTrigramPaths.m_secondTriGramMicroCategory = lingInfoStack.top();
74
75 // Catégorie grammaticale du noeud adjacent du noeud adjacent au noeud v
76 tempTrigramPaths.m_thirdTriGramMicroCategory = wordMap[*second_ai].microCategory();
77
78 // Noeud adjacent au noeud v
79 tempTrigramPaths.m_vertexTriGramPath = verticesStack.top();
80
81 // Vecteur de structures en Trigrams pour le noeud v
82 trigramPathsVector.push_back(tempTrigramPaths);
83 }
84
85 // Pile contenant les noeuds adjacents au noeud v
86 verticesStack.pop();
87
88 // Pile Contenant les catégories grammaticales des noeuds adjacents au noeud v
89 lingInfoStack.pop();
90 }
91}
92
98void buildParticularCaseThreeVerticesPaths(PhoenixGraphVertex& v, const PhoenixLingGraph& g,
99 std::vector<TriGramPaths>& trigramPathsVector)
100{
101 PTLOGINIT;
102
103 LDEBUG << "====> Call of buildParticularCaseThreeVerticesPaths(" << v << "):";
104
105 // Pile contenant les noeuds adjacents au noeud v
106 std::stack<PhoenixGraphVertex> verticesStack;
107
108 // Objet temporaire du type TriGramPaths
109 TriGramPaths tempTrigramPaths;
110
111 // Pile Contenant les catégories grammaticales des noeuds adjacents au noeud v
112 std::stack<uint64_t> lingInfoStack;
113 graph_traits<PhoenixLingGraph>::adjacency_iterator first_ai, first_a_end;
114
115 // Property Map entre les noeuds du graphe et leurs informations linguistiques
116 CVertexWordPropertyMap wordMap = get
117 (vertex_word, g);
118
119 // Boucle pour visiter tous les noeuds adjacents (suivants) au noeud v
120 for (boost::tie(first_ai, first_a_end) = adjacent_vertices(v, g); first_ai != first_a_end; first_ai++)
121 {
122 // Pile contenant les noeuds adjacents (suivants) au noeud v
123 verticesStack.push(*first_ai);
124
125 // Pile Contenant les catégories grammaticales des noeuds adjacents (suivants) au noeud v
126 lingInfoStack.push(wordMap[*first_ai].microCategory());
127 }
128
129 // Boucle pour visiter tous les noeuds adjacents aux noeuds adjacents au noeud v
130 graph_traits<PhoenixLingGraph>::adjacency_iterator second_ai, second_a_end;
131
132 while (!verticesStack.empty() && !lingInfoStack.empty())
133 {
134 for (boost::tie(second_ai, second_a_end) = adjacent_vertices(verticesStack.top(), g); second_ai !=
135 second_a_end; second_ai++)
136 {
137 // Catégorie grammaticale du noeud v
138 tempTrigramPaths.m_firstTriGramMicroCategory = wordMap[v].microCategory();
139
140 // Catégorie grammaticale du noeud adjacent au noeud v
141 tempTrigramPaths.m_secondTriGramMicroCategory = lingInfoStack.top();
142
143 // Catégorie grammaticale du noeud adjacent du noeud adjacent au noeud v
144 tempTrigramPaths.m_thirdTriGramMicroCategory = wordMap[*second_ai].microCategory();
145
146 // Cas particulier: Noeud adjacent du noeud adjacent du noeud v
147 tempTrigramPaths.m_vertexTriGramPath = *second_ai;
148
149 // Vecteur de structures en Trigrams pour le noeud v
150 trigramPathsVector.push_back(tempTrigramPaths);
151 }
152
153 // Pile contenant les noeuds adjacents au noeud v
154 verticesStack.pop();
155
156 // Pile Contenant les catégories grammaticales des noeuds adjacents au noeud v
157 lingInfoStack.pop();
158 }
159}
160
166void buildTwoVerticesPaths(PhoenixGraphVertex& v,
167 const PhoenixLingGraph& g, std::vector<BiGramPaths>& bigramPathsVector)
168{
169 PTLOGINIT;
170
171 LDEBUG << "====> Call of buildTwoVerticesPaths(" << v << "):";
172
173 // Objet temporaire du type TriGramPaths
174 BiGramPaths tempBiGramPaths;
175 graph_traits<PhoenixLingGraph>::adjacency_iterator ai, a_end;
176
177 // Property Map entre les noeuds du graphe et leurs informarions linguistiques
178 CVertexWordPropertyMap wordMap = get
179 (vertex_word, g);
180
181 // Boucle pour visiter tous les noeuds adjacents (suivants) au noeud v
182 for (boost::tie(ai, a_end) = adjacent_vertices(v, g); ai != a_end; ai++)
183 {
184 // Catégorie grammaticale du noeud v
185 tempBiGramPaths.m_firstBiGramMicroCategory = wordMap[v].microCategory();
186
187 // Catégorie grammaticale du noeud adjacent au noeud v
188 tempBiGramPaths.m_secondBiGramMicroCategory = wordMap[*ai].microCategory();
189
190 // Noeud adjacent au noeud v
191 tempBiGramPaths.m_vertexBiGramPath = *ai;
192
193 // Vecteur de structures en Bigrams pour le noeud v
194 bigramPathsVector.push_back(tempBiGramPaths);
195 }
196}
197
198} // closing namespace PosTagger
199} // closing namespace LinguisticProcessing
200} // cmosing namespace Lima
#define LDEBUG
Definition LimaCommon.h:157
#define PTLOGINIT
void buildTwoVerticesPaths(PhoenixGraphVertex &v, const PhoenixLingGraph &g, std::vector< BiGramPaths > &bigramPathsVector)
Retourne un vecteur de structures de type BiGramPaths (Le troisième champ de la structure est le noeu...
void buildThreeVerticesPaths(PhoenixGraphVertex &v, const PhoenixLingGraph &g, std::vector< TriGramPaths > &trigramPathsVector)
Retourne un vecteur de structures de type TriGramPaths (Le quatrième champ de la structure est le noe...
void buildParticularCaseThreeVerticesPaths(PhoenixGraphVertex &v, const PhoenixLingGraph &g, std::vector< TriGramPaths > &trigramPathsVector)
Retourne un vecteur de structures de type TriGramPaths (Le quatrième champ de la structure est le noe...
NAUTITIA.
Creation of vectors of structures of Trigrams and Bigrams *.
Structure contenant les deux catégories grammaticales ainsi que le noeud adjacent au noeud donné
Definition ngrampaths.h:55
Structure contenant les trois catégories grammaticales ainsi que le noeud adjacent au noeud donné
Definition ngrampaths.h:32