LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
ltrText.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
16#ifndef LIMA_COMMON_BAGOFWORDS__LTR_TEXT__H
17#define LIMA_COMMON_BAGOFWORDS__LTR_TEXT__H
18
20#include "ltrToken.h"
22
23#include <vector>
24#include <iostream>
25#include <boost/shared_ptr.hpp>
26
27
28namespace Lima {
29namespace Common {
30namespace BagOfWords {
31
32class LTR_Text;
33LIMA_LINEARTEXTREPRESENTATION_EXPORT std::ostream& operator<<(std::ostream& os, const LTR_Text& text);
34LIMA_LINEARTEXTREPRESENTATION_EXPORT QDebug& operator<<(QDebug& os, const LTR_Text& text);
35
41class LIMA_LINEARTEXTREPRESENTATION_EXPORT LTR_Text : public std::vector< boost::shared_ptr<LTR_Token> > {
42
43private: // -- types
44 typedef std::vector<uint64_t> SENTENCE_BOUNDS_T;
45 typedef std::deque<std::pair<
46 Lima::Common::BagOfWords::BoWNamedEntity*, uint64_t> > NAMED_ENTITIES_T;
47
48public: // -- types
49 typedef SENTENCE_BOUNDS_T::const_iterator SENTS_CONST_ITER_T;
50
51public: // -- methods
55 virtual ~LTR_Text() {this->clear();};
56 //}@
57
60 std::string getId() const {
61 return m_id;
62 }
63 void setId(const std::string& id) {
64 m_id = id;
65 }
66 //}@
67
70 LTR_Text(const LTR_Text& text);
71// LTR_Text& operator=(const LTR_Text&);
72 //}@
73
75 // redefines the clear from base vector class to clear also sentence boundaries
76 void clear() {
77 // free tokens
78// for (LTR_Text::const_iterator itTok = this->begin();
79// itTok != this->end(); ++ itTok) {
80// if(*itTok) delete *itTok;
81// }
82 std::vector< boost::shared_ptr<LTR_Token> >::clear();
83 m_sentenceBounds.clear();
84 m_namedEntities.clear();
85 }
86
90 return m_sentenceBounds.begin();
91 }
93 return m_sentenceBounds.end();
94 }
95 //}@
96
99 void addToken(boost::shared_ptr<LTR_Token>& token);
100 void addSentenceBound(const uint64_t& sb);
101 void appendLTR_Text(const LTR_Text& ltr);
102 //}@
103
106 void binaryWriteOn(std::ostream& os) const;
107 void binaryReadFrom(std::istream& is);
108 //}@
109
112 friend LIMA_LINEARTEXTREPRESENTATION_EXPORT std::ostream& operator<<(std::ostream& os, const LTR_Text& text);
113 friend LIMA_LINEARTEXTREPRESENTATION_EXPORT QDebug& operator<<(QDebug& os, const LTR_Text& text);
114 //}@
115
116
117private: // -- methods
120 // prevent from using affectation
121 LTR_Text& operator=(const LTR_Text&) = delete;
122 //}@
123
124private: // -- data
125 SENTENCE_BOUNDS_T m_sentenceBounds;
128 std::string m_id;
129 NAMED_ENTITIES_T m_namedEntities;
130};
131
132
133} // BagOfWords
134} // Common
135} // Lima
136
137
138#endif // LIMA_COMMON_BAGOFWORDS__LTR_TEXT__H
QDebug & operator<<(QDebug &qd, const std::string &str)
Definition QsLog.cpp:39
#define LIMA_LINEARTEXTREPRESENTATION_EXPORT
This is a complex token used to represent a named entity token.
a linear text representation
Definition ltrText.h:41
SENTS_CONST_ITER_T endSentenceBounds() const
Definition ltrText.h:92
std::string getId() const
Definition ltrText.h:60
SENTS_CONST_ITER_T beginSentenceBounds() const
Definition ltrText.h:89
void setId(const std::string &id)
Definition ltrText.h:63
SENTENCE_BOUNDS_T::const_iterator SENTS_CONST_ITER_T
Definition ltrText.h:49
=======================================================================
T & operator<<(T &qd, const BoWType &bt)
NAUTITIA.