-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyntaxhelper.h
More file actions
56 lines (45 loc) · 1.49 KB
/
syntaxhelper.h
File metadata and controls
56 lines (45 loc) · 1.49 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
#ifndef SYNTAXHELPER_H
#define SYNTAXHELPER_H
#include <QString>
#include <QVector>
#include <QJsonDocument>
#include <QFile>
#include <QDebug>
#include <QJsonParseError>
#include <QJsonArray>
#include <QJsonObject>
#include "vikaword.h"
#include <QElapsedTimer>
class VikaSyntax {
public:
VikaSyntax();
VikaSyntax(QVector<QString> verbs, QVector<QString> objects, QString localisation, QVector<QString> adjectives);
QVector<QString> Verbs;
QVector<QString> Objects;
QVector<QString> Adjectives;
QString Localisation;
QString description;
void Print() const;
//Compares two syntaxes and returns a equality score (0 - no match, 100 - Full match)
static short Compare(const VikaSyntax& lhs, const VikaSyntax& rhs);
};
enum SyntaxType { Verb, Object, Localisation, Adjective };
//Interface between the json files and the objects
class SyntaxHelper {
public:
SyntaxHelper();
VikaSyntax GetSyntax(QStringList sentence);
QVector<int> GetSynonyms(const QString& word, SyntaxType type) const;
bool IsVerb(const QString& word) const;
bool IsObject(const QString& word) const;
bool IsLocalisation(const QString& word) const;
bool isAdjective(const QString& word) const;
int IndexOfWord(const QString &word, SyntaxType type) const;
private:
//Stores words from JSON words lists
QVector<VikaWord> _verbList;
QVector<VikaWord> _objectList;
QVector<VikaWord> _localisationList;
QVector<VikaWord> _adjectiveList;
};
#endif // SYNTAXHELPER_H