The cl-ntriples Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-ntriples Reference Manual

This is the cl-ntriples Reference Manual, version 2012.12.16, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 03:27:03 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

CL-NTRIPLES provides a simple parser for the N-Triples data format as defined by the W3C for storing RDF/Semantic information. N-Triples is a line-based, plain text format for encoding an RDF graph.

Main entry function is PARSE-NT method that parses N-Triples from the given source. This method accepts a file pathname, an input stream, or a string.

Returns a list of triples consisting of three elements: subject, predicate, object. Subjects can be either an uriref or a nodeID. Objects can be of three types: uriref, nodeID or a literal. Depending on the type of the object it is encoded into an association list.

N-Triples data format standard definition is provided in the W3C documents:

Check also the Semantic Web page on CLiki.

Project page on Sourceforge.

Sample usage

CL-NTRIPLES Quickdocs is available through Quicklisp:

(ql:quickload :cl-ntriples)

CL-NTRIPLES was developed for a practical purpose of accessing the wealth of data accumulated by the DBPedia project. For example, let's query information about a Ukrainian city of Chernihiv (wiki, dbpedia):

(defvar page-url "http://dbpedia.org/data/Chernihiv.ntriples")
(defvar *res* (nt:parse-nt (drakma:http-request page-url)))
;; *res* now contains a list of triples, let's query some predicates
;; for brevity, predicates will defined as variables

(defconstant +prop-area-total-km+ "http://dbpedia.org/property/areaTotalKm")
(defconstant +rdf-label+ "http://www.w3.org/2000/01/rdf-schema#label")

;; querying predicates is now reduced to a simple function call:
;; nt:predicate? TRIPLES PREDICATE &key LANG DATA-TYPE

;; what is the city area in km2?
(nt:predicate? *res* +prop-area-total-km+)
=> (("http://dbpedia.org/resource/Chernihiv"
  "http://dbpedia.org/property/areaTotalKm"
  ((:LITERAL-STRING . "79")
   (:URIREF . "http://www.w3.org/2001/XMLSchema#int"))))

;; how do Japanese call this city?
(predicate? *res* +rdf-label+ :lang "ja")
=> (("http://dbpedia.org/resource/Chernihiv"
  "http://www.w3.org/2000/01/rdf-schema#label"
  (:LITERAL-STRING "チェルニーヒウ" :LANG "ja")))

Functions

Package provides following functions:


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-ntriples

Author

Victor Anyakin <anyakinvictor@yahoo.com>

License

BSD

Description

CL-NTRIPLES is a simple basic parser for Ntriples data.

Long Description

A basic parser and a set of simple utilities to parse N-Triples data.

N-Triples provides a simple format for representation of Semantic Web/W3C RDF semantic data. CL-NTRIPLES provides a simple and easy to use parser for Common Lisp applications.

Version

2012.12.16

Dependency

alexandria

Source

cl-ntriples.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 cl-ntriples/src

Parent

cl-ntriples (system)

Location

src/

Components

Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 cl-ntriples.asd

Location

cl-ntriples.asd

Systems

cl-ntriples (system)

Packages

cl-ntriples-asd


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.2 cl-ntriples/src/package.lisp

Parent

src (module)

Location

src/package.lisp

Packages

cl-ntriples


Previous: , Up: Lisp files   [Contents][Index]

4.1.3 cl-ntriples/src/nt-parser.lisp

Dependency

package.lisp (file)

Parent

src (module)

Location

src/nt-parser.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 cl-ntriples-asd

Source

cl-ntriples.asd

Use List

Previous: , Up: Packages   [Contents][Index]

5.2 cl-ntriples

Source

package.lisp (file)

Nickname

nt

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Functions

Function: literal-string TRIPLE

Returns the literal-string value of the triple’s object.

Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: predicate? TRIPLES PREDICATE &key LANG DATA-TYPE

Given the list of triples produced by PARSE-NT returns a list of triples with predicates matching the given one.

Package

cl-ntriples

Source

nt-parser.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Generic functions

Generic Function: parse-nt SRC

Parses N-Triples from the given source. This method
accepts a file pathname, a stream, or a string.

Returns a list of triples consisting of three elements: subject, predicate, object. Subjects can be either an ‘uriref’ or a ‘nodeID’. Objects can be of three types: ‘uriref’, ‘nodeID’ or a ‘literal’. Depending on the type of the object it is encoded into a list.

Package

cl-ntriples

Source

nt-parser.lisp (file)

