Skip to content

Commit

Permalink
add biography texts for BNet person entities
Browse files Browse the repository at this point in the history
  • Loading branch information
yoge1 committed Oct 18, 2023
1 parent 8d326c6 commit fa72dd7
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions intavia_backend/main_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ async def bulk_retrieve_biography_objects(
r1 = requests.get(r["bioText"])
if r1.status_code == 200:
r_fin["text"] = r1.json()["text"]
elif "biotext" in r:
r_fin["text"] = r["biotext"]
if "bioAbstract" in res[0]:
r2 = requests.get(r["bioAbstract"])
if r2.status_code == 200:
Expand Down Expand Up @@ -296,13 +298,16 @@ async def retrieve_biography(biography_id: str, query: Base = Depends()):
query_dict["bioID"] = biography_id_decoded
res = get_query_from_triplestore_v2(query_dict, "get_biography_v2_1.sparql")
# res = FakeList(**{"results": flatten_rdf_data(res)})

if len(res) == 0:
raise HTTPException(status_code=404, detail="Item not found")
fin = {"id": biography_id}
if "bioText" in res[0]:
r1 = requests.get(res[0]["bioText"]["value"])
if r1.status_code == 200:
fin["text"] = r1.json()["text"]
elif "biotext" in res[0]:
fin["text"] = res[0]["biotext"]["value"]
if "bioAbstract" in res[0]:
r2 = requests.get(res[0]["bioAbstract"]["value"])
if r2.status_code == 200:
Expand Down
12 changes: 9 additions & 3 deletions intavia_backend/sparql/get_biography_v2_1.sparql
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
PREFIX idmcore: <http://www.intavia.eu/idm-core/>
PREFIX bgn: <http://data.biographynet.nl/rdf/>

SELECT ?bioText ?bioAbstract ?bioID
SELECT ?bioText ?bioAbstract ?biotext ?bioID

{% include 'add_datasets_v2_1.sparql' %}

WHERE {
BIND(<{{bioID}}> AS ?bioID)
?bioID idmcore:full_bio_link ?bioText .
OPTIONAL {?bioID idmcore:short_bio_link ?bioAbstract .}

{ ?bioID idmcore:full_bio_link ?bioText .
OPTIONAL {?bioID idmcore:short_bio_link ?bioAbstract . } }
UNION
{ ?bioID bgn:hasBioParts ?bioparts .
?bioparts bgn:text ?biotext .
FILTER NOT EXISTS { ?bioparts bgn:hasFigure ?fig . } }
}
2 changes: 2 additions & 0 deletions intavia_backend/sparql/get_entity_v2_1.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PREFIX idm: <https://www.intavia.eu/idm/>
PREFIX idmcore: <http://www.intavia.eu/idm-core/>
PREFIX bioc: <http://ldf.fi/schema/bioc/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
PREFIX bgn: <http://data.biographynet.nl/rdf/>

SELECT ?entity ?entityType ?entityTypeLabel ?entityLabel ?gender ?genderLabel ?nationalityLabel ?occupation ?occupationLabel
?event ?eventLabel ?role ?roleLabel ?start ?end ?role_type
Expand Down
1 change: 1 addition & 0 deletions intavia_backend/sparql/retrieve_entities_v2_1.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ OPTIONAL {?entity_proxy bioc:bearer_of ?role .
OPTIONAL {?entity_proxy crm:P168_place_is_defined_by/crm:P168_place_is_defined_by ?geometry}
OPTIONAL {?entity_proxy ^crm:P70_documents ?mediaObject }
OPTIONAL {?entity_proxy idmcore:bio_link ?biographyObject }
OPTIONAL {?entity_proxy ore:proxyIn ?biographyObject . ?biographyObject bgn:hasBioParts ?bioparts . ?bioparts bgn:text ?biotext . FILTER NOT EXISTS { ?bioparts bgn:hasFigure ?fig. } }
BIND(COALESCE(?entityLabelPre, ?defaultEntityLabel) AS ?entityLabel)
2 changes: 2 additions & 0 deletions intavia_backend/sparql/search_v2_1.sparql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PREFIX idm: <https://www.intavia.eu/idm/>
PREFIX idmcore: <http://www.intavia.eu/idm-core/>
PREFIX bioc: <http://ldf.fi/schema/bioc/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
PREFIX bgn: <http://data.biographynet.nl/rdf/>

SELECT ?entity ?entityType ?entityTypeLabel ?entityLabel ?gender ?genderLabel ?nationalityLabel ?occupation ?occupationLabel
?event ?linkedIds ?count ?geometry ?role_type (?entity as ?source) ?mediaObject ?biographyObject
Expand Down

0 comments on commit fa72dd7

Please sign in to comment.