From 0a53edaa7ca64b9e10a16c6d4aa74bc5fc42a4c9 Mon Sep 17 00:00:00 2001 From: Carsten Milling Date: Fri, 20 Dec 2024 21:36:21 +0100 Subject: [PATCH] Add role to characters in play information and to the characters endpoint Discovered from #274 that this is missing --- api.yaml | 4 ++++ modules/util.xqm | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/api.yaml b/api.yaml index 82b2a09..231b740 100644 --- a/api.yaml +++ b/api.yaml @@ -1958,6 +1958,8 @@ components: - MALE - FEMALE - UNKNOWN + role: + type: string wikidataId: # ontology: #character_wikidata_id type: string @@ -2226,6 +2228,8 @@ components: - FEMALE - UNKNOWN nullable: true + role: + type: string betweenness: # ontology: #character_node_betweenness type: number diff --git a/modules/util.xqm b/modules/util.xqm index 2508206..c2b4c4d 100644 --- a/modules/util.xqm +++ b/modules/util.xqm @@ -1020,6 +1020,7 @@ declare function dutil:get-play-info( ) let $name := $node/(tei:persName | tei:name)[1]/text() let $sex := $node/@sex/string() + let $role := $node/@role/string() let $isGroup := if ($node/name() eq 'personGrp') then true() else false() let $wikidata-id := dutil:get-wikidata-id-from-ana($node) @@ -1030,6 +1031,7 @@ declare function dutil:get-play-info( "isGroup": $isGroup, "sex": if($sex) then $sex else () }, + if ($role) then map:entry("role", $role) else (), if ($wikidata-id) then map:entry("wikidataId", $wikidata-id) else () )) }, @@ -1151,6 +1153,7 @@ declare function dutil:characters-info ( ) let $name := $node/(tei:persName | tei:name)[1]/text() let $sex := $node/@sex/string() + let $role := $node/@role/string() let $isGroup := if ($node/name() eq 'personGrp') then true() else false() let $num-of-speech := $tei//tei:sp[@who='#'||$id] @@ -1174,6 +1177,7 @@ declare function dutil:characters-info ( "betweenness": $metrics-node/betweenness/number(.), "eigenvector": $eigenvector }, + if ($role) then map:entry("role", $role) else (), if ($wikidata-id) then map:entry("wikidataId", $wikidata-id) else () )) }