LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
AbstractBoWElement.h
Go to the documentation of this file.
1// Copyright 2014 CEA LIST
2// SPDX-FileCopyrightText: 2022 CEA LIST <gael.de-chalendar@cea.fr>
3//
4// SPDX-License-Identifier: MIT
5
6/************************************************************************
7 * @file AbstractBoWElement.h
8 * @author Gael de Chalendar <gael.de-chalendar@cea.fr>
9 * @date Thu Jul 24 2003
10 * Copyright (C) 2014 by CEA LIST
11 ***********************************************************************/
12
13#ifndef ABSTRACTBOWELEMENT_H
14#define ABSTRACTBOWELEMENT_H
15
16#include "common/LimaCommon.h"
20#include <iostream>
21#include <string>
22#include <stdexcept>
23#include <map>
24#include <set>
25#include <memory>
26
27namespace Lima {
28namespace Common {
29namespace PropertyCode {
30 class PropertyManager;
31}
32namespace BagOfWords {
33
37#ifndef WIN32
38enum class BoWType : unsigned short {
39#else
40enum BoWType {
41#endif
44 BOW_TOKEN,
45 BOW_TERM,
49};
50
51LIMA_BOW_EXPORT uint8_t toInt(const BoWType& bt);
52
53template <typename T>
54T& operator<<(T& qd, const BoWType& bt)
55{
56 if (bt == BoWType::BOW_NOTYPE) qd << "BOW_NOTYPE";
57 else if (bt == BoWType::BOW_TOKEN) qd << "BOW_TOKEN";
58 else if (bt == BoWType::BOW_TERM) qd << "BOW_TERM";
59 else if (bt == BoWType::BOW_NAMEDENTITY) qd << "BOW_NAMEDENTITY";
60 else if (bt == BoWType::BOW_PREDICATE) qd << "BOW_PREDICATE";
61 else qd << "UNDEFINED";
62 return qd;
63};
64
72{
73public:
74
76
78
79 virtual void clear() {}
80
81 virtual AbstractBoWElement* clone() const = 0;
82
85 virtual uint64_t size(void) const = 0;
86
87 virtual BoWType getType() const {return BoWType::BOW_NOTYPE;}
88
89 virtual Lima::LimaString getString(void) const = 0;
90
91 virtual uint64_t getPosition(void) const = 0;
92 virtual uint64_t getLength(void) const = 0;
93 virtual void setPosition(const uint64_t pos) = 0;
94 virtual void setLength(const uint64_t len) = 0;
95
101 virtual std::set< uint64_t > getVertices() const = 0;
102
107 virtual std::string getOutputUTF8String(const Common::PropertyCode::PropertyManager* macroManager = 0) const = 0;
108
110 virtual std::string getIdUTF8String() const = 0;
111
112};
113
114} // namespace BagOfWords
115} // namespace Common
116} // namespace Lima
117
118#endif
#define LIMA_BOW_EXPORT
This class is the abstract base class of all elements that can be stored in a BoWText.
virtual std::set< uint64_t > getVertices() const =0
returns the set of vertices covered by this element
virtual uint64_t size(void) const =0
size of the AbstractBoWElement is the number of parts in the token: 0 for a predicate,...
virtual AbstractBoWElement * clone() const =0
virtual uint64_t getPosition(void) const =0
virtual void setLength(const uint64_t len)=0
virtual void setPosition(const uint64_t pos)=0
virtual std::string getIdUTF8String() const =0
function used to identify a bowtoken in a text (used in BowDumper)
virtual uint64_t getLength(void) const =0
virtual std::string getOutputUTF8String(const Common::PropertyCode::PropertyManager *macroManager=0) const =0
get a string of the AbstractBoWElement for output function
virtual Lima::LimaString getString(void) const =0
Provide tools to manage a specific property.
LIMA_BOW_EXPORT uint8_t toInt(const BoWType &bt)
Definition bowToken.cpp:42
BoWType
enum to characterize the type of the AbstractBoWElement
@ BOW_NOTYPE
the AbstractBoWElement is an abstract one that should not be instanciated
@ BOW_TERM
the AbstractBoWElement is a multi-term
@ BOW_NAMEDENTITY
the AbstractBoWElement is a named entity
@ BOW_TOKEN
the AbstractBoWElement is a simple token
@ BOW_PREDICATE
the AbstractBoWElement is a predicate (n-ary relation, template or semantic frame
T & operator<<(T &qd, const BoWType &bt)
NAUTITIA.
QString LimaString
Definition LimaString.h:33