The cl-ntriples Reference Manual

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 4.0 beta 2 "William Riker" on Mon Aug 15 03:51:53 2022 GMT+0.

Table of Contents


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:


2 Systems

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


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

2.1 cl-ntriples

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

Author

Victor Anyakin <anyakinvictor@yahoo.com>

License

BSD

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 (system).

Source

cl-ntriples.asd.

Child Component

src (module).


3 Modules

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


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

3.1 cl-ntriples/src

Source

cl-ntriples.asd.

Parent Component

cl-ntriples (system).

Child Components

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   [Contents][Index]

4.1.1 cl-ntriples/cl-ntriples.asd

Source

cl-ntriples.asd.

Parent Component

cl-ntriples (system).

ASDF Systems

cl-ntriples.

Packages

cl-ntriples-asd.


4.1.2 cl-ntriples/src/package.lisp

Source

cl-ntriples.asd.

Parent Component

src (module).

Packages

cl-ntriples.


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

Dependency

package.lisp (file).

Source

cl-ntriples.asd.

Parent Component

src (module).

Public Interface
Internals

5 Packages

Packages are listed by definition order.


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

5.1 cl-ntriples

Source

package.lisp.

Nickname

nt

Use List
  • alexandria.
  • common-lisp.
Public Interface
Internals

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

5.2 cl-ntriples-asd

Source

cl-ntriples.asd.

Use List
  • asdf/interface.
  • common-lisp.

6 Definitions

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


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

6.1 Public Interface


6.1.1 Ordinary functions

Function: literal-string (triple)

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

Package

cl-ntriples.

Source

nt-parser.lisp.

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.


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.

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

6.2 Internals


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

6.2.1 Constants

Constant: +nt-cr+
Package

cl-ntriples.

Source

nt-parser.lisp.

Constant: +nt-lf+
Package

cl-ntriples.

Source

nt-parser.lisp.

Constant: +nt-space+
Package

cl-ntriples.

Source

nt-parser.lisp.

Constant: +nt-tab+
Package

cl-ntriples.

Source

nt-parser.lisp.


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

6.2.2 Ordinary functions

Function: consume-whitespace (stream)
Package

cl-ntriples.

Source

nt-parser.lisp.

Function: ntriple-crlf-p (c)
Package

cl-ntriples.

Source

nt-parser.lisp.

Function: ntriple-ws-p (c)
Package

cl-ntriples.

Source

nt-parser.lisp.

Function: parse-literal (stream)

Parse the object literal from the stream.

Package

cl-ntriples.

Source

nt-parser.lisp.

Function: parse-node-id (stream)
Package

cl-ntriples.

Source

nt-parser.lisp.

Function: parse-ntriple-doc (stream)
Package

cl-ntriples.

Source

nt-parser.lisp.

Function: parse-ntriple-line (stream)
Package

cl-ntriples.

Source

nt-parser.lisp.

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.

Function: parse-uriref (stream)
Package

cl-ntriples.

Source

nt-parser.lisp.


Appendix A Indexes


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

A.1 Concepts


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

A.2 Functions

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

C
consume-whitespace: Private ordinary functions

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

G
Generic Function, parse-nt: Public generic functions

L
literal-string: Public ordinary functions

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

N
ntriple-crlf-p: Private ordinary functions
ntriple-ws-p: Private ordinary functions

P
parse-literal: Private ordinary functions
parse-node-id: Private ordinary functions
parse-nt: Public generic functions
parse-nt: Public generic functions
parse-nt: Public generic functions
parse-nt: Public generic functions
parse-ntriple-doc: Private ordinary functions
parse-ntriple-line: Private ordinary functions
parse-ntriple-triple: Private ordinary functions
parse-uriref: Private ordinary functions
predicate?: Public ordinary functions

Jump to:   C   F   G   L   M   N   P