导入txt文本字库 - ImportTxtDict
函数简介
从指定的txt文本文件导入字库数据到内存,便于后续文字识别使用。该接口不会将数据保存到数据库。
接口名称
ImportTxtDict
DLL调用
int ImportTxtDict(long instance, string dictName, string dictPath);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| dictName | 字符串 | 字库名称,用于标识当前导入的字库 |
| dictPath | 字符串 | txt文本字库文件路径,例如 C:\\dicts\\mydict.txt |
示例
C++
long instance = CreateCOLAPlugInterFace();
// 从txt文件导入字库到内存(不保存到数据库)
int ret = ImportTxtDict(instance, "mydict", "C:\\dicts\\mydict.txt");
Python
# 待补充
返回值
1 成功,0 失败。
注意事项
- 该接口仅将字库数据导入内存,不会保存到数据库,如需持久化请使用
InitDictFromTxt接口 - 建议在开发调试阶段使用该接口导入/调试字库,正式发布时可将字库存入数据库
- 请确保
dictPath对应的txt文件存在且格式正确 - 若字库中已存在同名条目,则返回失败
