此项功能就像 API一样,需要专业理论的帮助,建立在 Adjust Settings | Advanced环境下。
功能及用法
处理文本时标准因人而异,且不同于已建立的标准(文本、搜索词的选择不同等)。在输入WordSmith之前用户可能需要对数据做专门的检查或改动。例如:用户可能会根据某一语言的要求对单词做必要的变形。
该项功能就可实现以上情况。例如:用户要选择或过滤索引行。当 Concord 处理其文本文件时,每次找到搜索词的匹配项时,它就会引用用户的 .dll 文件。它会告诉 .dll文件所发现的匹配项,并且使该文件修改结果或命令 Concord 忽略这一项。
如何操作
选择 .dll 文件 (用户可重命名该文件),然后在Advanced页面检查一个或多个选项。在此用户需要引用标准的公式,需要知道它们的名称和格式。用户要按照自己的操作要求编写自己的.dll 文件。程序编写客采用任何一种编程语言(C++, Java, Pascal等)。
An example for lemmatising a word in WordList
下方显示的动态链接方案是在安装时载入的,编写完整,可以运行。
用户自己的 .dll 文件需要包含以下参数说明的功能
function WordlistChangeWord(
original : pointer;
language_identifier : DWORD;
is_Unicode : WordBool) : pointer; stdcall;
language_identifier 是用户所选用语言的的对应数字。参见:List of Locale ID (LCID) Values as Assigned by Microsoft .
因此, "最初的" (WordSmith提供的)的语言是一个PCHAR字符串(7或8字节,也可能是一个PWIDECHAR字符串(16字节,双字节统一码),那么用户自己的 .dll 文件指令需指出
a)零(如果用户不需要列表中原有的词)
b) 同一个 PCHAR/PWIDECHAR字符串,如果字符串不会被改动
c) 一个替换表格
这是一个源文本出处的例子
Today is Easter Day.
下方是Delphi中.dll的源编码
************************************
library WordSmithCustomDLL;
uses
Windows, SysUtils;
{
This example uses a very straightforward Windows routine for comparing
strings, CompareStringA and CompareStringW which are in a Windows .dll.
The function does a case-insensitive comparison because
NORM_IGNORECASE (=1) is used. If it was replaced by 0, the comparison
would be case-sensitive.
In this example, EASTER gets changed to CHRISTMAS.
}
function WordlistChangeWord(
original : pointer;
language_identifier : DWORD;
is_Unicode : WordBool) : pointer; stdcall;
begin
Result := original;
if is_Unicode then begin
if CompareStringW(
language_identifier,
NORM_IGNORECASE,
PWideChar(original), -1,
PWideChar(widestring('EASTER')), -1) - 2 = 0
then
Result := pwidechar(widestring('CHRISTMAS'));
end else begin
if CompareStringA(
language_identifier,
NORM_IGNORECASE,
PChar(original), -1,
PChar('EASTER'), -1) - 2 = 0
then
Result := pchar('CHRISTMAS');
end;
end;
function ConcordChangeWord(
original : pointer;
language_identifier : DWORD;
is_Unicode : WordBool) : pointer; stdcall;
begin
Result := WordlistChangeWord(original,language_identifier,is_unicode);
end;
function KeyWordsChangeWord(
original : pointer;
language_identifier : DWORD;
is_Unicode : WordBool) : pointer; stdcall;
begin
Result := WordlistChangeWord(original,language_identifier,is_unicode);
end;
function HandleConcordanceLine
(source_line : pointer;
hit_position,
hit_length : word;
byte_position_in_file,
language_id : DWORD;
is_Unicode : WordBool;
filename : pchar) : pointer; stdcall;
function extrasA : string;
begin
Result := #9+pchar(filename)+
#9+ IntToStr(byte_position_in_file)+
#9+ IntToStr(hit_position)+
#9+ IntToStr(hit_length);
end;
function extrasW : widestring;
begin
Result := extrasA;
end;
var f : TextFile;
output_file : string;
begin
Result := source_line;
output_file := ChangeFileExt(ParamStr(0),'')+
'_user_dll_concordance_lines.txt';
if (not IsPathDelimiter(ExpandUNCFileName(ParamStr(0)),1)) and
(DiskFree(Ord(UpCase(output_file[1]))-64) > 1024*2000) then
try
if FileExists(output_file) then begin
AssignFile(f,output_file);
Append(f);
end else begin
AssignFile(f,output_file);
Rewrite(f);
end;
if is_Unicode then
Writeln(f,pwidechar(source_line)+extrasW)
else
Writeln(f,pchar(source_line)+extrasA);
Flush(f);
CloseFile(f);
except
end;
end;
exports
ConcordChangeWord,
KeyWordsChangeWord,
WordlistChangeWord,
HandleConcordanceLine;
begin
end.
参见: API,custom settings
Page url: http://www.lexically.net/wordsmith/step_by_step_Chinese/?custom_processing.htm