LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
bowTerm.cpp
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 bowTerm.cpp
8 * @author Besancon Romaric
9 * @date Tue Oct 7 2003
10 * copyright Copyright (C) 2003 by CEA LIST
11 *
12 ***********************************************************************/
13
14#include "bowTerm.h"
17#include <string>
18
19namespace Lima {
20namespace Common {
21namespace BagOfWords {
22
31
32
33//**********************************************************************
34// constructors
35//**********************************************************************
39
41{
42 static_cast<BoWTermPrivate&>(*m_d).copy(t);
43}
44
49
50
52 const LinguisticCode category,
53 const uint64_t position,
54 const uint64_t length):
56{
57 m_d->m_lemma = lemma;
58 m_d->m_category = category;
59 m_d->m_position = position;
60 m_d->m_length = length;
61}
62
64 const LinguisticCode category,
65 const uint64_t position,
66 const uint64_t length,
67 std::deque< boost::shared_ptr< BoWToken > >& parts,
68 const uint64_t head):
70{
71 m_d->m_lemma = lemma;
72 m_d->m_category = category;
73 m_d->m_position = position;
74 m_d->m_length = length;
75 static_cast<BoWComplexTokenPrivate *>(m_d)->m_head = head;
76 for (auto i=parts.begin(); i!=parts.end(); i++)
77 {
78 addPart(*i);
79 }
80 static_cast<BoWComplexTokenPrivate*>(m_d)->m_head = head;
81}
82
87
89{
91 return *this;
92}
93
95{
96 return new BoWTerm(*(new BoWTermPrivate(static_cast<BoWTermPrivate&>(*(this->m_d)))));
97}
98
99
100//**********************************************************************
101// input/output functions
102//**********************************************************************
104 std::ostringstream oss;
105 oss << BoWToken::getOutputUTF8String(macroManager) << "->" << getUTF8StringParts(macroManager);
106 return oss.str();
107}
108
109std::string BoWTerm::getIdUTF8String() const {
110 std::ostringstream oss;
112 return oss.str();
113}
114
115std::ostream& operator<<(std::ostream& os, const BoWTerm& t) {
116 os << static_cast<BoWToken>(t) << "->" << t.getstdstringParts();
117 return os;
118}
119
120} // namespace BagOfWords
121} // namespace Common
122} // namespace Lima
This is a complex token for an index.
boost::shared_ptr< BoWToken > addPart(boost::shared_ptr< BoWToken > tok, const bool isHead=false)
add a part in the list of parts of the complex token.
BoWComplexToken & operator=(const BoWComplexToken &)
std::string getUTF8StringParts(const Common::PropertyCode::PropertyManager *macroManager=0) const
BoWTermPrivate(const BoWTermPrivate &btp)
Definition bowTerm.cpp:29
This is a complex token used to represent a multiword term.
Definition bowTerm.h:36
virtual BoWTerm * clone() const override
Definition bowTerm.cpp:94
BoWTerm & operator=(const BoWTerm &)
Definition bowTerm.cpp:88
virtual std::string getOutputUTF8String(const Common::PropertyCode::PropertyManager *macroManager=0) const override
get a string of the BoWToken for output function
Definition bowTerm.cpp:103
virtual std::string getIdUTF8String(void) const override
function used to identify a bowtoken in a text (used in BowDumper)
Definition bowTerm.cpp:109
virtual std::string getOutputUTF8String(const Common::PropertyCode::PropertyManager *macroManager=0) const override
get a string of the BoWToken for output function
Definition bowToken.cpp:430
Provide tools to manage a specific property.
T & operator<<(T &qd, const BoWType &bt)
NAUTITIA.
QString LimaString
Definition LimaString.h:33