25.12.2013 Views

Tamino XQuery User Guide - Software AG Documentation

Tamino XQuery User Guide - Software AG Documentation

Tamino XQuery User Guide - Software AG Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Text Retrieval<br />

The function tf:containsAdjacentText returns true if the tokens "one" and "more" are found in<br />

that order within a distance of less than nine tokens. Since there are eight unmatched tokens, the<br />

function returns true for the above query. Let us slightly change the query expression:<br />

let $text := text{"One, Two, Three, Four, Can I have a little more?"}<br />

return tf:containsAdjacentText($text, 9, "one", "four", "more")<br />

The function returns true if all the tokens "one", "four" and "more" are found in that order within<br />

a distance of less than nine tokens, not including any matched tokens in between such as "four".<br />

Since there are seven unmatched tokens, the function returns true for the above query.<br />

Generally, if you use a distance value of "1", it means that the tokens follow immediately one after<br />

another. It follows that tf:containsAdjacentText($mynode, 1, "search", "text") is equivalent<br />

to tf:containsText($mynode, "search text").<br />

While tf:containsAdjacentText respects the word order, the function tf:containsNearText<br />

does not. The following query using tf:containsNearText returns true, using<br />

tf:containsAdjacentText it would return false:<br />

let $text := text{"One, Two, Three, Four, Can I have a little more?"}<br />

return tf:containsNearText($text, 2, "four", "one", "two")<br />

Highlighting Retrieval Results<br />

When retrieving information from some text corpus, it is desirable to visualize the information<br />

found. In <strong>Tamino</strong> <strong>XQuery</strong>, you can do so by “highlighting” retrieval results. Consider the following<br />

query from the <strong>Tamino</strong> <strong>XQuery</strong> reference guide which searches in all review nodes for the word<br />

"discussion":<br />

88<br />

<strong>XQuery</strong> <strong>User</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!