分词软件,谁来帮我看看,十万火急,需要原程序请和我联系,信箱:ruiqi0407@163.com(100分)

  • 主题发起人 主题发起人 ruiqi0407
  • 开始时间 开始时间
R

ruiqi0407

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;

type
SHLSegWord=packed record
s_szWord:Pchar;
s_dwPos:LongWord;
s_fWeigth:Single;
end;
P_SHLSegWord=^SHLSegWord;
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
BitBtn1: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
BitBtn7: TBitBtn;
BitBtn8: TBitBtn;
Tmemo1: TMemo;
Tmemo2: TMemo;
Tmemo3: TMemo;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure BitBtn8Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
DicSOF:Boolean;//----------------------------检验是否已经打开词典
end;

var
Form1: TForm1;

implementation
Uses
MyDll;

//Dll中的函数接口
//获取指定下标的关键词


{$R *.dfm}

procedure TForm1.BitBtn8Click(Sender: TObject);
begin
If DicSOF then
Begin
HLFreeUsrDict();
End;
HlFreeSplit();
close;

end;

procedure TForm1.BitBtn4Click(Sender: TObject);
begin
Tmemo1.Text :='';
Tmemo2.Text :='';
Tmemo3.Text :='';
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
Var
File_FilePath:String;
SucOrFai:Bool;
begin
if opendialog1.Execute then
begin
File_FilePath:=OpenDialog1.FileName;
SucOrFai:=HLOpenUsrDict(Pchar(File_FilePath));
If SucOrFai then
//可以添加声音文件
MessageDlg('装载用户字典成功',mtconfirmation,[mbok],0)
Else
//可以添加声音文件
MessageDlg('装载用户字典失败',mtconfirmation,[mbok],0);
end;

end;

procedure TForm1.BitBtn1Click(Sender: TObject);
Var
s:string;

hlHandle:THandle;
nCnt:Integer;
i:Integer;
R_Success:BOOL; //分词切分成功与否的标志
L_Word:SHLSegWord;//用于获得分词结果
StrWord:Pchar; //用于接收分词后的结果
S_String:AnsiString;


begin
s:='';
Tmemo1.Text :='';
Tmemo2.Text :='';
Caption:='分词系统';
if(not HLSplitInit('')) then
begin
Beep;
MessageDlg('初始化分词系统失败',mtconfirmation,[mbok],0);
application.Terminate ;
end;



S_String:=''; //清空临时字符串存放地的内容
Tmemo2.Text :='';
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);

L_Word.s_szWord :=nil;
L_Word.s_dwPos :=0;
L_Word.s_fWeigth :=0.0;

For i:=1 to nCnt do
begin
L_Word:=HLGetWordAt(hlHandle,i-1); //获取指定序号下的字符串信息

If L_Word.s_szWord=nil then
Begin
Beep;
MessageDlg('获取分词信息失败',mtconfirmation,[mbok],0);
Exit;
End
Else
Begin
StrWord:=L_Word.s_szWord ;

S_String:=StrWord; //由于Pchar类型的不支持用"+"进行字符串的操作,故用了一个中间变量
S_String:=S_String+'';//进行字符串的累加;
End;
Tmemo2.Text :=S_String;

HlCloseSplit(hlHandle);
end;
End
Else
Begin
Beep;
MessageDlg('分词失败!',mtconfirmation,[mbok],0);
HLCloseSplit(hlHandle);
End;

end;

procedure TForm1.BitBtn5Click(Sender: TObject);
begin
HLFreeUsrDict();
MessageDlg('用户词典卸载成功!',mtconfirmation,[mbok],0);

end;

procedure TForm1.BitBtn6Click(Sender: TObject);
begin
if opendialog1.execute then
begin
Tmemo1.Text:=ExtractFileName(opendialog1.filename);
Tmemo1.Lines.LoadFromFile(OpenDialog1.FileName );
end
end;

procedure TForm1.BitBtn7Click(Sender: TObject);
//var
//i:Integer;
begin
//for i:=0 to Tmemo3.Lines.Count-1 do
if savedialog1.execute then
begin
//WriteLn(savedialog1.FileName,Tmemo3.Lines)
Tmemo3.Lines.SaveToFile(savedialog1.FileName );
Tmemo3.Lines.LoadFromFile(savedialog1.FileName );
end
end;

end.
 
不知道老兄分词词典多大?

速度多少?精度多少?
 
我想给文章或者一句话分词,不要求精度,速度,
 
关键是这段程序
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:=''; //清空临时字符串存放地的内容
Tmemo2.Text :='';
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;
 
实在不行修改这段程序也行
procedure TForm1.BitBtn1Click(Sender: TObject);
Var
s:string;

hlHandle:THandle;
nCnt:Integer;
i:Integer;
R_Success:BOOL; //分词切分成功与否的标志
L_Word:SHLSegWord;//用于获得分词结果
StrWord:Pchar; //用于接收分词后的结果
S_String:AnsiString;


