R
ruiqi0407
Unregistered / Unconfirmed
GUEST, unregistred user!
type
SHLSegWord=packed record
s_szWordchar;
s_dwPos:LongWord;
s_fWeigth:Single;
end;
P_SHLSegWord=^SHLSegWord;
..........
var
Form1: TForm1;
implementation
Uses
MyDll,StructWordInfo;
//Dll中的函数接口
//获取指定下标的关键词
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
Var
hlHandle:THandle;
nCnt:Integer;
i:Integer;
R_Success:BOOL; //分词切分成功与否的标志
L_Word: String; //存放分词结果
//Temp_L_Word:String;
S_String:String; //Tmemo2的临时存放地
begin
S_String:=''; //清空临时字符串存放地的内容
if(not HLSplitInit('')) then
begin
Beep;
MessageDlg('初始化分词系统失败',mtconfirmation,[mbok],0);
application.Terminate ;
end;
//--------------------------------------检测打开分词句柄
hlHandle:=HLOpenSplit();
If(hlHandle=INVALID_HANDLE_VALUE)then
begin
beep;
MessageDlg('分词句柄没有成功打开?',mtconfirmation,[mbok],0);
Exit;
end;
//--------------------------------------开始分词
R_Success:=HLSSplit(hlHandle,Pchar(Trim(Tmemo1.Text)),0);
If R_Success then
Begin
//--------------------------获得分词结果个数
nCnt:= HLGetWordCnt(hlHandle);
//--------------------------获取分词结果操作
for i:=0 to nCnt-1 do
begin
//L_Word:=Pchar('00');
Setlength(L_Word,128);
L_Word:=GetDllString(hlHandle,i); //这一句已经将返回值为Pchar的转换为String类型的了
{Temp_L_Word:=Copy(L_Word,1,Length(L_Word)); }
DelDllString(GetDllString(hlHandle,i));
//DelDllString(Pchar(L_Word));
If i=0 then
begin //???整个程序的问题有可能是字符串不匹配
S_String:=L_Word;
end
Else
Begin
S_String:=Concat(S_String,' ',L_Word);
If i= nCnt-1 then
Begin
Break;
End;
S_String:=S_String+'';//进行字符串的累加;
End;
end;
Tmemo2.Text :=Trim(S_String);
MessageDlg(Trim(S_String),mtconfirmation,[mbok],0);
HLCloseSplit(hlHandle);//???运行到这出错
End
Else
Begin
Beep;
MessageDlg('分词失败!',mtconfirmation,[mbok],0);
HLCloseSplit(hlHandle);
End;
end;
SHLSegWord=packed record
s_szWordchar;
s_dwPos:LongWord;
s_fWeigth:Single;
end;
P_SHLSegWord=^SHLSegWord;
..........
var
Form1: TForm1;
implementation
Uses
MyDll,StructWordInfo;
//Dll中的函数接口
//获取指定下标的关键词
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
Var
hlHandle:THandle;
nCnt:Integer;
i:Integer;
R_Success:BOOL; //分词切分成功与否的标志
L_Word: String; //存放分词结果
//Temp_L_Word:String;
S_String:String; //Tmemo2的临时存放地
begin
S_String:=''; //清空临时字符串存放地的内容
if(not HLSplitInit('')) then
begin
Beep;
MessageDlg('初始化分词系统失败',mtconfirmation,[mbok],0);
application.Terminate ;
end;
//--------------------------------------检测打开分词句柄
hlHandle:=HLOpenSplit();
If(hlHandle=INVALID_HANDLE_VALUE)then
begin
beep;
MessageDlg('分词句柄没有成功打开?',mtconfirmation,[mbok],0);
Exit;
end;
//--------------------------------------开始分词
R_Success:=HLSSplit(hlHandle,Pchar(Trim(Tmemo1.Text)),0);
If R_Success then
Begin
//--------------------------获得分词结果个数
nCnt:= HLGetWordCnt(hlHandle);
//--------------------------获取分词结果操作
for i:=0 to nCnt-1 do
begin
//L_Word:=Pchar('00');
Setlength(L_Word,128);
L_Word:=GetDllString(hlHandle,i); //这一句已经将返回值为Pchar的转换为String类型的了
{Temp_L_Word:=Copy(L_Word,1,Length(L_Word)); }
DelDllString(GetDllString(hlHandle,i));
//DelDllString(Pchar(L_Word));
If i=0 then
begin //???整个程序的问题有可能是字符串不匹配
S_String:=L_Word;
end
Else
Begin
S_String:=Concat(S_String,' ',L_Word);
If i= nCnt-1 then
Begin
Break;
End;
S_String:=S_String+'';//进行字符串的累加;
End;
end;
Tmemo2.Text :=Trim(S_String);
MessageDlg(Trim(S_String),mtconfirmation,[mbok],0);
HLCloseSplit(hlHandle);//???运行到这出错
End
Else
Begin
Beep;
MessageDlg('分词失败!',mtconfirmation,[mbok],0);
HLCloseSplit(hlHandle);
End;
end;