Methods
Method: parse-nt (SRC pathname)
Method: parse-nt (SRC string)
Method: parse-nt (SRC stream)

Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Constants

Constant: +nt-cr+
Package

cl-ntriples

Source

nt-parser.lisp (file)

Constant: +nt-lf+
Package

cl-ntriples

Source

nt-parser.lisp (file)

Constant: +nt-space+
Package

cl-ntriples

Source

nt-parser.lisp (file)

Constant: +nt-tab+
Package

cl-ntriples

Source

nt-parser.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Functions

Function: consume-whitespace STREAM
Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: ntriple-crlf-p C
Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: ntriple-ws-p C
Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: parse-literal STREAM

Parse the object literal from the stream.

Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: parse-node-id STREAM
Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: parse-ntriple-doc STREAM
Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: parse-ntriple-line STREAM
Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: parse-ntriple-triple STREAM

The triple consists of a: subject, predicate, object. All they are separated by whitespace. There is also a terminating full stop point in the end of a tripple.

Returns a list consisting of three elements corresponding to the tripple.

The syntax is:
triple ::= subject ws+ predicate ws+ object ws* ’.’ ws*

Package

cl-ntriples

Source

nt-parser.lisp (file)

Function: parse-uriref STREAM
Package

cl-ntriples

Source

nt-parser.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L   M  
Index Entry  Section

C
cl-ntriples.asd: The cl-ntriples<dot>asd file
cl-ntriples/src: The cl-ntriples/src module
cl-ntriples/src/nt-parser.lisp: The cl-ntriples/src/nt-parser<dot>lisp file
cl-ntriples/src/package.lisp: The cl-ntriples/src/package<dot>lisp file

F
File, Lisp, cl-ntriples.asd: The cl-ntriples<dot>asd file
File, Lisp, cl-ntriples/src/nt-parser.lisp: The cl-ntriples/src/nt-parser<dot>lisp file
File, Lisp, cl-ntriples/src/package.lisp: The cl-ntriples/src/package<dot>lisp file

L
Lisp File, cl-ntriples.asd: The cl-ntriples<dot>asd file
Lisp File, cl-ntriples/src/nt-parser.lisp: The cl-ntriples/src/nt-parser<dot>lisp file
Lisp File, cl-ntriples/src/package.lisp: The cl-ntriples/src/package<dot>lisp file

M
Module, cl-ntriples/src: The cl-ntriples/src module

Jump to:   C   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   F   G   L   M   N   P  
Index Entry  Section

C
consume-whitespace: Internal functions

F
Function, consume-whitespace: Internal functions
Function, literal-string: Exported functions
Function, ntriple-crlf-p: Internal functions
Function, ntriple-ws-p: Internal functions
Function, parse-literal: Internal functions
Function, parse-node-id: Internal functions
Function, parse-ntriple-doc: Internal functions
Function, parse-ntriple-line: Internal functions
Function, parse-ntriple-triple: Internal functions
Function, parse-uriref: Internal functions
Function, predicate?: Exported functions

G
Generic Function, parse-nt: Exported generic functions

L
literal-string: Exported functions

M
Method, parse-nt: Exported generic functions
Method, parse-nt: Exported generic functions
Method, parse-nt: Exported generic functions

N
ntriple-crlf-p: Internal functions
ntriple-ws-p: Internal functions

P
parse-literal: Internal functions
parse-node-id: Internal functions
parse-nt: Exported generic functions
parse-nt: Exported generic functions
parse-nt: Exported generic functions
parse-nt: Exported generic functions
parse-ntriple-doc: Internal functions
parse-ntriple-line: Internal functions
parse-ntriple-triple: Internal functions
parse-uriref: Internal functions
predicate?: Exported functions

Jump to:   C   F   G   L   M   N   P  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   +  
C  
Index Entry  Section

+
+nt-cr+: Internal constants
+nt-lf+: Internal constants
+nt-space+: Internal constants
+nt-tab+: Internal constants

C
Constant, +nt-cr+: Internal constants
Constant, +nt-lf+: Internal constants
Constant, +nt-space+: Internal constants
Constant, +nt-tab+: Internal constants

Jump to:   +  
C  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   P   S  
Index Entry  Section

C
cl-ntriples: The cl-ntriples system
cl-ntriples: The cl-ntriples package
cl-ntriples-asd: The cl-ntriples-asd package

P
Package, cl-ntriples: The cl-ntriples package
Package, cl-ntriples-asd: The cl-ntriples-asd package

S
System, cl-ntriples: The cl-ntriples system

Jump to:   C   P   S