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"
19
21
22using namespace std;
23
24namespace Lima {
25namespace Common {
26namespace BagOfWords {
27
28
29//**********************************************************************
30// constructors,destructor,copy assignment
31//**********************************************************************
33std::vector< boost::shared_ptr< AbstractBoWElement > >()
34{
35#ifdef DEBUG_LP
37 LDEBUG << "BoWText::BoWText()" << this;
38#endif
39}
40
41
43std::vector< boost::shared_ptr< AbstractBoWElement > >()
44{
45#ifdef DEBUG_LP
47 LDEBUG << "BoWText::BoWText(BoWText)" << this;
48#endif
49 (*this) = t;
50}
51
53{
54#ifdef DEBUG_LP
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
75{
76 clear();
77}
78void BoWText::writeBoWText(ostream& stream)
79{
80 BoWBinaryWriter writer;
81 writer.writeBoWText(stream, *this);
82}
83
84
86#ifdef DEBUG_LP
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//**********************************************************************
103std::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}
110QDebug& 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
#define LDEBUG
Definition LimaCommon.h:157
#define BOWLOGINIT
Definition LimaCommon.h:201
This class is the abstract base class of all elements that can be stored in a BoWText.
void writeBoWText(std::ostream &file, const BoWText &bowText) const
This class represents a list of elements, that are pointers on polymmorphic tokens that can be simple...
Definition bowText.h:48
void writeBoWText(std::ostream &stream)
Definition bowText.cpp:78
BoWText & operator=(const BoWText &)
Definition bowText.cpp:52
T & operator<<(T &qd, const BoWType &bt)
NAUTITIA.
STL namespace.