LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
SegmentFeatureExtractor.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
*
8
* @file SegmentFeatureExtractor.h
9
* @author Romaric Besancon (romaric.besancon@cea.fr)
10
* @date Mon Feb 7 2011
11
* copyright Copyright (C) 2011 by CEA LIST
12
* Project LIMA
13
*
14
* @brief accessors for various features of a word
15
*
16
*
17
***********************************************************************/
18
19
#ifndef SEGMENTFEATUREEXTRACTOR_H
20
#define SEGMENTFEATUREEXTRACTOR_H
21
22
#include "
TextSegmentationExport.h
"
23
#include "
SegmentationData.h
"
24
#include "
linguisticProcessing/core/LinguisticAnalysisStructure/AnalysisGraph.h
"
25
#include "
common/AbstractFactoryPattern/RegistrableFactory.h
"
26
27
namespace
Lima
{
28
namespace
LinguisticProcessing {
29
30
//----------------------------------------------------------------------
31
// Abstract segment feature extractor class
32
class
AbstractSegmentFeatureExtractor
33
{
34
public
:
35
AbstractSegmentFeatureExtractor
(MediaId language,
const
std::string& complement=
""
);
36
virtual
~AbstractSegmentFeatureExtractor
() {}
37
38
virtual
void
update
(
const
AnalysisContent
&
/*analysis*/
) {}
39
40
virtual
std::string
getValue
(
const
LinguisticAnalysisStructure::AnalysisGraph
* graph,
41
const
Segment
& seg)
const
=0;
42
protected
:
43
MediaId
m_language
;
44
};
45
46
//----------------------------------------------------------------------
47
// Asbtract factory for abstract feature extractor
48
class
AbstractSegmentFeatureExtractorFactory
:
49
public
RegistrableFactory
<AbstractSegmentFeatureExtractorFactory>
50
{
51
public
:
52
AbstractSegmentFeatureExtractorFactory
(
const
std::string& factoryId);
53
virtual
AbstractSegmentFeatureExtractor
*
create
(MediaId language,
const
std::string& complement)=0;
54
private
:
55
};
56
57
//----------------------------------------------------------------------
58
// template for factories for actual instances of feature extractors
59
template
<
typename
SegmentFeatureExtractor>
60
class
LIMA_TEXTSEGMENTATION_EXPORT
SegmentFeatureExtractorFactory
:
61
public
AbstractSegmentFeatureExtractorFactory
62
{
63
public
:
64
SegmentFeatureExtractorFactory
(
const
std::string& factoryId):
65
AbstractSegmentFeatureExtractorFactory
(factoryId) {}
66
AbstractSegmentFeatureExtractor
*
create
(MediaId language,
const
std::string& complement)
override
{
67
AbstractSegmentFeatureExtractor
* newFeature=
new
SegmentFeatureExtractor(language, complement);
68
return
newFeature;
69
}
70
private
:
71
};
72
73
//----------------------------------------------------------------------
74
// a class for list of features
75
//----------------------------------------------------------------------
76
class
SegmentFeatures
:
public
std::vector<AbstractSegmentFeatureExtractor*> {
77
public
:
78
SegmentFeatures
();
79
SegmentFeatures
(MediaId language);
80
~SegmentFeatures
();
81
82
void
setLanguage
(MediaId language) { m_language=language; }
83
void
initialize
(
const
std::deque<std::string>& featureNames);
84
void
update
(
const
AnalysisContent
& analysis);
85
86
private
:
87
MediaId m_language;
88
};
89
90
//----------------------------------------------------------------------
91
// instances of feature extractors
92
//----------------------------------------------------------------------
93
// check if an entity of a given type exists in the segment
94
#define SegmentFeaturePosition_ID "position"
95
class
LIMA_TEXTSEGMENTATION_EXPORT
SegmentFeaturePosition
:
public
AbstractSegmentFeatureExtractor
{
96
public
:
97
SegmentFeaturePosition
(MediaId language,
const
std::string& complement=
""
);
98
~SegmentFeaturePosition
() {}
99
100
void
update(
const
AnalysisContent
& analysis)
override
;
101
102
std::string
103
getValue(
const
LinguisticAnalysisStructure::AnalysisGraph
* graph,
104
const
Segment
& seg)
const override
;
105
private
:
106
uint64_t m_offset;
107
};
108
109
#define SegmentFeatureLength_ID "length"
110
class
LIMA_TEXTSEGMENTATION_EXPORT
SegmentFeatureLength
:
public
AbstractSegmentFeatureExtractor
{
111
public
:
112
SegmentFeatureLength
(MediaId language,
const
std::string& complement=
""
);
113
~SegmentFeatureLength
() {}
114
115
void
update(
const
AnalysisContent
& analysis)
override
;
116
117
std::string
118
getValue(
const
LinguisticAnalysisStructure::AnalysisGraph
* graph,
119
const
Segment
& seg)
const override
;
120
private
:
121
};
122
123
#define SegmentFeatureType_ID "type"
124
class
LIMA_TEXTSEGMENTATION_EXPORT
SegmentFeatureType
:
public
AbstractSegmentFeatureExtractor
{
125
public
:
126
SegmentFeatureType
(MediaId language,
const
std::string& complement=
""
);
127
~SegmentFeatureType
() {}
128
129
void
update(
const
AnalysisContent
& analysis)
override
;
130
131
std::string
132
getValue(
const
LinguisticAnalysisStructure::AnalysisGraph
* graph,
133
const
Segment
& seg)
const override
;
134
private
:
135
};
136
137
138
}
// end namespace
139
}
// end namespace
140
141
#endif
AnalysisGraph.h
RegistrableFactory.h
SegmentationData.h
TextSegmentationExport.h
LIMA_TEXTSEGMENTATION_EXPORT
#define LIMA_TEXTSEGMENTATION_EXPORT
Definition
TextSegmentationExport.h:27
Lima::AnalysisContent
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
Definition
AnalysisContent.h:37
Lima::LinguisticProcessing::AbstractSegmentFeatureExtractorFactory
Definition
SegmentFeatureExtractor.h:50
Lima::LinguisticProcessing::AbstractSegmentFeatureExtractorFactory::create
virtual AbstractSegmentFeatureExtractor * create(MediaId language, const std::string &complement)=0
Lima::LinguisticProcessing::AbstractSegmentFeatureExtractor
Definition
SegmentFeatureExtractor.h:33
Lima::LinguisticProcessing::AbstractSegmentFeatureExtractor::getValue
virtual std::string getValue(const LinguisticAnalysisStructure::AnalysisGraph *graph, const Segment &seg) const =0
Lima::LinguisticProcessing::AbstractSegmentFeatureExtractor::update
virtual void update(const AnalysisContent &)
Definition
SegmentFeatureExtractor.h:38
Lima::LinguisticProcessing::AbstractSegmentFeatureExtractor::~AbstractSegmentFeatureExtractor
virtual ~AbstractSegmentFeatureExtractor()
Definition
SegmentFeatureExtractor.h:36
Lima::LinguisticProcessing::AbstractSegmentFeatureExtractor::m_language
MediaId m_language
Definition
SegmentFeatureExtractor.h:43
Lima::LinguisticProcessing::LinguisticAnalysisStructure::AnalysisGraph
An AnalysisData containing a LinguisticGraph with a language and an id.
Definition
AnalysisGraph.h:47
Lima::LinguisticProcessing::SegmentFeatureExtractorFactory
Definition
SegmentFeatureExtractor.h:62
Lima::LinguisticProcessing::SegmentFeatureExtractorFactory::SegmentFeatureExtractorFactory
SegmentFeatureExtractorFactory(const std::string &factoryId)
Definition
SegmentFeatureExtractor.h:64
Lima::LinguisticProcessing::SegmentFeatureExtractorFactory::create
AbstractSegmentFeatureExtractor * create(MediaId language, const std::string &complement) override
Definition
SegmentFeatureExtractor.h:66
Lima::LinguisticProcessing::SegmentFeatureLength
Definition
SegmentFeatureExtractor.h:110
Lima::LinguisticProcessing::SegmentFeatureLength::~SegmentFeatureLength
~SegmentFeatureLength()
Definition
SegmentFeatureExtractor.h:113
Lima::LinguisticProcessing::SegmentFeaturePosition
Definition
SegmentFeatureExtractor.h:95
Lima::LinguisticProcessing::SegmentFeaturePosition::~SegmentFeaturePosition
~SegmentFeaturePosition()
Definition
SegmentFeatureExtractor.h:98
Lima::LinguisticProcessing::SegmentFeatureType
Definition
SegmentFeatureExtractor.h:124
Lima::LinguisticProcessing::SegmentFeatureType::~SegmentFeatureType
~SegmentFeatureType()
Definition
SegmentFeatureExtractor.h:127
Lima::LinguisticProcessing::SegmentFeatures
Definition
SegmentFeatureExtractor.h:76
Lima::LinguisticProcessing::SegmentFeatures::initialize
void initialize(const std::deque< std::string > &featureNames)
Definition
SegmentFeatureExtractor.cpp:71
Lima::LinguisticProcessing::SegmentFeatures::update
void update(const AnalysisContent &analysis)
Definition
SegmentFeatureExtractor.cpp:87
Lima::LinguisticProcessing::SegmentFeatures::~SegmentFeatures
~SegmentFeatures()
Definition
SegmentFeatureExtractor.cpp:61
Lima::LinguisticProcessing::SegmentFeatures::setLanguage
void setLanguage(MediaId language)
Definition
SegmentFeatureExtractor.h:82
Lima::LinguisticProcessing::SegmentFeatures::SegmentFeatures
SegmentFeatures()
Definition
SegmentFeatureExtractor.cpp:51
Lima::LinguisticProcessing::Segment
Definition
SegmentationData.h:23
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
TextSegmentation
SegmentFeatureExtractor.h
Generated by
1.9.8