Commit 3a0a3e37 authored by mrodzis's avatar mrodzis 💪
Browse files

refactor: fix bug, change function interface

parent eafd865a
Pipeline #212352 failed with stages
in 2 minutes and 56 seconds
......@@ -40,10 +40,11 @@ import module namespace functx = "http://www.functx.com";
declare variable $vars:ns := "http://ahikar.sub.uni-goettingen.de/ns/annotations";
declare function vars:get-variants($teixml-uri as xs:string,
$pages as element(tei:TEI)+)
$pages as element(tei:TEI)+,
$pb-n as xs:string)
as map(*)* {
for $page in $pages return
let $variants := vars:get-variants-on-page-as-maps($teixml-uri, $page)
let $variants := vars:get-variants-on-page-as-maps($teixml-uri, $page, $pb-n)
for $map in $variants
let $id := map:get($map, "current") => map:get("id")
......@@ -66,14 +67,15 @@ as map(*)* {
: @return A map with information about the current token and its variants
:)
declare function vars:get-variants-on-page-as-maps($teixml-uri as xs:string,
$page as element(tei:TEI))
$page as element(tei:TEI),
$pb-n as xs:string)
as map()* {
let $ms-id := vars:get-ms-id-from-idno($teixml-uri)
let $relevant-files-for-ms-id := vars:get-relevant-files($ms-id)
(: the MS identifier position is the same in all relevant files, so we simply
choose the first for looking it up :)
let $ms-id-position := vars:determine-id-position($ms-id, $relevant-files-for-ms-id[1])
let $tokens := vars:get-token-ids-on-page($teixml-uri, $page)
let $tokens := vars:get-token-ids-on-page($teixml-uri, $pb-n)
let $files-relevant-for-page := vars:get-files-relevant-for-page($relevant-files-for-ms-id, $ms-id-position, $tokens)
for $file in $files-relevant-for-page return
......@@ -125,7 +127,7 @@ declare function vars:determine-id-position($ms-id as xs:string,
as xs:integer {
let $witnesses := map:get($json, "witnesses")
return
index-of($witnesses?*, $ms-id)
index-of($witnesses?*, "t_" || $ms-id)
};
(:~
......@@ -136,9 +138,11 @@ as xs:integer {
: @param $page The current page as provided in tei:pb/@n
:)
declare function vars:get-token-ids-on-page($teixml-uri as xs:string,
$page as element(tei:TEI))
$page as xs:string)
as xs:string+ {
$page//tei:w/@xml:id
let $page-chunks := commons:get-transcription-and-transliteration-per-page($teixml-uri, $page)
return
$page-chunks//tei:w/@xml:id
};
declare function vars:get-files-relevant-for-page($relevant-files-for-ms-id as map()+,
......
......@@ -55,7 +55,7 @@ as item()* {
return
(edit:get-annotations($pages, $teixml-uri),
motifs:get-motifs($pages, $teixml-uri),
vars:get-variants($teixml-uri, $page))
vars:get-variants($teixml-uri, $pages, $page))
};
declare function san:make-items-for-TEI($teixml-uri as xs:string,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment