WordRange construct

This commit is contained in:
yanyiwu 2016-04-17 21:57:36 +08:00
parent 339e3ca772
commit 6ff6fe1430
4 changed files with 9 additions and 12 deletions

View File

@ -63,13 +63,13 @@ class FullSegment: public SegmentBase {
const DictUnit* du = dags[i].nexts[j].second;
if (du == NULL) {
if (dags[i].nexts.size() == 1 && maxIdx <= uIdx) {
unicode::WordRange wr = {begin + i, begin + nextoffset};
unicode::WordRange wr(begin + i, begin + nextoffset);
res.push_back(wr);
}
} else {
wordLen = du->word.size();
if (wordLen >= 2 || (dags[i].nexts.size() == 1 && maxIdx <= uIdx)) {
unicode::WordRange wr = {begin + i, begin + nextoffset};
unicode::WordRange wr(begin + i, begin + nextoffset);
res.push_back(wr);
}
}

View File

@ -57,7 +57,7 @@ class HMMSegment: public SegmentBase {
}
right ++;
} while (false);
unicode::WordRange wr = {left, right - 1};
unicode::WordRange wr(left, right - 1);
res.push_back(wr);
left = right;
} else {
@ -114,7 +114,7 @@ class HMMSegment: public SegmentBase {
for (size_t i = 0; i < status.size(); i++) {
if (status[i] % 2) { //if (HMMModel::E == status[i] || HMMModel::S == status[i])
right = begin + i + 1;
unicode::WordRange wr = {left, right - 1};
unicode::WordRange wr(left, right - 1);
res.push_back(wr);
left = right;
}

View File

@ -99,11 +99,11 @@ class MPSegment: public SegmentBase {
const DictUnit* p = dags[i].pInfo;
if (p) {
assert(p->word.size() >= 1);
unicode::WordRange wr = {begin + i, begin + i + p->word.size() - 1};
unicode::WordRange wr(begin + i, begin + i + p->word.size() - 1);
words.push_back(wr);
i += p->word.size();
} else { //single chinese word
unicode::WordRange wr = {begin + i, begin + i};
unicode::WordRange wr(begin + i, begin + i);
words.push_back(wr);
i++;
}

View File

@ -31,6 +31,9 @@ typedef limonp::LocalVector<struct RuneStr> RuneStrArray;
struct WordRange {
RuneStrArray::const_iterator left;
RuneStrArray::const_iterator right;
WordRange(RuneStrArray::const_iterator l, RuneStrArray::const_iterator r)
: left(l), right(r) {
}
size_t Length() const {
return right - left + 1;
}
@ -44,12 +47,6 @@ struct WordRange {
}
}; // struct WordRange
//struct RuneWordStr {
// Unicode word;
// const char* str;
// size_t len;
//}; // struct RuneWordStr
struct RuneStrLite {
uint32_t rune;
uint32_t len;