XQuery wrap/truncate 全词 (KWIC)
XQuery wrap/truncate on whole word (KWIC)
在花了很长时间在 XQuery(运行 在 eXist-db 中)中构建自定义搜索功能后,我发现了 KWIC(上下文中的关键字)模块,它解决了我在代码中遇到的大部分问题。
我已经将 KWIC 的版本从 this blog (direct link 更新为更新的模块),但还有一个问题我正在努力解决。
我正在使用以下代码显示搜索结果:
let $kwicconfig := <config xmlns="" width="60" preserve-space="true" format="p" />
{for $match in $results
let $expanded := kwic:expand($match)
return
<li>
<em>{kwic:get-summary($expanded, ($expanded//exist:match)[1], $kwicconfig)}</em>
</li>
}
显示以下示例结果:
...nd the interpretation of the criteria. Examiners will be contacted b...
我仍然是 XQuery 的初学者,如何修改 KWIC 函数以便结果 wordwraps/truncates 整个单词,而不是像现在那样拆分单词?
请参阅 exist-open 邮件列表中的 this thread,其中包括 link 到具有此功能的修改后的 kwic.xql。一种更高级的方法是使用内置的 kwic.xql 函数,但使用 $callback
参数将回调函数传递给 truncate-previous
和 truncate-following
函数,并使用您的自定义修剪逻辑。
在花了很长时间在 XQuery(运行 在 eXist-db 中)中构建自定义搜索功能后,我发现了 KWIC(上下文中的关键字)模块,它解决了我在代码中遇到的大部分问题。
我已经将 KWIC 的版本从 this blog (direct link 更新为更新的模块),但还有一个问题我正在努力解决。
我正在使用以下代码显示搜索结果:
let $kwicconfig := <config xmlns="" width="60" preserve-space="true" format="p" />
{for $match in $results
let $expanded := kwic:expand($match)
return
<li>
<em>{kwic:get-summary($expanded, ($expanded//exist:match)[1], $kwicconfig)}</em>
</li>
}
显示以下示例结果:
...nd the interpretation of the criteria. Examiners will be contacted b...
我仍然是 XQuery 的初学者,如何修改 KWIC 函数以便结果 wordwraps/truncates 整个单词,而不是像现在那样拆分单词?
请参阅 exist-open 邮件列表中的 this thread,其中包括 link 到具有此功能的修改后的 kwic.xql。一种更高级的方法是使用内置的 kwic.xql 函数,但使用 $callback
参数将回调函数传递给 truncate-previous
和 truncate-following
函数,并使用您的自定义修剪逻辑。