Skip to content

释放字库缓存 - FreeDict

函数简介

释放内存中的文本字库缓存,使后续 OCR 可重新加载最新字库。该接口仅清除内存缓存,不会修改数据库中的字库数据。

接口名称

FreeDict

DLL调用

int FreeDict(long instance, string dictName);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
dictName字符串字库名称;多个字库用 | 分割,如 dict1|dict2;传空字符串表示释放全部内存字库缓存。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.FreeDict("mydict");
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.FreeDict("mydict");
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.FreeDict("mydict")
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.FreeDict("mydict");
go
import "github.com/ola/olaplug/olaplug"

ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
ret := ola.FreeDict("mydict")
rust
use olaplug::OLAPlugServer;

let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let ret = ola.free_dict("mydict");
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.FreeDict("mydict")
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.FreeDict("mydict")
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.FreeDict(“mydict”)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.FreeDict("mydict");
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.FreeDict("mydict")
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.FreeDict("mydict");

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
FreeDict(instance, "mydict");
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeDict(long ola, string dictName);

long instance = CreateCOLAPlugInterFace();
FreeDict(instance, "mydict");
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.FreeDict(instance, "mydict")

返回值

返回值说明
1成功。
0失败。

注意事项

项目说明
仅释放内存缓存该接口仅释放内存中的字库缓存,不会删除或修改数据库中的字库数据。
更新字库后刷新缓存当通过 ImportDictWordInitDictFromTxt 等接口更新数据库字库后,可调用本接口释放旧缓存,使后续 OcrFromDict*FindStr* 等重新加载最新字库。
多库与全部释放dictName 支持 dict1|dict2 形式指定多个字库;传空字符串时释放全部内存字库缓存。
与 ImportTxtDict 配合通过 ImportTxtDict 导入的内存字库同样可被本接口释放;释放后需重新导入或从数据库加载。