A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/RDFLib/rdflib/issues/428 below:

Trig serialisation handling prefixes incorrectly · Issue #428 · RDFLib/rdflib · GitHub

In version 4.1.2 (under python 2.7), running the Trig test detailed at #317 produces invalid Trig output.

Running the code:

from rdflib import ConjunctiveGraph

data = """
@prefix ns1: <http://chartex.org/chartex-schema#> .
<http://chartex.org/graphid/document1> = {
    ns1:Person_A a ns1:Person ;
        ns1:TextSpan "Simon" .
    ns1:Person_B a ns1:Person ;
        ns1:TextSpan "Walter" .
}
<http://chartex.org/graphid/document2> = {
    ns1:Person_C a ns1:Person ;
        ns1:TextSpan "Agnes" .
    ns1:Person_D a ns1:Person ;
        ns1:TextSpan "Emma" .
}
<http://chartex.org/graphid/Person_Atenant_ofPerson_B> = {
    ns1:Person_A ns1:tenant_of ns1:Person_B .
}
<http://chartex.org/graphid/Person_Ctenant_ofPerson_D> = {
    ns1:Person_C ns1:tenant_of ns1:Person_D .
}
<http://chartex.org/graphid/ConfidenceMetrics> = {
    <http://chartex.org/graphid/Person_Atenant_ofPerson_B> ns1:confidence 0.9265 .
    <http://chartex.org/graphid/Person_Ctenant_ofPerson_D> ns1:confidence 0.8765 .
}
"""

cg = ConjunctiveGraph()
cg.parse(data=data, format='trig')
print cg.serialize(format='trig')

produces the invalid Trig output:

@prefix ns1: <http://chartex.org/chartex-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<ns2:Person_Atenant_ofPerson_B> = {
    ns1:Person_A ns1:tenant_of ns1:Person_B .
}

<ns2:ConfidenceMetrics> = {
    ns2:Person_Atenant_ofPerson_B ns1:confidence 0.9265 .

    ns2:Person_Ctenant_ofPerson_D ns1:confidence 0.8765 .
}

<ns2:Person_Ctenant_ofPerson_D> = {
    ns1:Person_C ns1:tenant_of ns1:Person_D .
}

<ns2:document2> = {
    ns1:Person_C a ns1:Person ;
        ns1:TextSpan "Agnes" .

    ns1:Person_D a ns1:Person ;
        ns1:TextSpan "Emma" .
}

<ns2:document1> = {
    ns1:Person_A a ns1:Person ;
        ns1:TextSpan "Simon" .

    ns1:Person_B a ns1:Person ;
        ns1:TextSpan "Walter" .
}

The Trig output contains the prefix "ns2" for graphs, but this prefix isn't defined anywhere. In addition, the prefixed graph name shouldn't be enclosed within angle brackets, e.g. the correct output for each named graph should be either:

@prefix ns2: <http://chartex.org/graphid/> .

ns2:document1 = {
    ...
}

Or:

<http://chartex.org/graphid/document1> = {
    ...
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4