delphi
比如在資料庫或者
stringGrid 或者 dbGrid里邊,有這樣的一組資料

然后,原句如:
深圳很好,發展很不錯
就會匹配深圳,然后找到相應的提示。
求指點。
亦或者,原句:這里有一只小貓
就會因小貓觸發匹配,找到其對應的提示。
uj5u.com熱心網友回復:
如果詞庫條目不多的話,一兩百以內,直接把字串分詞查找就可以了uses System.SysUtils, System.Math, Vcl.Grids;
function TFrom1.FindHint(const S: string): string;
var
i, j, k: integer;
word: string;
begin
for i := 1 to Length(S) do
for j := i to Min(i + 4, Length(S)) do
begin
word := Copy(S, i, j - i + 1);
for k := 0 to StringGrid1.RowCount - 1 do
if Pos(word, StringGrid1.Cols[0][k]) > 0 then
begin
Result := StringGrid1.Cols[1][k];
exit;
end;
end;
end;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/8175.html
標籤:語言基礎/算法/系統設計
上一篇:高手求救!!! 騰訊云
