Swiftpack.co - kasei/serd-parser as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by kasei.
kasei/serd-parser 0.0.3
An example of using the Serd RDF parsing library in Swift
⭐️ 2
🕓 2 years ago
.package(url: "https://github.com/kasei/serd-parser.git", from: "0.0.3")

serd-parser

This is an example project to show the use of the Serd RDF library to parse N-Triples data in Swift.

From the command line:

% swift build
% ./.build/debug/serd-parse foaf.ttl
<http://kasei.us/about/#greg> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
<http://kasei.us/about/#greg> <http://xmlns.com/foaf/0.1/name> "Gregory Todd Williams" .
<http://kasei.us/about/#greg> <http://xmlns.com/foaf/0.1/nick> "kasei" .
<http://kasei.us/about/#greg> <http://xmlns.com/foaf/0.1/mbox> <mailto://[email protected]> .
<http://kasei.us/about/#greg> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "f80a0f19d2a0897b89f48647b2fb5ca1f0bc1cb8" .
<http://kasei.us/about/#greg> <http://xmlns.com/foaf/0.1/homepage> <http://kasei.us/> .
<http://kasei.us/about/#greg> <http://xmlns.com/foaf/0.1/img> <http://kasei.us/images/greg.png> .
...

Or, programatically:

import SerdParser

// extract all foaf:name triples
let parser = SerdParser()
let count = try parser.parse(file: filename) { (s, p, o) in
    if case .iri("http://xmlns.com/foaf/0.1/name") = p {
        print("\(s) has name \(o) .")
    }
}
print("\(count) triples processed")

GitHub

link
Stars: 2
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics