This repository was archived by the owner on Mar 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (41 loc) · 1.24 KB
/
main.cpp
File metadata and controls
48 lines (41 loc) · 1.24 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
#include <iostream>
#include "Grammar.hpp"
using namespace std;
int main()
{
string a;
string s = "#JSGF v1.0;\
grammar sphinx-mode;\
public <command> = <pause> {pause} | <resume> {resume} | <push-to-talk> {push-to-talk} | <toggle> {toggle};\
<pause> = pause speech recognition;\
<resume> = resume speech recognition;\
<toggle> = toggle speech recognition;\
<push-to-talk> = ((enable | enter | begin | start) {enable} | (disable | exit | end | stop) {disable}) push to talk [mode];";
Grammar g;
Grammar::parseGrammarFromString(s, g);
cout << "PARSED GRAMMAR:" << endl;
cout << g.getText() << endl;
cout << "Rule Match Testing..." << endl;
getline(cin, a);
cout << a << endl;
std::string ruleName = g.getMatchingPublicRule(a);
if(ruleName != "") {
shared_ptr<Rule> r = g.getRule(ruleName);
if(r) {
cout << "Matched rule: " << r->getRuleName() << endl;
cout << "Matching tags:" << endl;
vector<string> t = Grammar::getMatchingTags(g.matchesRule(r, a));
for(string s : t) {
cout << "T:" << s << endl;
}
}
else {
cout << "Error returning Rule from ruleName!" << endl;
}
}
else {
cout << "Found no match!" << endl;
}
cout << "Test Done" << endl;
return 0;
}