SPARQL-Anything / PySPARQL-Anything

The SPARQL Anything Python library
Apache License 2.0
13 stars 2 forks source link

Is `--configuration` option available for python users? #24

Open luigi-asprino opened 1 month ago

luigi-asprino commented 1 month ago

I get an error with this piece of code

engine.run(
        query=query_string,
        configuration={
         "location" : file_input
      }
    )

Is configuration available as an argument to query via no-service mode? See https://github.com/SPARQL-Anything/sparql.anything/issues/150

MarcoR1791 commented 1 month ago

Hi Luigi,

Thank you for pointing this out. It is a bug indeed.

I have however fixed it and will try to release a fixed version asap.

The below code, for example (both c and configuration can be used)

facade_query = """
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>

CONSTRUCT { ?s ?p ?o } WHERE {
  SERVICE <x-sparql-anything:> {
     ?s ?p ?o
  }
}
"""
e = sa.SparqlAnything()
csv_facade = e.construct(
    q=facade_query,
    c={
        'blank-nodes': 'false',
        'location': 'data/artist_data_one.csv',
        'csv.headers': 'true'
    }
)
print(csv_facade.serialize(format="ttl"))

yields

@prefix fx: <http://sparql.xyz/facade-x/ns/>](http://sparql.xyz/facade-x/ns/%3E> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>](http://www.w3.org/1999/02/22-rdf-syntax-ns#%3E> .
@prefix xyz: <http://sparql.xyz/facade-x/data/>](http://sparql.xyz/facade-x/data/%3E> .

<file:///c:/Users/mr24397/Work%20Folders/Desktop/PhD/code/data/artist_data_one.csv#> a fx:root ;
    rdf:_1 <file:///c:/Users/mr24397/Work%20Folders/Desktop/PhD/code/data/artist_data_one.csv##row1> .

<file:///c:/Users/mr24397/Work%20Folders/Desktop/PhD/code/data/artist_data_one.csv##row1> xyz:dates "born 1930" ;
    xyz:gender "Female" ;
    xyz:id "10093" ;
    xyz:name "Abakanowicz, Magdalena" ;
    xyz:placeOfBirth "Polska" ;
    xyz:placeOfDeath "" ;
    xyz:url "http://www.tate.org.uk/art/artists/magdalena-abakanowicz-10093" ;
    xyz:yearOfBirth "1930" ;
    xyz:yearOfDeath "" .