LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
bowText.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 bowText.cpp
8
* @author Besancon Romaric
9
* @date Tue Oct 7 17:13:26 2003
10
* copyright Copyright (C) 2003 by CEA LIST
11
*
12
***********************************************************************/
13
14
#include "
bowText.h
"
15
#include "
bowToken.h
"
16
#include "
bowTerm.h
"
17
#include "
bowNamedEntity.h
"
18
#include "
common/Data/strwstrtools.h
"
19
20
#include "
linguisticProcessing/common/BagOfWords/bowBinaryReaderWriter.h
"
21
22
using namespace
std
;
23
24
namespace
Lima
{
25
namespace
Common {
26
namespace
BagOfWords {
27
28
29
//**********************************************************************
30
// constructors,destructor,copy assignment
31
//**********************************************************************
32
BoWText::BoWText
():
33
std
::vector<
boost
::shared_ptr<
AbstractBoWElement
> >()
34
{
35
#ifdef DEBUG_LP
36
BOWLOGINIT
;
37
LDEBUG
<<
"BoWText::BoWText()"
<<
this
;
38
#endif
39
}
40
41
42
BoWText::BoWText
(
const
BoWText
& t):
43
std
::vector<
boost
::shared_ptr<
AbstractBoWElement
> >()
44
{
45
#ifdef DEBUG_LP
46
BOWLOGINIT
;
47
LDEBUG
<<
"BoWText::BoWText(BoWText)"
<<
this
;
48
#endif
49
(*this) = t;
50
}
51
52
BoWText
&
BoWText::operator =
(
const
BoWText
& t)
53
{
54
#ifdef DEBUG_LP
55
BOWLOGINIT
;
56
LDEBUG
<<
"BoWText::operator="
<<
this
;
57
#endif
58
if
(
this
!= &t)
59
{
60
clear
();
61
// have to store a pointer map to handle references in
62
// the component lists of complex tokens
63
// std::map<AbstractBoWElement*,AbstractBoWElement*> pointerMap;
64
for
(BoWText::const_iterator i(t.begin());
65
i != t.end(); i++) {
66
boost::shared_ptr< AbstractBoWElement > tok( (*i)->clone(
/*pointerMap*/
) );
67
push_back(tok);
68
// pointerMap[(*i)]=tok;
69
}
70
}
71
return
*
this
;
72
}
73
74
BoWText::~BoWText
()
75
{
76
clear
();
77
}
78
void
BoWText::writeBoWText
(ostream& stream)
79
{
80
BoWBinaryWriter
writer;
81
writer.
writeBoWText
(stream, *
this
);
82
}
83
84
85
void
BoWText::clear
() {
86
#ifdef DEBUG_LP
87
BOWLOGINIT
;
88
LDEBUG
<<
"BoWText::clear()"
<<
this
;
89
#endif
90
for
(
auto
it = begin(); it != end(); it++)
91
{
92
#ifdef DEBUG_LP
93
LDEBUG
<<
"BoWText::clear clearing"
<< &(**it);
94
#endif
95
(*it)->clear();
96
}
97
std::vector< boost::shared_ptr< AbstractBoWElement > >
::clear
();
98
}
99
100
//**********************************************************************
101
// input/output functions
102
//**********************************************************************
103
std::ostream&
operator <<
(std::ostream& os,
const
BoWText
& text) {
104
for
(BoWText::const_iterator i(text.begin());
105
i != text.end(); i++) {
106
os << (*i)->getOutputUTF8String() << std::endl;
107
}
108
return
os;
109
}
110
QDebug&
operator <<
(QDebug& os,
const
BoWText
& text) {
111
for
(BoWText::const_iterator i(text.begin());
112
i != text.end(); i++) {
113
os << (*i)->getString();
114
}
115
return
os;
116
}
117
118
}
// namespace BagOfWords
119
}
// namespace Common
120
}
// namespace Lima
LDEBUG
#define LDEBUG
Definition
LimaCommon.h:157
BOWLOGINIT
#define BOWLOGINIT
Definition
LimaCommon.h:201
bowBinaryReaderWriter.h
bowNamedEntity.h
bowTerm.h
bowText.h
bowToken.h
Lima::Common::BagOfWords::AbstractBoWElement
This class is the abstract base class of all elements that can be stored in a BoWText.
Definition
AbstractBoWElement.h:72
Lima::Common::BagOfWords::BoWBinaryWriter
Definition
bowBinaryReaderWriter.h:90
Lima::Common::BagOfWords::BoWBinaryWriter::writeBoWText
void writeBoWText(std::ostream &file, const BoWText &bowText) const
Definition
bowBinaryReaderWriter.cpp:529
Lima::Common::BagOfWords::BoWText
This class represents a list of elements, that are pointers on polymmorphic tokens that can be simple...
Definition
bowText.h:48
Lima::Common::BagOfWords::BoWText::~BoWText
virtual ~BoWText()
Definition
bowText.cpp:74
Lima::Common::BagOfWords::BoWText::writeBoWText
void writeBoWText(std::ostream &stream)
Definition
bowText.cpp:78
Lima::Common::BagOfWords::BoWText::BoWText
BoWText()
Definition
bowText.cpp:32
Lima::Common::BagOfWords::BoWText::operator=
BoWText & operator=(const BoWText &)
Definition
bowText.cpp:52
Lima::Common::BagOfWords::BoWText::clear
virtual void clear()
Definition
bowText.cpp:85
Lima::Common::BagOfWords::operator<<
T & operator<<(T &qd, const BoWType &bt)
Definition
AbstractBoWElement.h:54
Lima
NAUTITIA.
Definition
AmosePluginsManager.h:15
boost
Definition
FsaAccess16.h:73
std
STL namespace.
strwstrtools.h
lima_linguisticprocessing
src
linguisticProcessing
common
BagOfWords
bowText.cpp
Generated by
1.9.8