Skip to content

Commit

Permalink
修正全角空格的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
luoleicn committed Mar 6, 2016
1 parent d1260f2 commit 532e80a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/segmentor/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,16 @@ int Preprocessor::preprocess(const std::string& sentence,
width = 1;
}
else if ((sent[i]&0xE0)==0xC0) { width = 2; }
else if ((sent[i]&0xF0)==0xE0) { width = 3; }
else if ((sent[i]&0xF0)==0xE0) {
width = 3;
if (i + 3 <= len && sent[i] == 0xffffffe3 && sent[i + 1] == 0xffffff80 && sent[i + 2] == 0xffffff80) {
is_space = true;
}
}
else if ((sent[i]&0xF8)==0xF0) { width = 4; }
else { return -1; }


if (is_space) {
left_status = HAS_SPACE_ON_LEFT;
if (chartypes.size() > 0) { chartypes.back() |= HAS_SPACE_ON_RIGHT; }
Expand Down

0 comments on commit 532e80a

Please sign in to comment.