LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
TokenizerAutomaton.cpp
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// NAUTITIA
7//
8// jys 24-JUL-2002
9//
10// TokenizerAutomaton is the main program of TokenizerAutomaton stuff.
11
12#include "TokenizerAutomaton.h"
13
14#include "Automaton.h"
15#include "State.h"
16#include "CharChart.h"
26#include <string>
27
28using namespace std;
31using namespace Lima::Common::Misc;
32
33namespace Lima
34{
35namespace LinguisticProcessing
36{
37namespace FlatTokenizer
38{
39
41
44
46{
47 delete m_text;
48 delete _automaton;
49}
50
53 Manager* manager)
54
55{
57 LDEBUG << "TokenizerAutomaton::init";
58 MediaId _language=manager->getInitializationParameters().language;
59 try
60 {
61 string charchartId=unitConfiguration.getParamsValueAtKey("charChart");
62 auto res = LinguisticResources::single().getResource(_language,charchartId);
63 _charChart = std::dynamic_pointer_cast<CharChart>(res);
64 }
65 catch (NoSuchParam& )
66 {
67 LERROR << "no param 'charChart' in TokenizerAutomaton group configuration (language="
68 << (int) _language << ")";
70 }
71
72 m_text = new Text(_language, _charChart);
73}
74
76{
77 std::vector<State*>::const_iterator it, it_end;
78 it = m_states.begin(); it_end = m_states.end();
79 for (; it != it_end; it++)
80 {
81 if ( (*it)->name() == name )
82 {
83 return *it;
84 }
85 }
86 return 0;
87}
88
90{
91 std::vector<State*>::iterator it, it_end;
92 it = m_states.begin(); it_end = m_states.end();
93 for (; it != it_end; it++)
94 {
95 if ( (*it)->name() == name )
96 {
97 return *it;
98 }
99 }
100 return 0;
101}
102
103} //namespace FlatTokenizerAutomaton
104} // namespace LinguisticProcessing
105} // namespace Lima
#define LDEBUG
Definition LimaCommon.h:157
#define LERROR
Definition LimaCommon.h:161
#define TOKENIZERLOGINIT
Defines a Factory to create Object of type Base.
#define FLATTOKENIZERAUTOMATON_CLASSID
return a message when a 'param' was not found
Manage initialization of InitializableObjects using configuration module and parameters.
const InitializationParameters & getInitializationParameters() const
get Initialization Parameters
Use this exception to signal an error in one of the configuration files.
Definition LimaCommon.h:345
void init(Common::XMLConfigurationFiles::GroupConfigurationStructure &unitConfiguration, Manager *manager) override
static const LinguisticResources & single()
const singleton accessor
Definition Singleton.h:51
SimpleFactory< AbstractResource, TokenizerAutomaton > flatTokenizerFactory(FLATTOKENIZERAUTOMATON_CLASSID)
NAUTITIA.
QString LimaString
Definition LimaString.h:33
STL namespace.
launch exception related to the configuration file parsing