Get level of excerpts in document

This commit is contained in:
Georgy Litvinov 2021-03-03 17:25:29 +01:00
parent 0e1614a31a
commit 4ee8db0022
2 changed files with 16 additions and 17 deletions

View file

@ -42,11 +42,11 @@ display:getCompilationExcerptPathsDataGetter
display:saveToVar "paths"; display:saveToVar "paths";
display:query display:query
""" """
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ts_: <https://litvinovg.pro/text_structures#> PREFIX ts_: <https://litvinovg.pro/text_structures#>
SELECT (GROUP_CONCAT(substr(concat("000",str(?outline)),strlen(str(?outline))); SEPARATOR = ".") AS ?path ) ?tocElement ?elenphExcerpt SELECT (GROUP_CONCAT(substr(concat("000",str(?outline)),strlen(str(?outline))); SEPARATOR = ".") AS ?path ) (COUNT(?outline) AS ?level) ?tocElement ?elenphExcerpt
WHERE { WHERE {
?individualURI ts_:hasTOC ?toc . ?individualURI ts_:hasTOC ?toc .
?toc ts_:hasTOCItem/(ts_:pointsTo/ts_:hasTOCItem)* ?tmpTOCItem . ?toc ts_:hasTOCItem/(ts_:pointsTo/ts_:hasTOCItem)* ?tmpTOCItem .
?tmpTOCItem rdf:type ts_:TOCItem . ?tmpTOCItem rdf:type ts_:TOCItem .
@ -56,10 +56,10 @@ display:getCompilationExcerptPathsDataGetter
?tocElement ts_:hasText ?elenphExcerpt . ?tocElement ts_:hasText ?elenphExcerpt .
} }
{ {
SELECT ?tocElement SELECT ?tocElement
WHERE { WHERE {
?individualURI ts_:hasTOC ?toc . ?individualURI ts_:hasTOC ?toc .
?toc (ts_:hasTOCItem/ts_:pointsTo)+ ?tocElement . ?toc (ts_:hasTOCItem/ts_:pointsTo)+ ?tocElement .
?tocElement rdf:type ts_:TOCLevel . ?tocElement rdf:type ts_:TOCLevel .
} }
} }

View file

@ -42,11 +42,11 @@ display:getArticleExcerptPathsDataGetter
display:saveToVar "paths"; display:saveToVar "paths";
display:query display:query
""" """
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ts_: <https://litvinovg.pro/text_structures#> PREFIX ts_: <https://litvinovg.pro/text_structures#>
SELECT (GROUP_CONCAT(substr(concat("000",str(?outline)),strlen(str(?outline))); SEPARATOR = ".") AS ?path ) ?tocElement ?elenphExcerpt SELECT (GROUP_CONCAT(substr(concat("000",str(?outline)),strlen(str(?outline))); SEPARATOR = ".") AS ?path ) (COUNT(?outline) AS ?level) ?tocElement ?elenphExcerpt
WHERE { WHERE {
?individualURI ts_:hasTOC ?toc . ?individualURI ts_:hasTOC ?toc .
?toc ts_:hasTOCItem/(ts_:pointsTo/ts_:hasTOCItem)* ?tmpTOCItem . ?toc ts_:hasTOCItem/(ts_:pointsTo/ts_:hasTOCItem)* ?tmpTOCItem .
?tmpTOCItem rdf:type ts_:TOCItem . ?tmpTOCItem rdf:type ts_:TOCItem .
@ -56,12 +56,11 @@ display:getArticleExcerptPathsDataGetter
?tocElement ts_:hasText ?elenphExcerpt . ?tocElement ts_:hasText ?elenphExcerpt .
} }
{ {
SELECT ?elenphArticle ?tocElement SELECT ?elenphArticle ?tocElement
WHERE { WHERE {
?individualURI ts_:hasTOC ?toc . ?individualURI ts_:hasTOC ?toc .
?toc (ts_:hasTOCItem/ts_:pointsTo)+ ?tocElement . ?toc (ts_:hasTOCItem/ts_:pointsTo)+ ?tocElement .
?tocElement rdf:type ts_:TOCLevel . ?tocElement rdf:type ts_:TOCLevel .
?individualURI rdf:type ts_:elenphArticle .
} }
} }
} GROUP BY ?tocElement ?elenphExcerpt ORDER BY ?path } GROUP BY ?tocElement ?elenphExcerpt ORDER BY ?path