• 回答数

    1

  • 浏览数

    303

机智小百合
首页 > 英语培训 > 英语自动分词程序

1个回答 默认排序
  • 默认排序
  • 按时间排序

vivianygefes

已采纳

procedure TForm1.Button1Click(Sender: TObject);var I: Integer; str: String; ts: TStringList; strCount: Integer;begin//65,90,97,122 str := UpperCase(MEmo1.Text ); For I := Length(str) - 1 Downto 1 do begin if not (Ord(str[I]) in [65..90,97..122,32]) then //将不是空格,大、小写英文字母的字符转换成空格 str[I] := ' '; end; memo1.Text := Str; For I := Length(str) - 1 Downto 2 do //清除连续二个或多个空格的情况 begin if (str[I] = ' ') and (str[I - 1 ] = ' ') then delete(str, I, 1); end; memo1.Text := Str; ListBox1.Items.Text := StringReplace(Trim(str), ' ', #13#10, [rfReplaceAll]); //显示到LISTBOX ListBox1.Sorted := true; //排序 //循环并取出每个词出现的个数,并把结果保存到LSITBOX2 strCount := 1; ListBox2.Items.Append(ListBox1.Items[ListBox1.items.Count - 1] + ' 1'); for I := ListBox1.Count - 2 Downto 0 do if ListBox1.Items[I] = ListBox1.Items[I + 1] then begin inc(StrCount); ListBox2.Items[ListBox2.items.Count - 1] := ListBox1.Items[I] + ' ' + IntToStr(strCount); ListBox1.Items.Delete(I); end else begin StrCount := 1; ListBox2.Items.Append(ListBox1.Items[I] + ' ' + IntToStr(strCount)); end;end;

英语自动分词程序

287 评论(8)

相关问答