LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
Events.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 11-JUL-2002
9//
10// Events is a string of events. Class of characters and other
11// events are in the form of printable bytes. Class Events
12// holds events which are of the same effect.
13
14#include "Events.h"
15#include "CharChart.h"
18
19#include <string>
20
21using namespace Lima::Common::Misc;
22
23namespace Lima
24{
25namespace LinguisticProcessing
26{
27namespace FlatTokenizer
28{
29
30Events::Events(std::shared_ptr<CharChart> chart) : std::vector<const CharClass*>(),
31 m_chart(chart)
32{
33}
34
36
37void Events::addEventNamed(const LimaString& eventName)
38{
39 push_back(m_chart->classNamed(eventName));
40}
41
42bool Events::isRecognized(const Lima::LimaChar& event) const
43{
44#ifdef DEBUG_LP
46#endif
47 for (uint64_t i = 0; i < size(); i++)
48 {
49// LDEBUG << "Events::isRecognized("<<i<<","<<event<<") ; size=" << size();
50 const CharClass* eventClass = m_chart->charClass(event);
51 while (eventClass != 0)
52 {
53#ifdef DEBUG_LP
54 LDEBUG << "| | | test event '"<< eventClass->name()
55 << "' on '" << ((*this)[i]==0?"":(*this)[i]->name()) <<"'";
56#endif
57 if ( (*this)[i] == eventClass )
58 {
59 return true;
60 }
61 eventClass = eventClass->superClass();
62 }
63 }
64 return false;
65}
66
67} //namespace FlatTokenizer
68} // namespace LinguisticProcessing
69} // namespace Lima
#define LDEBUG
Definition LimaCommon.h:157
#define TOKENIZERLOGINIT
const Lima::LimaString & name() const
Definition CharClass.h:27
bool isRecognized(const Lima::LimaChar &event) const
Definition Events.cpp:42
Events(std::shared_ptr< CharChart > chart)
Definition Events.cpp:30
void addEventNamed(const LimaString &eventName)
Definition Events.cpp:37
NAUTITIA.
QChar LimaChar
Definition LimaString.h:30
QString LimaString
Definition LimaString.h:33
STL namespace.