Triple20: an RDF triple viewer and editor


Jan Wielemaker
Human-Computer Studies (HCS),
University of Amsterdam
The Netherlands
E-mail: wielemak@science.uva.nl

Abstract

This document describes Triple20. Triple20 is a visualisation and editing tool for data stored in the SWI-Prolog semweb triple store. Triple20 has been designed not to limit the expressiveness of the triple data model, to scale comfortably to several millions of triples and deal with triples associated to multiple sources at the same time.

As the internal interfaces stabelise they will be fixated and documented, providing an extensible toolkit whose components can be reorganised to build dedicated semantic web tools.

Based completely on XML/RDF and fairly crash-proof the system is usable as visualisation and editing tool. Both is internal interfaces and UI however are under active development and change frequently, which is why we only explain the basics in this document.

Table of Contents

1 Introduction

Most ontology editors have their own view on the world that dictate both the internal data model and the UI. Such systems provide import and export filters to other formats. Triple20 on the contrary uses RDF/XML and the RDF formal triple data model directly, providing a range of visualization primitives that interpret the triple store at different level of abstraction ranging from access to the RDF/XML source via triple-tables and RDF diagrams to dedicated RDFS and OWL views. Using triples directly, these views can co-exist in the same application and the toolkit can easily handle anything that can be expressed in triples.

Modularity and scale are other important aspects of the semantic web. Triple20 keeps track of the source of each triple which enables it it view and edit several RDF documents in a unified view. It has been designed to view and edit models with several millions of triples on standard office equipment.

2 The Triple20 User Interface

The interface is too unstable to document in any detail. This section only provides some hints to get you started.

2.1 Drag till you Drop

Many edit operations require two arguments, making drag-and-drop an attractive interface technique. Drag and drop is associated with most objects on both the left- and right mouse button. While dragging, the system indicates the action taken in the status window. On left-drag it executes the indicated action. On right-drop it displays a menu with alternatives. Some actions

Note that File/New window creates a new view on the triple set that fully cooperates and synchronises with the other views. Drag and drop between multiple views is a suggested technique to deal with larger ontologies. Notable the user can exploit search in a small window to locate relevant resources.

If the text-field is coloured blue, this indicates there is at least one resource in the database that exactly matches the typed string.

2.2 Context menus

Most objects have a context menu associated with the right mouse-button that act on the represented resource, possibly in relation to other resources on the same row (table) or related in the hierarchy. Sub-menus are described as Menu/SubMenu/...

Details (hierarchy)
Show the resource in the table and bring the most applicable view to the front.

Hierarchy location (table)
If the resource is not in the hierarchy, add it as well as the parents to create (an arbitrary) path to the root. See also View/Show all parents.

Copy/Id
Put the full resource identifier (including namespace) on the clipboard.

Copy/Copy as xml identifier
Put the NamespaceId:LocalId on the clipboard using the namespace identifier as registered with the rdf_db library.

Copy/Copy as xml attribute
Put the resource in a format suitable for an XML attribute value: &NamespaceId;LocalId

Rename resource
Rename an existing resource to a new one. All triples holding the old resource in either of the three fields are updated.

Delete
Delete a resource completely. All triples holding this resource in either of the three fields are removed from the database.

Delete class hierarchy (hierarchy)
Delete an entire hierarchy build using rdfs:subClassOf or a subproperty thereof. Resources that become disconnected from the hierarchy are deleted completely.

Unrelate (hierarchy)
Delete the triple causing the node to appear in this location of the hierarchy. All other relations are unaffected. See also View/Show all parents.

New subclass (hierarchy)
Create a new resource and make it a subclass of the current node. The create dialog prompts for the file, namespace and label for the new resource. The meta class (rdf:type, default associated file and default namespace are the same as the super class.

New individual (hierarchy)
Create an individual of the class represented by the current node. See also New subclass.

New property (hierarchy)
Create an individual of the property class represented by the current node. See also New subclass.

View/rdf source
Open the RDF description defining the resource. The current implementation naïvely opens the first if triples for the resource originate from multiple descriptions.

View/diagram
Open an RDF diagram with this resource or add this resource to the already open diagram. The current diagram window is based on code from an older project and not yet well integrated into Triple20.

View/Show all parents (hierarchy)
Find all places in the hierarchy where the current resource appears and highlight them. This is particularly useful to examine multiple inheritance, multiple types, etc.

View/triples (predicate)
Show all triples of this predicate in the right-hand table. The current triple-table is crude, providing inefficient update and poor handling of large tables.

2.3 The Window menu

File/New window
Create a new Triple20 window on the same database. Drag and drop between the two windows is supported to relate resources from different parts of the hierarchy.

File/Open project
Discard the current database and open an existing project (see section 5). Triple20 cannot work with multiple projects at the same time.

File/New project
Discard the current database and create a new empty project. See section 5 for details on working with projects.

File/Load ontology
Load triples from an XML/RDF file. Note that most XML/RDF files depend on RDFS and/or OWL, which must be loaded to get a meaningful view. See also File/Load base ontology. If Triple20 is started by opening an XML/RDF file it will apply some heuristics to load the required base ontologies. Use File/Statistics to examine the loaded files.

File/Load base ontology
Load one of the ontologies distributed with triple20. Almost any project requires rdfs.

File/Load required base ontologies
Load the registered base ontologies needed to show the current document correctly. A base ontology is considered required if the current dataset contains predicates that belong to the namespace of a base ontology.

File/New file
Create a new file and add it to the pool. After creating this file resources can be associated to it. See also New subclass and section 5.1 for a discussion on file management.

File/Merge files
Move the triples associated with a file to another file. The command opens a dialog for selecting the source and destination files. For example, ontologies can be merged by creating a new file, merging the desired ontologies into the new file and save this file.

File/Save file
The submenu holds all loaded files, where the files whose set of associated triples has been modified are activated. The `modified' state is based on the MD5 hash of the triples associated to the file which implies that after edit/undo or edit/inverse edit the file is still regarded unmodified.

File/Save all
Save all modified files.

File/Name spaces
Inspect/edit the mapping from short name space identifiers (e.g. rdfs) to the associated URI. Changes to this mapping are stored in the project.

File/Files
Show loaded files, associated namespaces and access rights. Second tab shows some query statistics.

File/exit
Exit the current window. Note that the current Triple20 runs on top of the Prolog toplevel which may be used to inspect and alter the triple store. Closing a window does not stop Prolog. New Triple20 windows can be created from Prolog using the command ?- go..

View/Label
Change the labels displayed for resources. See section 2.5 for details.

View/Dialect
Change which part of and how the triple store is interpreted. Little of this is implemented in the current prototype.

View/OWL/Class extension
If selected (default), resources that belong to the dynamically computed class extension are visible in the hierarchy with the icon. Note that computing the OWL class extension is very incomplete.

View/Show roots of/...
The submenu shows all source files. Selecting a source file collapses the hierarchy and then adds all concepts and properties that are defined in this file, but whose parent is not defined in this file. The file to which a resource belongs is defined as the file to which the rdf:type triple belongs.

Tools/Add missing labels
Add an rdfs:label triple to each non-anonymous resource that has no defined label. The default label is the local name of the resource.

Tools/Maintenance/Delete cached ontologies
Delete all cache files created to speedup the loading of RDF/XML files. This may be necessary to recover from incompatible changes to the cache file format or bugs in the RDF/XML parser.

Tools/Maintenance/Delete snapshots
Delete all snapshots. If you want to preserve any project file, make sure you understand snapshots before using this option. See section 5.3.

Help/Help
Open this document in your browser.

Help/About
Show the about box. Among author and copyright information it provides a link to the project home.

2.4 Search

The top-right window allows searching resources with certain literal properties. The Search in menu specifies the properties searched. Two entries have special meaning.

Any
Search in any property with literal value. Searching for Any disables the other fields.

Resource
Search the resource itself.

The search-field itself allows for the syntax ns:string, where ns is a namespace abbreviation. This causes the search to be executed in the given namespace only.

The hierarchy is collapsed and the first 100 matches of the search are added to the hierarchy. Using shift-click, collapsing of the hierarchy is skipped and the hits are added to the current view. This makes it easy to add resources to the hierarchy, preparing drop operations. Similar results can be realised by creating a new window using File/New window.

2.5 Icons and Labels

Using the View/Label menu the system can identify resources in three ways. Label only only displays the label. The label is either the first value for the rdfs:label property, a subproperty thereof or the last part of the resource name. Namespace and label displays the namespace identifier (see section 5.2) before the label. This is the default. Resource displays the namespace identifiers in front of the local resource name.

In most situations the label is preceded by a small icon. The icons depend on the classification of the resource. In the hierarchy view, labels may have two icons. In this case the first icon represents the relation to the parent and the second represents the type classification.

2.6 Undo and redo

Triple20 provides unlimited undo and redo using toolbar buttons. Note however that some operations, notably file merge

2.7 View consistency

Triple20 uses the Model-View-Controller design. Edit operations only modify the triple database. The GUI monitors the changes to the triple database and updates the display. Unfortunately the view has a very indirect relation to the triples. Generally labels register themselves to be updated whenever a property of the represented resource is changed, added or deleted. Complicates relations such as expressed in the hierarchy and table use a registered query which is re-evaluated on every change in the background. If the result changes the background thread triggers the UI to update.

This deals with most changes, but sometimes the system will miss the proper update. When in doubt collapse and re-expand the hierarchy and/or switch the table to another resource and back to force proper update. Please report inconsistencies you think can be avoided.

2.8 Printing

There is very limited support to print graphical representations. The main tool has a Print hierarchy menu, which prints the current expansion of the left hierarchy window on a single sheet of paper. The RDF graph viewer, started with View diagram also provides a print option.

Note that not only the visible part of the window, but also the invisible parts are printed. The result is scaled down to fit a single page.

3 Semantic Web practice

3.1 Classes as property values

A very common modeling practice is to use classes as property values. For example, people are tempted to describe the colour of an object as red by selecting the class red from a colour ontology. A commonly seen mistake is to define a property colour with its range set to the root of the colour hierarchy of the domain ontology. This construct however allows for individuals of colours to be placed in the property, not subclasses. The W3C best practices group's current position on this issue is to fill the property with an anonymous individual of the class, in our case an anonymous individual of class red. At first this may appear odd, but think about it. The colour of an object is not `red', but some unspecified form of this colour! Representation as an anonymous individual is a clean solution to express this.

Triple20 supports this practice by creating an anonymous individual whenever one tries to define a property where the value is a subclass of the range of the property. Such objects are identified with the icon.

4 OWL support

The current version of Triple20 does not know much about OWL. It supports OWL at the following places:

OWL reasoning uses a subset of OWL/Full, inferring properties that can be inferred fairly quickly. Supported reasoning includes: owl:sameAs and the property attributes owl:inverseOf, owl:SymmetricProperty and owl:TransitiveProperty. It also derives the value of a property if one of the types of a resource defines owl:hasValue.

Triple20 deduces the class extensions of restrictions and descriptions. If property values are to be considered it uses the above described features to infer property values.

5 Projects and files

5.1 Files

Triples in rdf_db are actually quadruples. The last part registers the origin of the triple, so the tool can load ontologies from multiple files, present the joined view and still save the modified triples to a specific file. As Triple20 provides an integrated view and editing capabilities on all triples loaded from all sources it requires some machinery and defaults to define the source assigned to newly created triples. The File/Statistics menu gives access to an overview of the loaded files and allows to inspect and edit properties thereof. Defined properties are:

ro
The source is read only. Any transaction that modifies this source is rolled back and an error message is displayed. Sources are initially flagges as ro if they are loaded as a base ontology or they are loaded from a read-only file.

rw
The source is editable. This implies triples can deleted, updated and added. If no source is flagged all, new triples are added to the same source as already existing triples on the same subject. New subjects are ---by default--- added to the same source as their context, but this may be overruled by the user.

fallback
If there is no context, this source is used for new triples. At most one of the sources has the fallback or all property. Enabling fallback or all enables rw.

all
All new triples are added to this source.

The menu File/Merge files allow the user to move all triples associated to some file to another file. This can be used to merge ontologies. The File/Save file submenu allow for saving modified files. The View/Show roots of/... submenu can be used to show the roots of classes and properties defined on a file.

5.2 Namespaces

Triple20 has an internal table of well-known namespaces and their common abbreviation. This table is in the file rdf_base.pl. If possible it will use the abbreviated form in the UI. Namespaces can be added through the File/Names paces menu option. Registered namespaces are stored in the project file.

5.3 Project files and snapshots

A project file .rdfj is a journal of executed edit operations. This approach has several advantages over the normal load-modify-save cycle.

There are various alternatives for handling the loading of ontology files in the journal. One is to simply add the fact that a file is loaded. This can be attractive because the journal acts as a set of edit operations that can be executed on a modified version of the same file. Unfortunately it also easily leads to problems if the file is saved from the tool. For this reason Triple20 maintains a snapshot directory where it stores snapshots of ontology files loaded into projects. The name for these files is created from the original file as well as an MD5 digest constructed from the triples. The journal contains information on the original file (name, time modified, size, number of triples) as well as the MD5 digest. If the journal is replayed it will first try to locate the snapshot from the MD5 digest and name, loading exactly the same file. If this fails Triple20 tries to locate the ontology file itself.

6 Triple20 as a library

Triple20 can be used in two modes: as a stand-alone applicationn and as a Prolog library. Section 7 discusses installation as a stand-alone executable. This section discusses the steps to use Triple20 as a GUI in another Prolog program. This usage aims at non-GUI RDF applications based on the library(rdf_db.pl) library that wish to have a GUI for exploring the triple-set. Note that it is possible to load and Triple20 only in a debugging version.

6.1 Making Triple20 known

Triple20 uses the file-search path triple20 for locating its components. Add the following to your project load-file, adjusting the path to reflect local installation:


:- multifile
        user:file_search_path/2.
:- dynamic
        user:file_search_path/2.

user:file_search_path(triple20, '/staff/jan/src/Triple20/src').

Now, Triple20 can be loaded using the directive


:- use_module(triple20(load)).

6.2 Interacting with Triple20

Triple20 provides the following predicates:

triple20(+Argv)
Start the Triple20 GUI using options from Argv. Argv is a list of atoms, each atom providing a commandline argument.

triple20
Equivalent to triple20([]), starting the default Triple20 GUI.

t20(+Action)
Utility predicate telling the Triple20 GUI to perform some action. It uses the broadcasting service to send a message to all open Triple20 GUI windows. Typical actions are:

refresh
Propagate changes to the database to Triple20. Normally Triple20 gets update messages from the library(rdf_edit.pl) library. Applications using library(rdf_db.pl) directly should inform Triple20 that the database has changes, forcing Triple20 to flush its caches.

open_resource(+URI, +How)
Open resource URI according to How in the table or hierarchy.

7 Downloading and Installation

The current snapshot of the Triple20 toolkit can be downloaded from SWI-Prolog CVS server. As the system is under active development, the HEAD revision is often unstable. We use the symbolic (sticky) tag STABLE to reflect the latest usable version. The CVS download commands are:


% cvs -d :pserver:pl@gollem.science.uva.nl:/usr/local/cvspl login
Logging in to :pserver:pl@gollem.science.uva.nl:2401/usr/local/cvspl
CVS password: prolog

% cvs -z 9 -d :pserver:pl@gollem.science.uva.nl:/usr/local/cvspl co -r STABLE Triple20

This command both downloads the software and the basic ontologies. Alternatively you may checkout the CVS module Triple20-Full, which also download RDF versions of WordNet, OpenCyc and SUMO (total ± 47 Mb).

7.1 Finishing in MS-Windows

After installing Prolog, double click setup.bat to register .RDFJ project files to start Triple20. Optionally also associate .RDF, .RDFS and .OWL to lauch Triple20 and load the file.

To make Triple20 accessible from the Windows desktop, create a shortcut from the desktop to src/triple20.pl or write a .BAT file by adjusting the template given below.


@echo off

"C:\Program Files\pl\bin\plwin.exe" "C:\Program Files\Triple20\src\triple20.pl"

7.2 Finishing in Unix

Edit triple20.pl, adjust #! path to point to the SWI-Prolog executable and file_search_path/2 with an absolute path to the directory where you installed the sources. Now copy (or make a symbolic link) triple20.pl to a directory in your $PATH environment variable as triple20.

After this you can run triple20 option ... file .... Using triple20 --help for a list of commandline options.

8 Bugs and other issues

Although the current system is in active use for browsing ontologies for some time and the first users start to edit ontologies with it, it should first of all be regarded as a prototype. Some remaining issues are:

Acknowledgements

The small type-icons are partly copied from and partly inspired by the Protégé project.

Index

A
Any
C
Copy/Copy as xml attribute
Copy/Copy as xml identifier
Copy/Id
D
Delete
Delete class hierarchy
Details
F
File/exit
File/Files
File/Load base ontology
2.3
File/Load ontology
File/Load required base ontologies
File/Merge files
5.1
File/Name spaces
File/Names paces
5.2
File/New file
File/New project
File/New window
2.1 2.4
File/Open project
File/Save all
File/Save file
5.1
file_search_path/2
7.2
File/Statistics
2.3 5.1
H
Help/About
Help/Help
Hierarchy location
N
New individual
New property
New subclass
2.2 2.2 2.3
O
OWL/Class extension
4
R
Rename resource
Resource
S
Search in
2.4
T
t20/1
Tools/Add missing labels
Tools/Maintenance/Delete cached ontologies
Tools/Maintenance/Delete snapshots
triple20/0
triple20/1
U
Unrelate
V
View/diagram
View/Dialect
View/Label
2.5
View/OWL/Class extension
View/rdf source
View/Show all parents
2.2 2.2
View/Show roots of/...
5.1
View/triples