LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
bowToken.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 bowToken.h
8 * @author Besancon Romaric
9 * @date Tue Oct 7 17:13:26 2003
10 * copyright Copyright (C) 2003 by CEA LIST
11 *
12 * @brief
13 *
14 ***********************************************************************/
15
16#ifndef BOWTOKEN_H
17#define BOWTOKEN_H
18
20#include "common/LimaCommon.h"
24#include <iostream>
25#include <string>
26#include <stdexcept>
27#include <map>
28#include <set>
29#include <memory>
30
31namespace Lima {
32namespace Common {
33namespace PropertyCode {
34 class PropertyManager;
35}
36namespace BagOfWords {
37
38class BoWTokenPrivate;
46{
47 friend class BoWTokenPrivate;
48public:
49
51 const LinguisticCode category,
52 const uint64_t position,
53 const uint64_t length);
55 const uint64_t position=0,
56 const uint64_t length=0);
57 BoWToken(const BoWToken& tok);
58 BoWToken();
59
60 virtual ~BoWToken();
61
62 virtual void clear() override {}
63
64 virtual BoWToken* clone() const override;
65// virtual BoWToken* clone(const std::map<BoWToken*,BoWToken*>&) const;
66
67 virtual Lima::LimaString getLemma(void) const;
68 virtual Lima::LimaString getInflectedForm(void) const;
69 LinguisticCode getCategory(void) const;
70 uint64_t getPosition(void) const override;
71 uint64_t getLength(void) const override;
72
74 virtual uint64_t size(void) const override;
75
76 void setLemma(const Lima::LimaString& lemma);
77 void setInflectedForm(const Lima::LimaString& inflectedForm);
78 void setCategory(LinguisticCode c);
79 void setPosition(const uint64_t pos) override;
80 void setLength(const uint64_t len) override;
81
82 virtual Lima::LimaString getString(void) const override;
83
84 static void setInternalSeparator(const LimaChar c);
85 static void setCompoundSeparator(const LimaChar c);
86
87 static LimaChar getInternalSeparator();
88 static LimaChar getCompoundSeparator();
89
90 virtual BoWType getType() const override;
91
92 uint64_t getVertex() const;
93 void setVertex(uint64_t vertex);
94
103 virtual std::set< uint64_t > getVertices() const override;
104
109 virtual std::string getOutputUTF8String(const Common::PropertyCode::PropertyManager* macroManager = 0) const override;
110
112 virtual std::string getIdUTF8String() const override;
113
114 friend LIMA_BOW_EXPORT std::ostream& operator << (std::ostream&, const BoWToken&);
115 friend LIMA_BOW_EXPORT QDebug& operator << (QDebug&, const BoWToken&);
116
126 bool operator==(const BoWToken&) const;
127
132 bool operator!=(const BoWToken&) const;
133
134
141 virtual Common::Misc::PositionLengthList getPositionLengthList() const;
142
146 virtual void addToPosition(const uint64_t offset);
147
148 friend LIMA_BOW_EXPORT std::ostream& operator << (std::ostream& os,
150 friend LIMA_BOW_EXPORT QDebug& operator << (QDebug& os,
152
153 static void setUseOnlyLemma(const bool b);
154 static bool getUseOnlyLemma();
155
157 friend LIMA_BOW_EXPORT std::ostream& operator << (std::ostream& os,
158 const std::map<BoWToken*,uint64_t>& refMap);
159 friend LIMA_BOW_EXPORT QDebug& operator << (QDebug& os,
160 const std::map<BoWToken*,uint64_t>& refMap);
161
162protected:
164 BoWToken& operator=(const BoWToken& tok);
165 bool operator==(const BoWToken& tok);
167};
168//**************************************************************
169// exceptions
170//**************************************************************
171class LIMA_BOW_EXPORT InputErrorException : public std::runtime_error {
172 public:
173 InputErrorException(const std::string& mes):std::runtime_error(mes){};
174};
175
176//**************************************************************
177// functions
178//**************************************************************
179} // namespace BagOfWords
180} // namespace Common
181} // namespace Lima
182
183#endif
QDebug & operator<<(QDebug &qd, const std::string &str)
Definition QsLog.cpp:39
#define LIMA_BOW_EXPORT
This class is the abstract base class of all elements that can be stored in a BoWText.
This class contains the representation of an element of the bag of words.
Definition bowToken.h:46
BoWToken(const Lima::LimaString &lemma, const LinguisticCode category, const uint64_t position, const uint64_t length)
virtual void clear() override
Definition bowToken.h:62
BoWToken(const Lima::LimaString &str, const uint64_t position=0, const uint64_t length=0)
InputErrorException(const std::string &mes)
Definition bowToken.h:173
Provide tools to manage a specific property.
BoWType
enum to characterize the type of the AbstractBoWElement
std::vector< std::pair< Position, Length > > PositionLengthList
NAUTITIA.
QChar LimaChar
Definition LimaString.h:30
QString LimaString
Definition LimaString.h:33
STL namespace.