This set of functions produces word frequencies for any given sequence of text nodes.
✓ Published0🌍 Public
CCliffordAnderson
Last edited Sep 30, 2014
Created on Sep 30, 2014
This example computes word frequencies from a sequence of text nodes and returns them as an ordered list of word elements. It first shows the frequency-ranked vocabulary by normalizing the input—converting to lowercase, stripping punctuation, and tokenizing—before counting occurrences of each distinct token. The code uses XQuery 3.0 with functions like `fn:tokenize`, `fn:distinct-values`, and `fn:count` to group and sort the results. The final output is an XML `<words>` element containing individual `<word>` elements with a `frequency` attribute, ordered from most to least frequent. The data source is the `//tei:l` elements from a TEI-encoded text.
AI-generated description