begin
s:='';
Tmemo1.Text :='';
Tmemo2.Text :='';
Caption:='分词系统';
if(not HLSplitInit('')) then
begin
Beep;
MessageDlg('初始化分词系统失败',mtconfirmation,[mbok],0);
application.Terminate ;
end;



S_String:=''; //清空临时字符串存放地的内容
Tmemo2.Text :='';
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);

L_Word.s_szWord :=nil;
L_Word.s_dwPos :=0;
L_Word.s_fWeigth :=0.0;

For i:=1 to nCnt do
begin
L_Word:=HLGetWordAt(hlHandle,i-1); //获取指定序号下的字符串信息

If L_Word.s_szWord=nil then
Begin
Beep;
MessageDlg('获取分词信息失败',mtconfirmation,[mbok],0);
Exit;
End
Else
Begin
StrWord:=L_Word.s_szWord ;

S_String:=StrWord; //由于Pchar类型的不支持用"+"进行字符串的操作,故用了一个中间变量
S_String:=S_String+'';//进行字符串的累加;
End;
Tmemo2.Text :=S_String;

HlCloseSplit(hlHandle);
end;
End
Else
Begin
Beep;
MessageDlg('分词失败!',mtconfirmation,[mbok],0);
HLCloseSplit(hlHandle);
End;

end;
 
有哪位大虾感兴趣想帮我看看,可以和我联系,我把原程序发给他。
ruiqi0407@163.com
 
请大家帮我看看,显示不出来结果怎么办,算法运行正确。
.....
....
type
SHLSegWord=packed record
s_szword:pchar
end;
P_SHLSegWord=^SHLSegWord;
.........
var
s:string;
hlHandle:THandle;
cnt:Integer;
i:Integer;
R_Success:Bool;
L_Word:SHLSegWord;
strword:string;
s_string:Ansistring;
............
for i:=0 to nCnt-1 do
begin
L_Word:HLGetWordAt(hlHandle,i);///???这里类型不对,在Tmemo2中显示不出来,谁能帮我改一改?
if L_Word <> nil then
begin
strword:=L_Word.s_szword;
s_string:=string;
s_string:=s_string+'';
end;
Tmemo2.text:=s_string;
HLCloseSplit(hlHandle);
 
将HLGetWordAt等函数的声明类型也发上来看一看吧。
 
unit MyDll;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Unit1;


Function HLSplitInit(lpszDataFilePath:Pchar):Bool;cdecl;//初始化海量分词系统
Procedure HLFreeSplit();cdecl ; //卸载海量分词系统,释放系统所占资源
Function HLOpenSplit ():THandle;cdecl ; //创建中文分词句柄
Procedure HLCloseSplit( hHandle:THandle);cdecl; //关闭分词结果句柄,释放分词结果所占资源
Function HLSSplit ( hHandle:THandle; lpText:Pchar ; ExtraCalcFlag:Integer):BOOL;cdecl ;//对指定字符串进行分词
FunCtion HLGetWordCnt( hHandle:THandle):Integer;cdecl; //得到分词结果中词的个数
Function HLGetWordAt ( hHandle:THandle; iIndex:Integer):SHLSegWord;cdecl; //得到指定的分词结果
Function HLOpenUsrDict(UserDictName:Pchar):BOOL;cdecl ; //加载用户自定义的字典
Procedure HLFreeUsrDict();cdecl ;//卸载用户自定义词典
Function HLGetFileKeyCnt( hHandle:THandle):Integer;cdecl ; //获取关键词的个数
Function HLGetFileKeyAt ( hHandle:THandle):SHLSegWord;cdecl;

implementation
Function HLSplitInit ; external 'HLSSplit.dll' name 'HLSplitInit'; //初始化海量分词系统
Procedure HLFreeSplit ; external 'HLSSplit.dll' name 'HLFreeSplit' ; //卸载海量分词系统,释放系统所占资源
Function HLOpenSplit ; external 'HLSSplit.dll' name 'HLOpenSplit'; //创建中文分词句柄
Procedure HLCloseSplit; external 'HLSSplit.dll' name 'HLCloseSplit'; //关闭分词结果句柄,释放分词结果所占资源
Function HLSSplit ; external 'HLSSplit.dll' name 'HLSplitWord';//对指定字符串进行分词
FunCtion HLGetWordCnt; external 'HLSSplit.dll' name 'HLGetWordCnt'; //得到分词结果中词的个数
Function HLGetWordAt ; external 'HLSSplit.dll' name 'HLGetWordAt'//得到指定的分词结果
Function HLOpenUsrDict; external 'HLSSplit.dll' name 'HLOpenUsrDict'; //加载用户自定义的字典
Procedure HLFreeUsrDict; external 'HLSSplit.dll' name 'HLFreeUsrDict';//卸载用户自定义词典
Function HLGetFileKeyCnt; external 'HLSSplit.dll' name 'HLGetFileKeyCnt'; //获取关键词的个数
Function HLGetFileKeyAt; external 'HLSSplit.dll' name 'HLGetFileKeyAt';


end.
 
有没有人来帮帮我这只小虾米?
 
后退
顶部