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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Text Retrieval<br />

for $a in input()/patient<br />

where tf:containsText($a/occupation, "diver")<br />

return { $a/name }<br />

Now <strong>Tamino</strong> returns Mr. Atkins in the diver list, since the tokenizer identifies "Diver" as a word,<br />

delimited on the left by a space character. After applying lower case as standard tokenizer rule<br />

the token "diver" is found and the function tf:containsText returns true. Please note that this<br />

function looks for word tokens, so using tf:containsText($a/occupation, "dive") would yield<br />

false, since "dive" is not a token that can be found in any of the occupation nodes. Similarly, a<br />

query using tf:containsText($a/occupation, "professional diver") returns true, since the<br />

two word tokens are found in that order in the occupation node. However,<br />

tf:containsText($a/occupation, "diver professional") returns false: Although both tokens<br />

are found, they are not in the specified order.<br />

Context Operations<br />

With context operations you can search for expressions that consist of one or more words which<br />

do not necessarily follow after one another. For example, you can search for variants of the expression<br />

"text retrieval" such as "retrieval of text" or in "text storage and retrieval". In <strong>Tamino</strong>, there<br />

are functions that let you specify the following context operations (here, "#" stands for one token):<br />

■ Maximum word distance<br />

"text # # retrieval" matches "text retrieval" and "text storage and retrieval"<br />

■ Word order<br />

If word order is not significant, "text retrieval" matches "text retrieval" and "retrieval of text"<br />

The functions tf:containsAdjacentText and tf:containsNearText both expect a maximum<br />

word distance as second argument. Consider the following query:<br />

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

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

This graphics shows you the search string, its tokens and how the query matches the search string:<br />

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

87

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

Saved successfully!

Ooh no, something went wrong!