Coder Social home page Coder Social logo

rdf2go's People

Contributors

afduarte avatar cem-okulmus avatar davidaf3 avatar deiu avatar drewp avatar kiivihal avatar philharveyonline avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rdf2go's Issues

rdf2go usage with SMW?

Hello,

I have read this Paper and it mentioned the usage of rdf2go with Semantic Mediawiki (SMW). I came to your repository, hoping for some example or some demo that can show how one can make it work with SMW.

I am looking forward to getting any help from you regarding the rdf2go integration with SMW!

Thanks.

Convert TTL or JSON-LD to GO struct

I'm able to convert TTL file to a JSON-LD format. Note, the conversion is not perfect because it lacks of @Context metadata. I compared the output using this repo vs online converters.
But how can I convert from JSON-LD to an a Golang structs? Or even better, can I convert straight from RDF TTL to Golang struct?

IterTriples causes concurrent map error

I'm a happy user of this library but we get occasional errors from the Go runtime's 'concurrent map misuse detector' which makes the program crash: https://go.dev/doc/go1.6#runtime

I believe IterTriples() needs to be changed to avoid this error, e.g. by adding a lock:

rdf2go/graph.go

Line 107 in c39eb29

func (g *Graph) IterTriples() (ch chan *Triple) {

You may also need to use this same lock inside the reader methods.

Alternatively you could avoid creating a goroutine inside IterTriples().

Working with # IRI

So I am seeing if I can read a VoID doc in turtle. All is going very well till I try to look for triples based on a # IRI.

When I try and do this line (full code ref below)

vds.DownloadURL = getObject(g, triples[triple].Subject, rdf2go.NewResource("http://www.w3.org/ns/dcat#downloadURL"))

It doesn't work since of course everything after # is effectively ignored which is of course correct in many cases. Still, in SPARQL I can set up a query and use a prefix that has a #'s base.

Is there a way to conduct a search in rdf2go with IRIs that have the # structure like in https://github.com/OpenCoreData/ocdGarden/blob/master/GraphUtils/VOIDReader/void.ttl

Code Ref: https://github.com/OpenCoreData/ocdGarden/blob/master/GraphUtils/VOIDReader/main.go

Error parsing text/turtle

Hi, thanks for your great library. Recently I encountered an error parsing turtle with booleans in it. Here is an example to reproduce:

package main

import (
  "fmt"
  "strings"
  "github.com/deiu/rdf2go"
)

func main() {
  g := rdf2go.NewGraph("")
  if err := g.Parse(strings.NewReader(`<s> <p> [ <o> true; <other> <triple> ] .`), "text/turtle"); err != nil {
    panic(err)
  }
  fmt.Println(g)
}

This results in:

panic: Expected object, got Expected ':' while lexing pname%!(EXTRA []interface {}=[]) (type %!s(easylex.TokenType=-2))

How can a prefix be used?

For example:
rdf is the prefix for <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
Therefore, in the .ttl file we should write:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
...
ont:TACTIC rdf:type owl:Class ;
    neo4voc:name "TACTIC" .

ont:CustomId rdf:type owl:DatatypeProperty ;
    neo4voc:name "CustomId" .

Blank node creation error in deserializing JSON-LD

Reference:
https://github.com/OpenCoreData/ocdGarden/blob/master/JSON-goLD/rdf2goTesting/main.go

Taking a JSON-LD document that contains blank nodes results in an error where all blank nodes get the same ID.

Expect something like

_:b0 <http://schema.org/description> "The Empire State Building is a 102-story landmark in New York City." .
_:b0 <http://schema.org/geo> _:b1 .
_:b0 <http://schema.org/image> <http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg> .
_:b0 <http://schema.org/name> "The Empire State Building" .
_:b1 <http://schema.org/latitude> "40.75"^^<http://www.w3.org/2001/XMLSchema#float> .
_:b1 <http://schema.org/longitude> "73.98"^^<http://www.w3.org/2001/XMLSchema#float> .

Get

_:n0 <http://schema.org/description> "The Empire State Building is a 102-story landmark in New York City."^^<http://www.w3.org/2001/XMLSchema#string> .
_:n0 <http://schema.org/geo> _:n0 .
_:n0 <http://schema.org/image> <http://www.civil.usherbrooke.ca/cours/gci215a/empire-state-building.jpg> .
_:n0 <http://schema.org/name> "The Empire State Building"^^<http://www.w3.org/2001/XMLSchema#string> .
_:n0 <http://schema.org/latitude> "40.75"^^<http://www.w3.org/2001/XMLSchema#float> .
_:n0 <http://schema.org/longitude> "73.98"^^<http://www.w3.org/2001/XMLSchema#float> .

Note the geo line at row 2 in both outputs.
The rightmost blank node can not be _:n0 again.

Also, curious if I load multiple JSON-LD documents into a single graph if the blank nodes will be unique so that subsequent JSON-LD documents don't deserialize with conflicting blank node IDs.

Escaping characters throws an exception

Hello,

There's a problem (bug) in the current library code regarding the escpaction of special characters.
I'm trying to parse a RDF literal (string) which has dobule slash: "aaa\\bbb".
As a result of that, an exception is being thrown: panic: strconv.ParseInt: parsing "ser": invalid syntax

Program's code:

package main

import (
	"github.com/deiu/rdf2go"
	"log"
	"os"
)

func main() {
	if err := convertTtlToJsonLd(); err != nil {
		log.Fatalln(err)
	}
}

func convertTtlToJsonLd() error {
	r, _ := os.OpenFile("test.ttl", os.O_CREATE|os.O_RDONLY, 0664)
	w, _ := os.OpenFile("test.json", os.O_CREATE|os.O_WRONLY, 0644)
	g := rdf2go.NewGraph("https://oxfordsemantic.tech/RDFox/getting-started/")
	if err := g.Parse(r, "text/turtle"); err != nil {
		return err
	}
	return g.Serialize(w, "application/ld+json")
}

RDF (Turtle) file - test.ttl:

@prefix : <https://oxfordsemantic.tech/RDFox/getting-started/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfox: <http://oxfordsemantic.tech/RDFox#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix swrl: <http://www.w3.org/2003/11/swrl#> .
@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:Username :Asset_account :Account_159 ;
    :Str_username "w10apps01\\user" ;
    rdf:type :Username .

Exception being thrown:

panic: strconv.ParseInt: parsing "ser": invalid syntax

goroutine 1 [running]:
github.com/deiu/gon3.unescapeUChar({0xc0001c41f0?, 0x12a0120?})
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/rdf.go:208 +0x2be
github.com/deiu/gon3.lexicalForm({0xc0001c41ef, 0x11})
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/rdf.go:155 +0xd2
github.com/deiu/gon3.(*Parser).parseRDFLiteral(0xc000129e68?)
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/parser.go:560 +0x7e
github.com/deiu/gon3.(*Parser).parseLiteral(0xc000129e68?)
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/parser.go:508 +0x5e
github.com/deiu/gon3.(*Parser).parseObject(0xc000129e68)
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/parser.go:469 +0x9c5
github.com/deiu/gon3.(*Parser).parseObjectList(0xc000129e68?)
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/parser.go:381 +0x25
github.com/deiu/gon3.(*Parser).parsePredicateObjectList(0xc000129e68?)
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/parser.go:344 +0xa9
github.com/deiu/gon3.(*Parser).parseTriples(0xc000129e68)
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/parser.go:273 +0xb8
github.com/deiu/gon3.(*Parser).parseStatement(0x1343660?)
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/parser.go:168 +0x105
github.com/deiu/gon3.(*Parser).Parse(0xc000129e68, {0x1343660?, 0xc000010230?})
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/parser.go:51 +0x11b
github.com/deiu/rdf2go.(*Graph).Parse(0xc00007dc50, {0x1343660, 0xc000010230}, {0x12c8083?, 0x300000002?})
        /Users/bora/go/pkg/mod/github.com/deiu/[email protected]/graph.go:201 +0x2f7
main.convertTtlToJsonLd()
        /Users/bora/converter/main.go:19 +0x1c7
main.main()
        /Users/bora/converter/main.go:10 +0x19

Process finished with the exit code 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.