====== Croatica et Tyrolensia: XQuery scripts ====== [[https://commons.wikimedia.org/wiki/File%3ACostumes_de_Differents_Pays%2C_'Femme_Morlaque_du_Canton_de_Segna'_LACMA_M.83.190.48.jpg |{{ http://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/Costumes_de_Differents_Pays%2C_%27Femme_Morlaque_du_Canton_de_Segna%27_LACMA_M.83.190.48.jpg/256px-Costumes_de_Differents_Pays%2C_%27Femme_Morlaque_du_Canton_de_Segna%27_LACMA_M.83.190.48.jpg}}]] ===== Adding a function to parse wordforms externally ===== What we need: - a working [[http://basex.org/|BaseX]] installation; see [[z:croat-tyrol-basex-deploy|The easiest way to deploy BaseX]] - permissions and ways to edit a ''.xqm'' XQuery module file (such as the ''restxq.xqm'' supplied with BaseX) - address of a parsing service (e. g. [[http://services.perseids.org/bsp/morphologyservice/analysis/word?word=homines&lang=lat&engine=morpheuslat]] -- check this out to see the kinds of results that will be provided) First we edit the ''form'' part, where users submit sentences (or words) to be parsed:

Parse words from Latin sentence

Enter a Latin sentence which you want to parse. The result will be an XML file with lots of grammatical information for each word.

Sententia:

Then we prepare the function (e. g. by adding this to the end of the ''restxq.xqm'' module file). //Caveat//: the service address here is not real, it is a placeholder! (:~ : A comment, to help us know what we're doing: : this function retrieves lexical information : from an external service : for words in a form request. : @param $message message to be included in the response : @return response element :) declare %rest:path("/homon") %rest:POST %rest:form-param("query","{$query}", "(no query)") function page:homon-postman( $message as xs:string) { let $url := ("http://some.parsing.service.org/somemorphologyservice/someword?word=SOMEWORD&lang=latamp;engine=morpheuslat") (: convert string into sequence :) let $rijeci := tokenize($query, "\W+") (: for each item in sequence :) return element w { for $r in $rijeci let $parsed := (doc(replace($url,'SOMEWORD',$r))) return element ana { $parsed } } };