Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iand/nquads
NQuad parser in Go
https://github.com/iand/nquads
go golang linked-data parser rdf semantic-web
Last synced: 18 days ago
JSON representation
NQuad parser in Go
- Host: GitHub
- URL: https://github.com/iand/nquads
- Owner: iand
- License: unlicense
- Created: 2020-09-20T16:37:11.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-04T12:04:06.000Z (9 months ago)
- Last Synced: 2024-10-07T23:05:26.416Z (3 months ago)
- Topics: go, golang, linked-data, parser, rdf, semantic-web
- Language: Go
- Homepage:
- Size: 65.4 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# nquads
A basic nquads parser in Go
[![Check Status](https://github.com/iand/nquads/actions/workflows/check.yml/badge.svg)](https://github.com/iand/nquads/actions/workflows/check.yml)
[![Test Status](https://github.com/iand/nquads/actions/workflows/test.yml/badge.svg)](https://github.com/iand/nquads/actions/workflows/test.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/iand/nquads)](https://goreportcard.com/report/github.com/iand/nquads)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/iand/nquads)## Overview
[N-Quads](https://www.w3.org/TR/n-quads/) is a serialisation format for [RDF datasets](https://www.w3.org/TR/rdf11-concepts/#section-dataset).
A dataset consists of a default graph with no name and zero or more named graphs where a graph is a composed of a set of triples. The default
graph may be empty.An N-Quads file is a line-oriented format where each triple or quad statement is terminated by a period `.`.
- IRIs are enclosed by `<` and `>`
- Literals have a lexical value enclosed by `"` followed by an optional language tag using `@` as a delimiter, or a data type IRI using `^^` as a delimiter
- Blank nodes have a lexical label prefixed by `_:` and the same label denotes the same blank node throughout the file.A triple in a named graph may be written as a statement using four terms, the last of which is the name of the graph:
```
.
```A triple in the default graph omits the fourth term:
```
.
```## Getting Started
Example of parsing an nquads file and printing out every 5000th quad
```Go
package mainimport (
"fmt"
"os"
"github.com/iand/nquads"
)func main() {
nqfile, err := os.Open("myquads.nq")
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %s", err.Error())
os.Exit(1)
}
defer nqfile.Close()count := 0
r := nquads.NewReader(nqfile)
for r.Next()
count++
if count % 5000 == 0{
fmt.Printf("%s\n", r.Quad())
}
}if r.Err() != nil {
fmt.Printf("Unexpected error encountered: %v\n", r.Err())
}}
```## Author
* [Ian Davis](http://github.com/iand) -
# License
This is free and unencumbered software released into the public domain. For more
information, see or the accompanying [`UNLICENSE`](UNLICENSE) file.## Credits
The design and logic is inspired by Go's standard csv parsing library