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.
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 }
}
};