LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
BoWFeatureExtractor.h
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
* @author Romaric Besancon (romaric.besancon@cea.fr)
8
* @date Tue Feb 12 2013
9
* @brief accessors for various features of a word, stored in a BoW format
10
* (same features as the WordFeatureExtractors)
11
***********************************************************************/
12
13
#ifndef BOWFEATUREEXTRACTOR_H
14
#define BOWFEATUREEXTRACTOR_H
15
16
#include "
AnalysisDumpersExport.h
"
17
#include "
linguisticProcessing/common/PropertyCode/PropertyAccessor.h
"
18
#include "
linguisticProcessing/common/BagOfWords/bowToken.h
"
19
#include "
common/AbstractFactoryPattern/RegistrableFactory.h
"
20
21
namespace
Lima
{
22
namespace
LinguisticProcessing {
23
24
//----------------------------------------------------------------------
25
// Abstract feature extractor class
26
//
27
// BoW feature extractors are needed for generic dumper because compounds are stored in
28
// BoWTerm and we need compatible feature extractors on LinguisticVertex and on BoWTerm
29
// to have a similar output for both
30
class
LIMA_ANALYSISDUMPERS_EXPORT
AbstractBoWFeatureExtractor
31
{
32
public
:
33
AbstractBoWFeatureExtractor
(MediaId language,
const
std::string& complement=
""
);
34
virtual
~AbstractBoWFeatureExtractor
() {}
35
36
virtual
std::string
getValue
(
const
Common::BagOfWords::AbstractBoWElement
* token)
const
=0;
37
const
std::string&
getName
() {
return
m_name; }
38
void
setName
(
const
std::string& name) { m_name=name; }
39
40
protected
:
41
MediaId
m_language
;
42
std::string
m_name
;
43
};
44
45
//----------------------------------------------------------------------
46
// Asbtract factory for abstract feature extractor
47
class
LIMA_ANALYSISDUMPERS_EXPORT
AbstractBoWFeatureExtractorFactory
:
48
public
RegistrableFactory
<AbstractBoWFeatureExtractorFactory>
49
{
50
public
:
51
AbstractBoWFeatureExtractorFactory
(
const
std::string& factoryId);
52
virtual
AbstractBoWFeatureExtractor
*
create
(MediaId language,
const
std::string& complement=
""
)=0;
53
private
:
54
};
55
56
//----------------------------------------------------------------------
57
// template for factories for actual instances of feature extractors
58
template
<
typename
BoWFeatureExtractor>
59
class
LIMA_ANALYSISDUMPERS_EXPORT
BoWFeatureExtractorFactory
:
60
public
AbstractBoWFeatureExtractorFactory
61
{
62
public
:
63
BoWFeatureExtractorFactory
(
const
std::string& factoryId):
64
AbstractBoWFeatureExtractorFactory
(factoryId) {}
65
AbstractBoWFeatureExtractor
*
create
(MediaId language,
const
std::string& complement=
""
)
override
{
66
AbstractBoWFeatureExtractor
* newFeature=
new
BoWFeatureExtractor(language,complement);
67
return
newFeature;
68
}
69
private
:
70
};
71
72
//----------------------------------------------------------------------
73
// a class for list of features
74
//----------------------------------------------------------------------
75
class
LIMA_ANALYSISDUMPERS_EXPORT
BoWFeatures
:
public
std::vector<AbstractBoWFeatureExtractor*> {
76
public
:
77
BoWFeatures
();
78
BoWFeatures
(MediaId language);
79
~BoWFeatures
();
80
81
void
setLanguage
(MediaId language) { m_language=language; }
82
void
initialize(
const
std::deque<std::string>& featureNames);
83
private
:
84
MediaId m_language;
85
};
86
87
//----------------------------------------------------------------------
88
// instances of feature extractors
89
//----------------------------------------------------------------------
90
#define BoWFeaturePosition_ID "position"
91
class
LIMA_ANALYSISDUMPERS_EXPORT
BoWFeaturePosition
:
public
AbstractBoWFeatureExtractor
{
92
public
:
93
BoWFeaturePosition
(MediaId language,
const
std::string& complement=
""
);
94
~BoWFeaturePosition
() {}
95
96
std::string getValue(
const
Common::BagOfWords::AbstractBoWElement
* token)
const override
;
97
};
98
99
//----------------------------------------------------------------------
100
#define BoWFeatureToken_ID "word"
101
class
LIMA_ANALYSISDUMPERS_EXPORT
BoWFeatureToken
:
public
AbstractBoWFeatureExtractor
{
102
public
:
103
BoWFeatureToken
(MediaId language,
const
std::string& complement=
""
);
104
~BoWFeatureToken
() {}
105
106
std::string getValue(
const
Common::BagOfWords::AbstractBoWElement
* token)
const override
;
107
};
108
109
//----------------------------------------------------------------------
110
#define BoWFeatureInflectedForm_ID "inflectedForm"
111
class
LIMA_ANALYSISDUMPERS_EXPORT
BoWFeatureInflectedForm
:
public
AbstractBoWFeatureExtractor
{
112
public
:
113
BoWFeatureInflectedForm
(MediaId language,
const
std::string& complement=
""
);
114
~BoWFeatureInflectedForm
() {}
115
116
std::string getValue(
const
Common::BagOfWords::AbstractBoWElement
* token)
const override
;
117
};
118
119
//----------------------------------------------------------------------
120
#define BoWFeatureLemma_ID "lemma"
121
class
LIMA_ANALYSISDUMPERS_EXPORT
BoWFeatureLemma
:
public
AbstractBoWFeatureExtractor
{
122
public
:
123
BoWFeatureLemma
(MediaId language,
const
std::string& complement=
""
);
124
~BoWFeatureLemma
() {}
125
126
std::string getValue(
const
Common::BagOfWords::AbstractBoWElement
* token)
const override
;
127
private
:
128
};
129
130
//----------------------------------------------------------------------
131
#define BoWFeatureProperty_ID "property"
132
class
LIMA_ANALYSISDUMPERS_EXPORT
BoWFeatureProperty
:
public
AbstractBoWFeatureExtractor
{
133
public
:
134
BoWFeatureProperty
(MediaId language,
const
std::string& complement=
""
);
135
~BoWFeatureProperty
() {}
136
137
std::string getValue(
const
Common::BagOfWords::AbstractBoWElement
* token)
const override
;
138
139
private
:
140
std::string m_propertyName;
141
const
Common::PropertyCode::PropertyAccessor
* m_propertyAccessor;
142
const
Common::PropertyCode::PropertyManager
* m_propertyManager;
143
};
144
145
//----------------------------------------------------------------------
146
#define BoWFeatureTstatus_ID "tstatus"
147
class
LIMA_ANALYSISDUMPERS_EXPORT
BoWFeatureTstatus
:
public
AbstractBoWFeatureExtractor
{
148
public
:
149
BoWFeatureTstatus
(MediaId language,
const
std::string& complement=
""
);
150
~BoWFeatureTstatus
() {}
151
152
std::string getValue(
const
Common::BagOfWords::AbstractBoWElement
* token)
const override
;
153
};
154
155
}
// end namespace
156
}
// end namespace
157
158
#endif
AnalysisDumpersExport.h
LIMA_ANALYSISDUMPERS_EXPORT
#define LIMA_ANALYSISDUMPERS_EXPORT
Definition
AnalysisDumpersExport.h:27
PropertyAccessor.h
RegistrableFactory.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::PropertyCode::PropertyAccessor
Provide function to read write and check a property.
Definition
PropertyAccessor.h:31
Lima::Common::PropertyCode::PropertyManager
Provide tools to manage a specific property.
Definition
PropertyManager.h:34
Lima::LinguisticProcessing::AbstractBoWFeatureExtractorFactory
Definition
BoWFeatureExtractor.h:49
Lima::LinguisticProcessing::AbstractBoWFeatureExtractorFactory::create
virtual AbstractBoWFeatureExtractor * create(MediaId language, const std::string &complement="")=0
Lima::LinguisticProcessing::AbstractBoWFeatureExtractor
Definition
BoWFeatureExtractor.h:31
Lima::LinguisticProcessing::AbstractBoWFeatureExtractor::m_name
std::string m_name
Definition
BoWFeatureExtractor.h:42
Lima::LinguisticProcessing::AbstractBoWFeatureExtractor::getName
const std::string & getName()
Definition
BoWFeatureExtractor.h:37
Lima::LinguisticProcessing::AbstractBoWFeatureExtractor::getValue
virtual std::string getValue(const Common::BagOfWords::AbstractBoWElement *token) const =0
Lima::LinguisticProcessing::AbstractBoWFeatureExtractor::~AbstractBoWFeatureExtractor
virtual ~AbstractBoWFeatureExtractor()
Definition
BoWFeatureExtractor.h:34
Lima::LinguisticProcessing::AbstractBoWFeatureExtractor::m_language
MediaId m_language
Definition
BoWFeatureExtractor.h:41
Lima::LinguisticProcessing::AbstractBoWFeatureExtractor::setName
void setName(const std::string &name)
Definition
BoWFeatureExtractor.h:38
Lima::LinguisticProcessing::BoWFeatureExtractorFactory
Definition
BoWFeatureExtractor.h:61
Lima::LinguisticProcessing::BoWFeatureExtractorFactory::create
AbstractBoWFeatureExtractor * create(MediaId language, const std::string &complement="") override
Definition
BoWFeatureExtractor.h:65
Lima::LinguisticProcessing::BoWFeatureExtractorFactory::BoWFeatureExtractorFactory
BoWFeatureExtractorFactory(const std::string &factoryId)
Definition
BoWFeatureExtractor.h:63
Lima::LinguisticProcessing::BoWFeatureInflectedForm
Definition
BoWFeatureExtractor.h:111
Lima::LinguisticProcessing::BoWFeatureInflectedForm::~BoWFeatureInflectedForm
~BoWFeatureInflectedForm()
Definition
BoWFeatureExtractor.h:114
Lima::LinguisticProcessing::BoWFeatureLemma
Definition
BoWFeatureExtractor.h:121
Lima::LinguisticProcessing::BoWFeatureLemma::~BoWFeatureLemma
~BoWFeatureLemma()
Definition
BoWFeatureExtractor.h:124
Lima::LinguisticProcessing::BoWFeaturePosition
Definition
BoWFeatureExtractor.h:91
Lima::LinguisticProcessing::BoWFeaturePosition::~BoWFeaturePosition
~BoWFeaturePosition()
Definition
BoWFeatureExtractor.h:94
Lima::LinguisticProcessing::BoWFeatureProperty
Definition
BoWFeatureExtractor.h:132
Lima::LinguisticProcessing::BoWFeatureProperty::~BoWFeatureProperty
~BoWFeatureProperty()
Definition
BoWFeatureExtractor.h:135
Lima::LinguisticProcessing::BoWFeatureToken
Definition
BoWFeatureExtractor.h:101
Lima::LinguisticProcessing::BoWFeatureToken::~BoWFeatureToken
~BoWFeatureToken()
Definition
BoWFeatureExtractor.h:104
Lima::LinguisticProcessing::BoWFeatureTstatus
Definition
BoWFeatureExtractor.h:147
Lima::LinguisticProcessing::BoWFeatureTstatus::~BoWFeatureTstatus
~BoWFeatureTstatus()
Definition
BoWFeatureExtractor.h:150
Lima::LinguisticProcessing::BoWFeatures
Definition
BoWFeatureExtractor.h:75
Lima::LinguisticProcessing::BoWFeatures::setLanguage
void setLanguage(MediaId language)
Definition
BoWFeatureExtractor.h:81
Lima::RegistrableFactory
Defines a Factory that automatically register to a MainFactory singleton.
Definition
RegistrableFactory.h:32
Lima
NAUTITIA.
Definition
AmosePluginsManager.h:15
lima_linguisticprocessing
src
linguisticProcessing
core
AnalysisDumpers
BoWFeatureExtractor.h
Generated by
1.9.8