LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
DynamicSvmToolPosTagger.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 * Copyright (C) 2004-2012 by CEA LIST *
8 * *
9 ***************************************************************************/
10#ifndef LIMA_LINGUISTICPROCESSING_POSTAGGER_DYNAMICSVMTOOLPOSTAGGER_H
11#define LIMA_LINGUISTICPROCESSING_POSTAGGER_DYNAMICSVMTOOLPOSTAGGER_H
12
13// #include "viterbiUtils.h"
14// #include "frequencyCost.h"
15
20
26
27#include <list>
28#include <vector>
29#include <set>
30#include <map>
31#include <queue>
32
33#include <sstream>
34
35class tagger;
36class nodo;
37
38namespace Lima
39{
40
41namespace LinguisticProcessing
42{
43
44namespace PosTagger
45{
46
47#define DYNAMICSVMTOOLPOSTAGGER_CLASSID "DynamicSvmToolPosTagger"
48
54{
55public:
57
59
60 void init(
62 Manager* manager) override;
63
64 LimaStatusCode process(AnalysisContent& analysis) const override;
65
66private:
67 /* Configuration */
68 LinguisticCode m_defaultCateg; // default category, used before and after text.
69 std::list<LinguisticCode> m_stopCategories; // sentence boundaries
70
71 /* Book-keeping */
72 const Common::PropertyCode::PropertyAccessor* m_microAccessor;
73 const Common::PropertyCode::PropertyManager* m_MicroManager;
74 MediaId m_language;
75
76 /* Stores the information we know about the path thus far:
77 * - prev is the best vertex to choose when going through this vertex
78 * - score is the sum of the scores thus far (not normalized)
79 * - pathLength helps us to normalize the score
80 * - category is the chosen microcategory
81 */
82 struct PathInfo {
84 double score;
85 std::string pos;
86 int pathLength;
87 };
88
89
90 /* The SVMTool tagger */
91 tagger *t;
92 boost::tuple<std::string, uint64_t> SVMTool(
93 const LinguisticGraph* srcGraph,
95 LinguisticGraphVertex prevVertex,
96 std::map<LinguisticGraphVertex, struct PathInfo > &maxAncestors) const;
97
98 /* Useful functions */
99 std::vector<std::string> getMicros(LinguisticGraphVertex token, const LinguisticGraph *srcGraph) const;
100 std::set<LinguisticGraphVertex> getPreviousTokens(LinguisticGraphVertex token, const LinguisticGraph *srcGraph) const;
101 std::vector<nodo*> buildContext(const LinguisticGraph*, LinguisticGraphVertex, LinguisticGraphVertex, LinguisticGraphVertex) const;
102 std::string getWord(LinguisticGraphVertex token, const LinguisticGraph *srcGraph) const;
103 LinguisticGraphVertex nextToken(LinguisticGraphVertex token, const LinguisticGraph* srcGraph) const;
104 std::set<LinguisticGraphVertex> nextTokens(LinguisticGraphVertex token, const LinguisticGraph* srcGraph) const;
105
106};
107
109{
110public:
111
112 virtual std::shared_ptr<MediaProcessUnit> create(
114 MediaProcessUnit::Manager* manager) const override ;
115
116private:
117 DynamicSvmToolPosTaggerFactory(const std::string& id);
118 static DynamicSvmToolPosTaggerFactory* s_instance;
119
120};
121
122
123}
124
125}
126
127}
128
129#endif
This file is the main header file for the data related to annotation graphs.
A graph structure for linguistic analysis.
LinguisticGraph::vertex_descriptor LinguisticGraphVertex
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, LinguisticVertexProperties > LinguisticGraph
Property to identify the chains in the graph.
Holds all data that pass through the ProcessUnits Analysis data are shared pointers,...
Provide function to read write and check a property.
Provide tools to manage a specific property.
Defines Factory for an Initializable Object.
Manage initialization of InitializableObjects using configuration module and parameters.
virtual std::shared_ptr< MediaProcessUnit > create(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, MediaProcessUnit::Manager *manager) const override
A PoS tagger using SVMTool as a backend and Viterbi to maximize the results.
LimaStatusCode process(AnalysisContent &analysis) const override
Process on data in analysisContent.
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
initialize with parameters from configuration file.
NAUTITIA.
LimaStatusCode
Definition LimaCommon.h:236
launch exception related to the configuration file parsing