C/C++ code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "friso/friso.h"
#include "friso/friso_API.h"
friso_t friso;
friso_task_t task;
typedef friso_t(*pfun_friso_new_from_ifile)(string);
typedef friso_task_t(*pfun_friso_new_task)();
typedef void(*pfun_friso_set_text)(friso_task_t,string);
typedef friso_hits_t(*pfun_friso_next)(friso_t,friso_mode_t,friso_task_t);
typedef void(*pfun_friso_free_task)(friso_task_t);
typedef void(*pfun_friso_free)(friso_t);
HINSTANCE hdll = LoadLibrary("friso\\friso.dll");
pfun_friso_new_from_ifile newfriso = (pfun_friso_new_from_ifile)GetProcAddress(hdll,"friso_new_from_ifile");
pfun_friso_new_task newtask = (pfun_friso_new_task)GetProcAddress(hdll,"friso_new_task");
pfun_friso_set_text frisosettext = (pfun_friso_set_text)GetProcAddress(hdll,"friso_set_text");
pfun_friso_next frisonext = (pfun_friso_next)GetProcAddress(hdll,"friso_next");
pfun_friso_free_task freetask = (pfun_friso_free_task)GetProcAddress(hdll,"friso_free_task");
pfun_friso_free freefriso = (pfun_friso_free)GetProcAddress(hdll,"friso_free");
LPSTR ini = "friso\\friso.ini";
friso = newfriso(ini);
task = newtask();
LPSTR txt = "測試:friso是使用c語言開發的壹個中文分詞器,使用流行的mmseg算法實現。完全基於模塊化設計和實現,可以很方便的植入到其他程序中,例如:MySQL,PHP等。 ";
frisosettext(task,txt);
while((frisonext(friso,friso->mode,task))!=NULL)
{
OutputDebugString(task->hits->word);//第壹次的輸出竟然不是“測試”而是“friso”
OutputDebugString(" ");
if(task->hits->type==__FRISO_NEW_WORDS__)
{
//第壹次運行到這裏就除錯
//錯誤提示:HEAP[fenci.exe]: Invalid Address specified to RtlValidateHeap( 00030000, 003954D0 )
FRISO_FREE(task->hits->word);
}
}
OutputDebugString("\r\n");
freetask(task);
freefriso(friso);