-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_lm.cpp
More file actions
40 lines (33 loc) · 953 Bytes
/
Copy pathtest_lm.cpp
File metadata and controls
40 lines (33 loc) · 953 Bytes
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
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include "lm.h"
using namespace std;
int main()
{
LM lm;
const int size = 5;
string wlist[size] = {"a", "b", "c", "d", "e"};
for( int i = 0; i < size; i++ ){
lm.word.push_back(wlist[i]);
lm.prob.push_back(i);
}
const LM const_lm = lm;
cout << "Testing operator[] for ordinary LM object:" << endl;
for( int i = 0; i < size; i++ ){
string w = wlist[i];
cout << "lm[" << w << "] = " << lm[w] << endl;
}
cout << "Testing operator[] for const LM object:" << endl;
for( int i = 0; i < size; i++ ){
string w = wlist[i];
cout << "const_lm[" << w << "] = " << const_lm[w] << endl;
}
cout << "Testing for clear():" << endl;
lm.clear();
cout << "Size of word after lm.clear(): " << lm.word.size()
<< "\nSize of prob after lm.clear(): " << lm.prob.size()
<< endl;
}