2012-08-06 44 views
1

我需要爲加載到MarkLogic的一組文檔中的每個文檔生成一個關鍵字列表。我正在考慮對文檔集運行cts:distinct-terms,但無法弄清楚如何獲取每個文檔的關鍵字列表,而不是與該集合相關的術語列表。任何人都可以提出解決方案不同-條款分別每份文件:如何爲存儲在MarkLogic中的文檔生成關鍵字?

回答

3

您是否使用score=logtf選項?當我嘗試這些時,停用詞的分數增加了很多。如果你仔細想想,這是有道理的:數據庫不能再使用IDF來清除它們。如果您只想要TF,但您可以使用停用詞列表進行過濾 - 如已經建議的那樣。

logtfidf得分自然應該懲罰停用詞。您可以設置min-val選項或其他選項來調整結果。例如,在這裏我將min-val設置爲27,因爲stop-words開始出現在26.由於IDF,正確的選項將取決於現有的數據庫內容。

cts:distinctive-terms(
    text { 'I need to generate a list of keywords for each document in a set of documents that are loaded into MarkLogic. I am considering running cts:distinctive-terms against the set of documents, but cannot figure out how to get a list of keywords for each document rather than a list of terms relevant to the set. Can anyone suggest a solution?' }, 
    <options xmlns="cts:distinctive-terms" 
    xmlns:db="http://marklogic.com/xdmp/database"> 
    <min-val>27</min-val> 
    <use-db-config>false</use-db-config> 
    <db:stemmed-searches>true</db:stemmed-searches> 
    <db:word-searches>false</db:word-searches> 
    <db:fast-phrase-searches>false</db:fast-phrase-searches> 
    </options>)/cts:term/cts:word-query/cts:text/string() 
=> 
load 
set 
solution 
term 
document 
list 
keyword 
+0

謝謝!我沒有通過選項節點。即使我刪除min-val選項,此工作也很好。它爲每個文檔返回0到10個術語。什麼影響返回的條款數量?我主要關心返回0的情況。 – 2012-08-07 15:34:36

+0

'max-terms' - 來自http://docs.marklogic.com/5.0doc/docapp.xqy#display.xqy?fname=http://pubs/5.0doc/apidoc/SearchBuiltins.xml&category=SearchBuiltins&function=cts:獨特的術語 - 但如果你看到0,那麼有些奇怪。你可以用一個獨立的文本節點來重現它,就像我上面所用的一樣嗎? – mblakele 2012-08-08 01:21:45

3

在關注和呼叫CTS的文檔簡單地重複

for $doc in doc() 
return 
    cts:distinctive-terms($doc) 

HTH!

+0

這就是我第一次嘗試,但最終得到「the」,「is」和其他同樣無趣的話作爲大多數條件返回。有人建議我應該針對整套文件運行cts:獨特的術語。這返回了一組更好的條款,但我無法弄清楚從哪裏去。 – 2012-08-07 02:27:52

+1

@ joe-glorioso這實際上是一個稍微不同的問題。針對大量文檔(如果不是簡單的話)運行獨特的術語,將這些術語的頂部術語作爲停用詞列表處理。從較小的集合或單個文檔中過濾它們。我最近自己做了一些類似的技巧.. – grtjn 2012-08-07 05:34:47

+0

感謝您的幫助! – 2012-08-07 15:10:46