问题描述
我有以下 Xquery
代码:
for $w in $words
let $freq := (count($corpus[. eq $w]) div count($content2[text() eq $w]))
order by $freq descending
return <tr><td>{$w}</td><td>{$freq}</td></tr>
$words
是一些在 $corpus
中出现(可能出现多次)的不同词.$content2
是另一个词袋.变量和除法不是那么重要.
$words
is some distinct words that appears (may appear multiple times) in $corpus
. $content2
is some another bag of words. Variables and division is not that important.
这个xquery
列出了一些词的频率计算,有序.
This xquery
lists some frequency calculation of words, ordered.
我想做的是将结果限制为 10.我尝试使用位置值,但因为它给了我单词在单词列表中的位置,所以没有成功..
What I want to do is limit the results by 10.I tried to use positional values but as it gives me the position of the word in the word list, it didnt work out..
有什么帮助吗?
推荐答案
使用 subsequence($sequence, $start, $records)
返回结果子集,从记录 $ 开始start
(注意 XQuery 从 1 开始计数)返回 records
项.查看限制结果集"XQuery Wikibooks 页面.如何应用从该页面复制的函数的示例:
Use subsequence($sequence, $start, $records)
to return a subset of results, starting at record $start
(be aware XQuery counts from 1) returning records
items. Have a look at "Limiting Result Sets" XQuery Wikibooks Page. An example of how to apply the function copied from this page:
let $sorted-people :=
for $person in collection($collection)/person
order by $person/last-name/text()
return $person
for $person at $count in subsequence($sorted-people, $start, $records)
return
<li>{ $person/last-name/text() }</li>
这篇关于限制 xquery 中的结果数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!