From 4ef96c50ab454005de3b94b9b0d576d6eebfa05a Mon Sep 17 00:00:00 2001 From: Oleg Belyaev Date: Sat, 22 Mar 2025 00:08:52 +0300 Subject: [PATCH] now index and display subentries --- static/abaev.js | 47 ++++++++++------------------------------- xq/abv-mod.xqm | 6 ++++++ xq/make-lookup.xq | 20 +++++++++++++++--- xq/restx_dict_cached.xq | 29 +++++++++++++++++++------ 4 files changed, 57 insertions(+), 45 deletions(-) diff --git a/static/abaev.js b/static/abaev.js index ce2d301..636c7d3 100644 --- a/static/abaev.js +++ b/static/abaev.js @@ -131,41 +131,16 @@ $( document ).ready(function() { } }; Plotly.newPlot(map, [$(this).data('map')], layout); - - - - // var data = [{ - // type: 'scattergeo', - // mode: 'markers+text', - // text: [ - // 'Montreal', 'Toronto', 'Vancouver', 'Calgary', 'Edmonton', - // 'Ottawa', 'Halifax', 'Victoria', 'Winnepeg', 'Regina' - // ], - // hovertext: 'HIMEM.SYS
EGAVGA.BGI', - // hoverinfo: 'text', - // lon: [ - // -73.57, -79.24, -123.06, -114.1, -113.28, - // -75.43, -63.57, -123.21, -97.13, -104.6 - // ], - // lat: [ - // 45.5, 43.4, 49.13, 51.1, 53.34, 45.24, - // 44.64, 48.25, 49.89, 50.45 - // ], - // marker: { - // size: 7, - // // color: [ - // // '#bebada', '#fdb462', '#fb8072', '#d9d9d9', '#bc80bd', - // // '#b3de69', '#8dd3c7', '#80b1d3', '#fccde5', '#ffffb3' - // // ], - // line: { - // width: 1 - // } - // }, - // name: 'Canadian cities', - // textposition: [ - // 'top right', 'top left', 'top center', 'bottom right', 'top right', - // 'top left', 'bottom right', 'bottom left', 'top right', 'top right' - // ], - // }]; }); + + // Event handler to show subentries + $('#show-re').on("change", function () { + if($(this).prop('checked')) { + console.log('haha') + $('li.abv-menu-re').removeAttr('hidden'); + } + else { + $('li.abv-menu-re').prop('hidden',true); + } + }); }); diff --git a/xq/abv-mod.xqm b/xq/abv-mod.xqm index 7479c99..21b1f9e 100644 --- a/xq/abv-mod.xqm +++ b/xq/abv-mod.xqm @@ -15,6 +15,7 @@ as xs:string { => replace('\)','') => replace('́','') (: combining acute :) => replace('\*','') + => replace('ᵆ','') => replace('a','/') => replace('A', '/') @@ -44,6 +45,7 @@ as xs:string { => replace('ʒ', '6') => replace('Ʒ', '6') + => replace('ǯ', '6') => replace('e', '7') => replace('E', '7') @@ -67,6 +69,8 @@ as xs:string { => replace('ǧ', 'A') => replace('Ǧ', 'A') + => replace('h', 'A') + => replace('H', 'A') => replace('i', 'B') => replace('I', 'B') @@ -166,6 +170,8 @@ as xs:string { => replace('z', 'X') => replace('Z', 'X') + => replace('ž', 'X') + => replace('Ž', 'X') }; declare function abv-m:sort-collection($docs as document-node()+) { diff --git a/xq/make-lookup.xq b/xq/make-lookup.xq index cd4ff9a..ed08202 100644 --- a/xq/make-lookup.xq +++ b/xq/make-lookup.xq @@ -2,11 +2,13 @@ declare default element namespace "http://www.tei-c.org/ns/1.0"; declare namespace tei = "http://www.tei-c.org/ns/1.0"; declare namespace abv = "http://ossetic-studies.org/ns/abaevdict"; +import module namespace abv-m = 'http://ossetic-studies.org/ns/abaevdict-mod' at './abv-mod.xqm'; + declare function local:genLookupEntry($doc as document-node()) as element()? { let $node := $doc/tei:TEI/tei:text/tei:body/tei:entry - let $phon := $node/tei:form[1]/tei:orth[1]/text()[1] + let $phon := normalize-space(data($node/tei:form[1]/tei:orth[1])) return element entry { attribute xml:id { $node/@xml:id }, @@ -16,9 +18,21 @@ as element()? } }; +let $entries := for $doc in collection('abaevdict') + return local:genLookupEntry($doc) + +let $subentries := for $doc in collection('abaevdict') + for $re in $doc//re + let $etext := normalize-space(data($re/form[1]/orth[1])) + where $etext != '' and not($etext = $entries/text()) + and not(starts-with($etext,',')) + and string-to-codepoints($etext)[1] != string-to-codepoints(' ') + return {$etext} + let $tbl := -{for $doc in collection('abaevdict') - return local:genLookupEntry($doc)} +{for $e in ($entries,$subentries) +order by abv-m:sortKey($e/text()) + return $e}
return db:put('abaevdict_index', $tbl, 'lookup.xml') \ No newline at end of file diff --git a/xq/restx_dict_cached.xq b/xq/restx_dict_cached.xq index c78fc9b..3138d83 100644 --- a/xq/restx_dict_cached.xq +++ b/xq/restx_dict_cached.xq @@ -14,8 +14,12 @@ declare variable $page:items as xs:integer := 20; (: These variables are declared in module scope because they are needed in different places, but they are still dynamically evaluated :) declare variable $page:lookup := doc('abaevdict_index/lookup.xml')/tei:table/tei:entry; +declare variable $page:lookup-all := doc('abaevdict_index/lookup.xml')/tei:table/*; + declare variable $page:total := ceiling(count($page:lookup) div $page:items); -declare variable $page:sorted := abv-m:sort-nodes($page:lookup); +(: This is still called sorted, because I haven't changed the code. +But it's now equal to lookup, because the lookup itself is now sorted. :) +declare variable $page:sorted := $page:lookup; (: =============================================================== :) (: ======================= COMMON STUFF ========================== :) @@ -331,15 +335,28 @@ declare %rest:path("{$lang}/dict") {html:doc('../static/chevron-left.svg')}