-
Notifications
You must be signed in to change notification settings - Fork 1
/
humanLanguage.cpp
43 lines (37 loc) · 996 Bytes
/
humanLanguage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "humanLanguage.h"
QSet<QChar> bgLetters(){
static QSet<QChar> r;
for(int i=0x410; i<=0x42A; i++) r << QChar(i);
r << QChar(0x42C);
for(int i=0x42E; i<=0x44A; i++) r << QChar(i);
r << QChar(0x44C);
for(int i=0x44E; i<=0x44F; i++) r << QChar(i);
return r;
};
QSet<QChar> bgPMarks(){
static QSet<QChar> r;
r << QChar('.') << QChar(',') << QChar('-') << QChar('(') << QChar(')');
r << QChar('!') << QChar('?') << QChar('"');
return r;
};
bool HumanLanguage::isLetter(QChar c){
return letters.contains(c);
};
bool HumanLanguage::isPMark(QChar c){
return pMarks.contains(c);
};
QChar HumanLanguage::nextPMark(const QString &s, int i){
QChar r = QChar();
for(int j=i; j<s.size(); j++){
if ( isLetter(s.at(j)) ) return r;
if ( isPMark(s.at(j)) ) return s.at(j);
}
return r;
};
HumanLanguage::HumanLanguage(HumanLanguageID id){
switch (id){
case bulgarian:
letters = bgLetters();
pMarks = bgPMarks();
}
};