forked from abaevdict/abaev-basex
added glosses to entry API
This commit is contained in:
parent
d8d24c1dc9
commit
24acee8378
1 changed files with 19 additions and 4 deletions
|
@ -22,8 +22,22 @@ declare function api:ment-index($db-lang as xs:string) {
|
||||||
(: Short entry info (only forms for now). Hash is used because URLs don't handle
|
(: Short entry info (only forms for now). Hash is used because URLs don't handle
|
||||||
some Unicode characters very well in this system :)
|
some Unicode characters very well in this system :)
|
||||||
declare function api:entry-info-short($n as node())
|
declare function api:entry-info-short($n as node())
|
||||||
as map(xs:string, xs:string) {
|
as map(xs:string, item()) {
|
||||||
map{'id': string(hash($n/@xml:id)), 'xmlid': $n/@xml:id, 'form': $n/text()}
|
map{'id': string(hash($n/@xml:id)),
|
||||||
|
'xmlid': string($n/@xml:id),
|
||||||
|
'form': $n/text()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
declare function api:entry-info-long($n as node(), $db-lang as xs:string)
|
||||||
|
as map(xs:string, item()) {
|
||||||
|
map:merge(
|
||||||
|
(
|
||||||
|
api:entry-info-short($n),
|
||||||
|
map{'glosses': array:build(data(doc(`abaevdict_{$db-lang}/xml/{$n/@xml:id}.xml`)
|
||||||
|
/tei:entry[1]/tei:sense/(tei:sense|tei:sense/tei:sense|.)/tei:cit/tei:quote))}
|
||||||
|
)
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
(: Short language info -- for the language list :)
|
(: Short language info -- for the language list :)
|
||||||
|
@ -168,8 +182,9 @@ declare %rest:path("{$db-lang}/api/entries/{$entry-id}")
|
||||||
%rest:GET
|
%rest:GET
|
||||||
function api:entries($db-lang as xs:string,
|
function api:entries($db-lang as xs:string,
|
||||||
$entry-id as xs:string) {
|
$entry-id as xs:string) {
|
||||||
api:entry-info-short(
|
api:entry-info-long(
|
||||||
$lookup/tei:table[1]/tei:entry[string(hash(@xml:id))=$entry-id])
|
$lookup/tei:table[1]/tei:entry[string(hash(@xml:id))=$entry-id],
|
||||||
|
$db-lang)
|
||||||
};
|
};
|
||||||
|
|
||||||
0
|
0
|
Loading…
Add table
Reference in a new issue