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)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)