hic.. i changed something which i couldn't remember what was changed
[vspell.git] / spell.cpp
blob28b283e8b8e87293203708bf0e8d041d33e301a7
1 #include "config.h" // -*- tab-width: 2 -*-
2 #include <iterator>
3 #include <algorithm>
4 #include <sstream>
5 #include <iostream>
6 #include <fstream>
7 #include "wfst.h"
8 #include "spell.h"
10 using namespace std;
11 using namespace Dictionary;
13 namespace Spell {
15 void check1(Sentence &st,Suggestions &sugg)
17 int i,n = st.get_syllable_count();
18 for (i = 0;i < n;i ++) {
19 strid id = st[i].get_cid();
20 if (sarch.in_dict(id))
21 continue;
23 st[i].sid = unk_id;
25 VocabString s = sarch[id];
26 if (strlen(s) == 1 && viet_isupper(s[0]) && viet_islower(s[0])) {
27 st[i].sid = sarch["<PUNCT>"];
28 continue;
31 Suggestion _s;
32 _s.id = i;
33 sugg.push_back(_s);
37 void check2(Sentence &st,Segmentation &seg,Suggestions &sugg)
39 int i,n = seg.items.size();
40 int cc = 0;
42 for (i = 0;i < n;i ++) {
43 vector<strid> sylls;
44 int len = seg.items[i].state->get_syllable_count();
45 if (len == 1) {
46 cc += len;
47 continue;
50 int start;
51 WordNodePtr node(get_root());
52 for (start = 0;start < len && node != NULL; start ++)
53 node = node->get_next(st[start+cc].cid);
55 cc += len;
56 if (node == NULL) {
57 Suggestion _s;
58 _s.id = i;
59 sugg.push_back(_s);