【发布时间】:2016-06-25 21:48:20
【问题描述】:
我正在尝试使用此功能从 MarkLogic 8 中的文本中删除停用词:
declare function rec:remove-stop-words($string, $stop_words) {
(: This is a recursive function. :)
if(not(empty($stop_words))) then
rec:remove-stop-words(
replace($string, $stop_words[1], '', 'i'),
(: This passes along the stop words after
the one just evaluated. :)
$stop_words[position() > 1]
)
else normalize-space($string)
};
这里我叫它
for $r in /rec:Record
return
rec:remove-stop-words(data($r/rec:Abstract), $stop_words}
它给了我以下错误
XDMP-ARGTYPE: (err:XPTY0004) fn:replace((xs:untypedAtomic(" 章节 利用 n..."), xs:untypedAtomic(" 书 ..."))、"a"、""、"i") 之间的相互关系 -- arg1 不是 xs:string 类型?
该函数需要string 类型,但实际类型是untypedAtomic。我不知道该怎么办!
注意:((问题不在函数中,因为我尝试将它用于不同的文本并且效果很好))。
我尝试通过以下方式将untypedAtomic 转换为string 代码:
return
<info>{rec:remove-stop-words(data(xs:string($r/rec:Abstract)), $stop_words)}</info>
但我收到了这个错误:
XDMP-ARGTYPE: (err:XPTY0004) fn:replace((" 章节 利用 n 的不对称性...", " 书 ...")、"a"、""、"i") 之间的相互关系 -- arg1 不是 xs:string 类型
【问题讨论】:
标签: string xquery marklogic type-conversion untyped-variables