-
-
Save AdamSteffanick/7348a0c890b2f13bc458 to your computer and use it in GitHub Desktop.
XQuery Working Group Challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xquery version "3.1"; | |
(: FUNCTION: Whether all the values in a sequence are distinct http://www.xqueryfunctions.com/xq/functx_are-distinct-values.html :) | |
declare namespace functx = "http://www.functx.com"; | |
declare function functx:are-distinct-values | |
($seq as xs:anyAtomicType* ) as xs:boolean { | |
count(distinct-values($seq)) = count($seq)}; | |
(: Converts sentences into verses and returns verses containing duplicate lemmata :) | |
(: Official release of the PROIEL treebank of ancient Indo-European languages :) | |
let $uri := "https://raw.githubusercontent.com/proiel/proiel-treebank/master/latin-nt.xml" | |
let $doc := fn:doc($uri) | |
for $citation in fn:distinct-values(fn:data($doc//token/@citation-part)) | |
let $tokens := $doc//token[./@citation-part = $citation] | |
where fn:not(functx:are-distinct-values($tokens/@lemma)) | |
return element verse { | |
attribute citation {$citation}, | |
fn:data($tokens[./@citation-part = $citation]/@form)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment