LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
bowComplexToken.h
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
6/************************************************************************
7 * @file bowComplexToken.h
8 * @author Besancon Romaric
9 * @date Tue Oct 7 2003
10 * copyright Copyright (C) 2003 by CEA LIST
11 *
12 * @brief
13 *
14 ***********************************************************************/
15
16#ifndef BOWCOMPLEXTOKEN_H
17#define BOWCOMPLEXTOKEN_H
18
20#include "bowToken.h"
21
22#include <boost/tuple/tuple.hpp>
23#include <deque>
24
25#include <boost/shared_ptr.hpp>
26
27namespace Lima {
28namespace Common {
29namespace BagOfWords {
30
31
32
33class BoWRelation;
34
35class BoWComplexTokenPrivate;
43{
45public:
46
53 class Part : public boost::tuple< boost::shared_ptr< BoWRelation >,
54 boost::shared_ptr< BoWToken > >
55 {
56 public:
57 Part() :
58 boost::tuple< boost::shared_ptr< BoWRelation >,
59 boost::shared_ptr< BoWToken > >(boost::shared_ptr< BoWRelation >(),
60 boost::shared_ptr< BoWToken >() )
61 {
62 }
63
64 Part(boost::shared_ptr< BoWToken > tok):
65 boost::tuple< boost::shared_ptr< BoWRelation >,
66 boost::shared_ptr< BoWToken > >(boost::shared_ptr< BoWRelation >(),
67 tok)
68 {
69 }
70
71 Part(boost::shared_ptr< BoWRelation > rel,
72 boost::shared_ptr< BoWToken > tok) :
73 boost::tuple< boost::shared_ptr< BoWRelation >,
74 boost::shared_ptr< BoWToken >>(rel,tok)
75 {
76 }
77
78 boost::shared_ptr< BoWRelation > getBoWRelation() const { return get<0>(); }
79
80 boost::shared_ptr< BoWToken > getBoWToken() const { return get<1>(); }
81
82 LimaString getLemma() const { return get<1>()->getLemma(); }
83
84 LinguisticCode getCategory() const { return get<1>()->getCategory(); }
85 };
86
88// /**
89// * copy constructor
90// *
91// * @attention the copy of the parts of a complex token is tricky :
92// * if a part of a complex token points to a token that have a proper
93// * existence outside of the part list, the pointer will be copied
94// * (no creation of a new object), otherwise a new object is created.
95// */
96// BoWComplexToken(const BoWComplexToken&);
97//
98// /**
99// * specialized copy constructor that takes into account a
100// * pointer-to-pointer map giving the correspondance of tokens for
101// * the component list, in case of a complete BoWText copy.
102// *
103// */
104// BoWComplexToken(const BoWComplexToken&,
105// const std::map<BoWToken*,BoWToken*>&);
106
108 const LinguisticCode category,
109 const uint64_t position,
110 const uint64_t length);
111
127 const LinguisticCode category,
128 const uint64_t position,
129 const uint64_t length,
130 std::deque< boost::shared_ptr< Lima::Common::BagOfWords::BoWToken > >& parts,
131 const uint64_t head);
132
133 virtual ~BoWComplexToken();
134
135// virtual BoWComplexToken* clone() const;
136// virtual BoWComplexToken* clone(const std::map<BoWToken*,BoWToken*>&) const;
137
138 virtual void clear() override;
139
140 virtual Lima::LimaString getLemma(void) const override;
141 virtual Lima::LimaString getInflectedForm(void) const override;
142
143 BoWComplexToken& operator= (const BoWComplexToken&);
144 bool operator== (const BoWComplexToken&);
145
147 uint64_t size(void) const override;
148
149 std::deque< Part >& getParts(void);
150 const std::deque< Part >& getParts(void) const;
151
152 std::deque< Part >::iterator getPartsIterator(void);
153 const std::deque< Part >::const_iterator getPartsIterator(void) const;
154
167 boost::shared_ptr< BoWToken > addPart(boost::shared_ptr< BoWToken > tok,
168 const bool isHead=false);
169
184 boost::shared_ptr< BoWToken > addPart(boost::shared_ptr< BoWRelation > rel,
185 boost::shared_ptr< BoWToken > tok,
186 const bool isHead=false);
187
196// BoWToken* addPart(const boost::shared_ptr< BoWToken > tok,
197// // const bool isInList,
198// const bool isHead=false);
199
210// BoWToken* addPart(const boost::shared_ptr< BoWRelation > rel,
211// const boost::shared_ptr< BoWToken > tok,
212// // const bool isInList,
213// const bool isHead=false);
214
215
216
217 uint64_t getHead() const;
218 void setHead(const uint64_t);
219
220 // this is an abstract class, has no type
221 virtual BoWType getType() const override = 0;
222
223 // common function for output of derived classes
224 std::string getUTF8StringParts(const Common::PropertyCode::PropertyManager* macroManager = 0) const;
225 std::string getstdstringParts() const;
226
227 virtual Common::Misc::PositionLengthList getPositionLengthList() const override;
228
235 void addToPosition(const uint64_t offset) override;
236
237
243 virtual std::set< uint64_t > getVertices() const override;
244
245protected:
247};
248
249
250} // namespace BagOfWords
251} // namespace Common
252} // namespace Lima
253
254#endif
#define LIMA_BOW_EXPORT
This class represents a part of a ComplexToken : it is composed of a pointer on the actual part (a Bo...
boost::shared_ptr< BoWToken > getBoWToken() const
Part(boost::shared_ptr< BoWToken > tok)
boost::shared_ptr< BoWRelation > getBoWRelation() const
Part(boost::shared_ptr< BoWRelation > rel, boost::shared_ptr< BoWToken > tok)
This is a complex token for an index.
BoWComplexToken(const Lima::LimaString &lemma, const LinguisticCode category, const uint64_t position, const uint64_t length)
BoWComplexToken(const Lima::LimaString &lemma, const LinguisticCode category, const uint64_t position, const uint64_t length, std::deque< boost::shared_ptr< Lima::Common::BagOfWords::BoWToken > > &parts, const uint64_t head)
a constructor to build a simple, independent complex token (parts are simple tokens,...
virtual BoWType getType() const override=0
This class is used to type the relation between a part and its enclosing complex token.
Definition BoWRelation.h:50
This class contains the representation of an element of the bag of words.
Definition bowToken.h:46
Provide tools to manage a specific property.
BoWType
enum to characterize the type of the AbstractBoWElement
std::vector< std::pair< Position, Length > > PositionLengthList
NAUTITIA.
QString LimaString
Definition LimaString.h:33