Debian Codegraph @

data/0.12-dev/gen_pms/fast.cpp

raw
1 #include "fast.h"
2 #include <fstream>
3 #include <strstream>
4 using namespace std;
5
6 AikSaurusFAST::AikSaurusFAST()
7 {
8 ifstream fin("thesaurus.in");
9 string index, words;
10
11 while(fin >> index >> words)
12 {
13 vector<string> foo;
14 for(unsigned int i = 0;i < words.size();++i)
15 {
16 if (words[i] == ',') words[i] = ' ';
17 }
18
19 istrstream ss(words.c_str());
20 string str;
21
22 while(ss >> str)
23 foo.push_back(str);
24
25 d_data.insert(make_pair(index, foo));
26 }
27 }
28
29 const vector<string>& AikSaurusFAST::getSynonyms(const string& word)
30 {
31 map<string, vector<string> >::iterator thing = d_data.find(word);
32
33 if (thing == d_data.end())
34 {
35 return d_null;
36 }
37
38 else
39 {
40 return thing->second;
41 }
42 }
43