下面这一段不是某种语言源代码,只用于说明方法。
string sentence,temp;
array of string word_list;
integer i,word_count;
i=0;word_count=0;
while i<sentence_length do
begin
temp=sentence[i];
while is_word(temp) do
begin
i=i+1;
temp=temp+sentence[i];
end;
word_list[word_count]=temp;
word_count=word_count+1;
end;
这种方法的准确率大概只有80%。is_word函数中可以简单的通过查询词语库来返回是否是一个词语。