LIMA
Libre Multilingual Analyzer — C++ API
Loading...
Searching...
No Matches
Char.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#include "Char.h"
7#include "CharClass.h"
8
10
11namespace Lima
12{
13namespace LinguisticProcessing
14{
15namespace FlatTokenizer
16{
17
19{
20
21public:
22 explicit CharPrivate(LimaChar code);
23
24 virtual ~CharPrivate();
25
28
31
32 const Char* m_maj;
33 const Char* m_min;
34 const Char* m_unmark;
36};
37
39m_code(code), m_surrogate(0), m_name(),
40m_class(0), m_maj(0), m_min(0), m_unmark(0), m_longUnmark(0)
41{
42}
43
47
49m_d(new CharPrivate(code))
50{
51}
52
54{
55 delete m_d;
56}
57
59Lima::LimaChar Char::code() const {return m_d->m_code;}
61const Lima::LimaString& Char::name() const {return m_d->m_name;}
62const CharClass* Char::charClass() const {return m_d->m_class;}
63
66void Char::setName(const Lima::LimaString& name) {m_d->m_name = name;}
67void Char::setCharClass(const CharClass* cl) {m_d->m_class = cl;}
68
69const Char* Char::maj() const {return m_d->m_maj;}
70const Char* Char::min() const {return m_d->m_min;}
71const Char* Char::unmark() const {return m_d->m_unmark==0?m_d->m_min:m_d->m_unmark;}
72const Char* Char::longUnmark() const {return m_d->m_longUnmark;}
73bool Char::hasLongUnmark() const {return m_d->m_longUnmark != 0;}
74
75
76void Char::setMaj(const Char* maj)
77{
78 m_d->m_maj = maj;
79 // if this has a maj, then there is a maj/min relation and this is the min
80 // allows to discard acronym dots when unmarking
81 if (maj != 0 && m_d->m_min == 0)
82 {
83 m_d->m_min = this;
84 }
85// if (maj != 0 && m_d->m_unmark == 0)
86// {
87// m_d->m_unmark = this;
88// }
89}
90
91void Char::setMin(const Char* min)
92{
93 m_d->m_min = min;
94 // if this has a min, then there is a maj/min relation and this is the maj
95 // allows to discard acronym dots when unmarking
96 if (min != 0 && m_d->m_maj == 0)
97 {
98 m_d->m_maj = this;
99 }
100// if (min != 0 && m_d->m_unmark == 0)
101// {
102// m_d->m_unmark = this;
103// }
104}
105void Char::setUnmark(const Char* un)
106{
108 LDEBUG << "Char::setUnmark" << (void*)this << this->code() << un->code() << (void*)m_d->m_unmark;
109 if (m_d->m_unmark == 0)
110 {
111 m_d->m_unmark = un;
112 if (un != 0 && m_d->m_min == 0)
113 {
114 m_d->m_min = this;
115 }
116 if (un != 0 && m_d->m_maj == 0)
117 {
118 m_d->m_maj = this;
119 }
120 }
121 else
122 {
123 setLongUnmark(un);
124 }
125}
127{
129 LDEBUG << "Char::setLongUnmark" << (void*)this << this->code() << lu->code();
130 m_d->m_longUnmark = lu;
131
132}
133
134} // Tokenizer
135} // LinguisticProcessing
136} // Lima
#define LDEBUG
Definition LimaCommon.h:157
#define TOKENIZERLOADERLOGINIT
const Lima::LimaString & name() const
Definition Char.cpp:61
void setName(const Lima::LimaString &name)
Definition Char.cpp:66
const CharClass * charClass() const
Definition Char.cpp:62
void setCharClass(const CharClass *cl)
Definition Char.cpp:67
NAUTITIA.
QChar LimaChar
Definition LimaString.h:30
QString LimaString
Definition LimaString.h:33