Skip to content

saveAsNTriplesFile problem (+fix proposal) #237

Description

@glaisney

Hi, I think I've found a problem with saveAsNTriplesFile : URIs with a very common namespace (like http:// www. w3.org/ 1999/ 02/ 22-rdf-syntax-ns#) are abbreviated, so the written N-Triples files may hold triples such as:
<http://www.my.namespace.org/subject> rdf:type <http://www.my.namespace.org/object> .

This is because in JenaTripleToNTripleString.scala we have :

class JenaTripleToNTripleString
    extends (Triple => String)
    with java.io.Serializable {
  override def apply(t: Triple): String = s"${FmtUtils.stringForTriple(t)} ."
}

so stringForTriple(t) will use commonly known namespaces.

I suggest the following fix, which simply consists in using an empty PrefixMappingImpl object :

private class JenaTripleToNTripleString
    extends (Triple => String)
      with java.io.Serializable {
    override def apply(t: Triple): String = s"${FmtUtils.stringForTriple(t,new PrefixMappingImpl())} ."
  }

Cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions