This repository was archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsoundchanges.h
More file actions
89 lines (70 loc) · 2.83 KB
/
soundchanges.h
File metadata and controls
89 lines (70 loc) · 2.83 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef SOUNDCHANGES_H
#define SOUNDCHANGES_H
class QString;
class QStringList;
class QChar;
class QRegularExpression;
template <class Key, class T> class QMap;
template <class T> class QList;
template <class T> class QQueue;
namespace std
{
template <class T1, class T2> struct pair;
}
class SoundChanges
{
public:
static QStringList ApplyChange(QString word, QString change, QMap<QChar, QList<QChar>> categories, int probability, bool reverse, bool alwaysApply, bool sometimesApply);
static QString PreProcessRegexp(QString regexp, QMap<QChar,QList<QChar>> categories);
static QString Syllabify(QString regexp, QString word, QChar seperator);
static QString RemoveDuplicates(QString s);
static QStringList Reanalyse(QStringList sl);
static QStringList Filter(QStringList sl, QStringList f, QMap<QChar, QList<QChar>> cats);
static void ReverseFirstTwo(QStringList &l);
private:
static bool TryRule(QString word,
int wordIndex,
QString change,
QMap<QChar, QList<QChar>> categories,
int *startpos,
int *length,
QQueue<std::pair<int, QChar>> *catnums,
bool reverse);
static bool TryCharacters(QString word,
int wordIndex,
int *finalIndex,
QString change,
QString target,
QMap<QChar, QList<QChar>> categories,
int *startpos,
int *length,
QQueue<std::pair<int, QChar>> *outcats,
bool recordcats,
QChar *lastCharParsed);
static bool TryCharacter(QString word,
QChar c,
QChar lastChar,
QChar *lastCharParsed,
QString target,
int &curIndex,
QMap<QChar, QList<QChar>> categories,
int *startpos,
int *length,
QQueue<std::pair<int, QChar>> *outcats,
bool recordcats);
static bool MatchChar(QChar char1,
QChar char2,
QMap<QChar, QList<QChar>> categories,
int *catnum);
static std::pair<QString, bool> ParseNonce(QList<QChar> nonce, QMap<QChar, QList<QChar>> categories);
static int ActualLength(QString rule);
static int MaxLength(QList<std::pair<QString, int>> l);
enum class State
{
Normal,
Optional,
Nonce,
Backreference
};
};
#endif // SOUNDCHANGES_H