kgtk icon indicating copy to clipboard operation
kgtk copied to clipboard

help needed for querying a KG other than wikidata

Open valecarriero opened this issue 1 year ago • 0 comments

Hi, I successfully reused your tool for Wikidata (see wikidata empirical patterns project)

Now, I am trying to change the code such that it can be run on KGs other that Wikidata. I am testing this with an ArCo KG release (see the NTriples dump) I generated two kgtk files, with and without namespaces, with the following commands:

  1. kgtk --debug --timing import-ntriples --verbose -i arco.nt -o OUTPUT_FILE --reject-file REJECT_FILE --namespace-file NAMESPACE_FILE --updated-namespace-file NAMESPACE_FILE --build-id True --build-datatype-column True (see below for a snapshot)
  2. kgtk --debug --timing import-ntriples --verbose -i arco.nt -o OUTPUT_FILE --reject-file REJECT_FILE --build-id True --build-datatype-column True —build-new-namespaces=False (see below for a snapshot)

I tried in multiple ways, but I'm not able to do basic queries, like:

  • kgtk --debug query -i arco_output.tsv.gz --match '()-[n4:label]->()' --limit 10 does not return anything on the first kgtk file
  • kgtk --debug query -i arco_output.tsv.gz --match '()-[:label]->()' --limit 10 does not return anything on the first kgtk file
  • kgtk --debug query -i arco_output_nonamespaces.tsv.gz --match '()-[p]->()' --where 'p IN ["http://www.w3.org/2000/01/rdf-schema#label"]' --limit 10 does not return anything

But I really tried in many more different ways...

I am using an old version of KGTK (1.4.2) and python 3.9.13

What am I missing? :) Thanks a lot for your support

1

node1   label   node2   datatype        id
n1:1200583495-heritage-protection-agency        n2:type n3:AgentRole            E1
n1:1200583495-heritage-protection-agency        n4:label        'Ente competente per tutela del bene 1200583495: S47'@it        n2:langString   E2
n1:1200583495-heritage-protection-agency        n4:label        'Heritage protection agency for cultural property 1200583495: S47'@en   n2:langString E3
n1:1200583495-heritage-protection-agency        n3:hasRole      n5:HeritageProtectionAgency             E4
n1:1200583495-heritage-protection-agency        n3:hasAgent     n6:d14d2c40c7af7b33e2d60f0fe31ad52f             E5
n7:terme-convento-nazionale     n2:type n8:SiteType             E6
n7:terme-convento-nazionale     n4:label        'Tipo di contenitore fisico: TERME; CONVENTO NAZIONALE'@it      n2:langString   E7
n7:terme-convento-nazionale     n9:name 'Tipo di contenitore fisico: TERME; CONVENTO NAZIONALE'@it      n2:langString   E8
n7:terme-convento-nazionale     n4:label        'Site type: TERME; CONVENTO NAZIONALE'@en       n2:langString   E9
n7:terme-convento-nazionale     n9:name 'Site type: TERME; CONVENTO NAZIONALE'@en       n2:langString   E10
[...]
n1      prefix_expansion        "https://w3id.org/arco/resource/AgentRole/"             E66993485
n10     prefix_expansion        "https://w3id.org/arco/resource/SiteDefinition/"                E66993486
n100    prefix_expansion        "https://w3id.org/arco/resource/Reuse/"         E66993487
n101    prefix_expansion        "https://w3id.org/arco/resource/CulturalPropertyPart/"          E66993488
n102    prefix_expansion        "https://w3id.org/arco/resource/LocationType/"          E66993489

2

node1   label   node2   datatype        id
https://w3id.org/arco/resource/AgentRole/1200583495-heritage-protection-agency  http://www.w3.org/1999/02/22-rdf-syntax-ns#type https://w3id.org/arco/ontology/core/AgentRole             E1
https://w3id.org/arco/resource/AgentRole/1200583495-heritage-protection-agency  http://www.w3.org/2000/01/rdf-schema#label      'Ente competente per tutela del bene 1200583495: S47'@it  http://www.w3.org/1999/02/22-rdf-syntax-ns#langString   E2
https://w3id.org/arco/resource/AgentRole/1200583495-heritage-protection-agency  http://www.w3.org/2000/01/rdf-schema#label      'Heritage protection agency for cultural property 1200583495: S47'@en     http://www.w3.org/1999/02/22-rdf-syntax-ns#langString   E3
https://w3id.org/arco/resource/AgentRole/1200583495-heritage-protection-agency  https://w3id.org/arco/ontology/core/hasRole     https://w3id.org/arco/resource/Role/HeritageProtectionAgency              E4
https://w3id.org/arco/resource/AgentRole/1200583495-heritage-protection-agency  https://w3id.org/arco/ontology/core/hasAgent    https://w3id.org/arco/resource/Agent/d14d2c40c7af7b33e2d60f0fe31ad52f             E5
https://w3id.org/arco/resource/SiteType/terme-convento-nazionale        http://www.w3.org/1999/02/22-rdf-syntax-ns#type https://w3id.org/arco/ontology/location/SiteType          E6
https://w3id.org/arco/resource/SiteType/terme-convento-nazionale        http://www.w3.org/2000/01/rdf-schema#label      'Tipo di contenitore fisico: TERME; CONVENTO NAZIONALE'@it        http://www.w3.org/1999/02/22-rdf-syntax-ns#langString   E7
https://w3id.org/arco/resource/SiteType/terme-convento-nazionale        https://w3id.org/italia/onto/l0/name    'Tipo di contenitore fisico: TERME; CONVENTO NAZIONALE'@it        http://www.w3.org/1999/02/22-rdf-syntax-ns#langString   E8
https://w3id.org/arco/resource/SiteType/terme-convento-nazionale        http://www.w3.org/2000/01/rdf-schema#label      'Site type: TERME; CONVENTO NAZIONALE'@en http://www.w3.org/1999/02/22-rdf-syntax-ns#langString   E9
https://w3id.org/arco/resource/SiteType/terme-convento-nazionale        https://w3id.org/italia/onto/l0/name    'Site type: TERME; CONVENTO NAZIONALE'@enhttp://www.w3.org/1999/02/22-rdf-syntax-ns#langString    E10

valecarriero avatar Aug 01 '23 09:08 valecarriero