bbcarchdev / acropolis

A toolkit for building knowledge graphs
https://bbcarchdev.github.io/acropolis
8 stars 6 forks source link

media= searches no longer return resources with related media #8

Closed townxelliot closed 6 years ago

townxelliot commented 6 years ago

A few months ago, I wrote some RDF to check that media queries work the way I thought they did. At the time, I could get the correct responses when I ingested that RDF.

I tried the same RDF file today, and the queries with the media= parameter don't return any results.

The file is inline below; the comment at the top shows the test queries I tried and what was expected. These queries used to return as expected, but no longer do.

# TESTS:
# ?q=nurse will return <./people/nurse1#id>, <./places/ward1#id>, <./people/nurse2#id>
# ?q=hospital will return <./places/ward1#id>, <./media/video1>
# ?q=nurse&media=image will return <./people/nurse1#id>, <./places/ward1#id>
# ?q=hospital&media=image will return <./places/ward1#id>
# ?q=nurse&media=video will return <./people/nurse2#id>

@base <http://res.space/esrestesting/> .

@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix dcmitype: <http://purl.org/dc/dcmitype/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .

<./people/nurse1#id>
  a foaf:Person ;
  rdfs:label "Nurse 1"@en .

<./media/image1>
  a dcmitype:StillImage ;
  schema:about <./people/nurse1#id> ;
  dcterms:license <http://creativecommons.org/licenses/by/4.0/> .

<./places/ward1#id>
  a geo:SpatialThing ;
  rdfs:label "Hospital ward where a nurse might work"@en .

<./media/image2>
  a dcmitype:StillImage ;
  foaf:primaryTopic <./places/ward1#id> ;
  dcterms:license <http://creativecommons.org/licenses/by/4.0/> .

<./people/nurse2#id>
  a foaf:Person ;
  foaf:name "Nurse 2"@en ;
  foaf:isPrimaryTopicOf <./media/video1> .

<./media/video1>
  a dcmitype:MovingImage ;
  rdfs:label "Video of the hospital"@en ;
  dcterms:license <http://creativecommons.org/licenses/by/4.0/> .
nevali commented 6 years ago

Hi @townxelliot

could you attach a copies of the import logs (twine -d ...), and the query logs (quilt -d -q 'param=val&param=val' /path) to try to identify which end of the chain the issue lies?

townxelliot commented 6 years ago

This is the output from twine -d: twine_d.log

This is the output from quilt -d -q 'q=nurse&media=image' / (after the RDF is loaded, and which isn't what I'd expect): quilt_media=image.log

This is the output for quilt -d -q 'q=nurse' / (after the RDF is loaded, and which is what I'd expect): quilt.log

townxelliot commented 6 years ago

This was down to me misunderstanding what a media= query should return. My assumption was that you would get resources which have a related media resource with a specific DCMI Type. What you actually get is resources which have a related creative work which in turn have a related media resource of a specific DCMI Type. The revised RDF I used to confirm this was:

@base <http://foo.bar> .

@prefix dcmitype: <http://purl.org/dc/dcmitype/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix mrss: <http://search.yahoo.com/mrss/> .
@prefix po: <http://purl.org/ontology/po/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .

# Nurse 1

</people/nurse1#id>
  a foaf:Person ;
  rdfs:label "Nurse 1"@en .

</photos/nurse1photo#id>
  a schema:Photograph ;
  foaf:primaryTopic <./people/nurse1#id> ;
  mrss:content <./media/nurse1photo.jpg> .

</media/nurse1photo.jpg>
  a dcmitype:StillImage .

# Hospital ward

</places/ward1#id>
  a geo:SpatialThing ;
  rdfs:label "Hospital ward where Nurse 1 and Nurse 2 work"@en .

</photos/ward1photo#id>
  a schema:Photograph ;
  rdfs:label "Photograph of the hospital ward"@en-gb ;
  foaf:primaryTopic <./places/ward1#id> ;
  mrss:content <./media/ward1photo.jpg> .

</media/ward1photo.jpg>
  a dcmitype:StillImage .

# Nurse 2

</people/nurse2#id>
  a foaf:Person ;
  rdfs:label "Nurse 2"@en .

</videos/nurse2film#id>
  a po:Programme ;
  foaf:primaryTopic <./people/nurse2#id> ;
  mrss:content <./media/nurse2film.mp4> .

</media/nurse2film.mp4>
  a dcmitype:MovingImage .

which works as expected, i.e.:

?q=nurse will return <./people/nurse1#id>, <./places/ward1#id>, <./people/nurse2#id> 
-> any resource whose label or description matches the keyword "nurse"

?q=hospital will return <./places/ward1#id>, <./media/ward1photo#id> 
-> any resource whose label or description matches the keyword "hospital"; 
note that this includes a creative work as well as a thing

?q=nurse&media=image will return <./people/nurse1#id>, <./places/ward1#id> 
-> any resource matching the keyword "nurse" which has a related creative work (via foaf:primaryTopic) 
which has a related media resource (via mrss:content) with type dcmitype:StillImage

?q=hospital&media=image will return <./places/ward1#id> 
-> any resource matching the keyword "hospital" which has a related creative work (via foaf:primaryTopic) 
which has a related media resource (via mrss:content) with type dcmitype:StillImage

?q=nurse&media=video will return <./people/nurse2#id> -> 
any resource matching the keyword "nurse" which has a related creative work (via foaf:primaryTopic) 
which has a related media resource (via mrss:content) with type dcmitype:MovingImage

My confusion was (I think) caused by older versions of spindle which generated about relations between a resource and itself, which I think was a work-around for the Shakespeare archive.