I have just started to build an ontology and I have to admit that it has been a while since I have done this; I think that the last time was when writing a paper about function (10.1186/2041-1480-1-S1-S4), so I was interested to see how it would work. I’ve have been engaged in discussions recently about syntactic aspects of OWL (http://www.russet.org.uk/blog/2040); the main reason for this is my long-held believe of the need for editing tools that work at the syntactic level; this allows us to plug in to the enormous body of programming tools supporting building, collaborative development, versioning and so on. So, I decided to build the entire thing using Emacs; the nature of the ontology also meant that I wanted to reboot my long-neglected attempts to bring literate development to ontologies (http://www.russet.org.uk/blog/1213). While it is not a large ontology I did manage 60 classes in an afternoon, so I am quite pleased with the results.

My basic working environment is as follows:

for editing
providing basic OWL Manchester Syntax Support
dynamic and automatic abbreviation support
for viewing the ontology, and running reasoners

As an environment, this works quite well now. Although I have tried it before, Protege seems to work much better now when (mis)-used as a display environment. First, when loading a file into Protege it gives a report of errors, but has a nice “reload” button so that I can now fix the errors (or at least try to). Second, after an ontology has been loaded, Protege will now detect that the file has changed an offer to reload it. In general, it works quite well. There are still some issues — I have not had time to work this out reproducibly enough for a bug report — but there are times when Protege breaks, particularly when I change the file and break the syntax. I can live with this — while restarting Protege is slow in computer time with the Java loading, it doesn’t require lots of clicking to get back to where I started (“Open Recent”), so it’s quick for the user. Finally, and most importantly of all, Protege’s Manchester syntax parser now seems to support comment characters correctly — at least in my hands it treats “#” as a comment character.

Using Emacs as an editing environment over Manchester syntax has some considerable advantages over using Protege raw. I am very keyboard-centric while Protege is very mouse-centric; just moving backward and forward to class definitions with incremental search is much better than in Protege. Simple things like search and replace, especially with regexp just happens naturally in Emacs and there is no equivalent in Protege.

I wrote omn-mode.el a long time ago now; I don’t remember when although the last update to it’s original Subversion repository is from 2005 according to the :Date : inside the file. omn-mode is based on generic.el, and it is starting to get a little stretched for this now; I should move it to using the normal define-major-mode functionality. However, this does reflect what it is best at which is syntax highlighting. I had to fiddle with this a bit, to add support for some extra keywords and just make it more consistant. I am working on the basis that everything should be syntax-highlighted; although this makes Manchester Syntax files a little garish, it helps get the syntax correct. I also improved some of the regexps: so " some " has been changed to "\\<some\\>".

As Protege is now doing comments, I have added proper support for these also, although as a comment character “#” is a bit irritating, given that is also a valid part of a URL. So I fudged a bit here and used “# ” as a two character start. This means that multiple comment characters such as “##” which I use in Lisp is not going to work. But fixing the situation would be much, much harder. It seems to me that “#” is not an ideal choice; a lisp-like “;” would be better; I think, technically, you can find a “;” in a URL, but I have never seen one.

While the previous indentation engine (based purely on the previous line) worked surprisingly well, I have also improved this now. Actually Manchester syntax is surprisingly easy to indent reasonably well; an ontology is essentially a bag of axioms, so it has relatively little structure at the syntactic level, which means that my engine only uses three indentation levels.

Finally, I’ve also updated the mode to recognise both ":", and "_" as a Word constituant, for reasons that should become clear.

pabbrev.el is my own dynamic “as you type” abbreviation expansion package, and it is still the nicest thing that I have written for Emacs. I use it every day (and am using it now). I did notice one minor bug with it which was making is misbehave, but the main change comes from the update to omn-mode’s syntax table. pabbrev.el now expands prefixes and terms as a single word. For me, at least, this seems to work well. The change to the syntax table will also affect other dynamic abbreviation packages as well, including dabbrev and hippie-expand. Similarly underscore_separated_terms should expand.

The combination of these changes means that, for me anyway, Emacs is now quite a capable Manchester syntax editor. I have only really touched here on the things that I have written, but editing OWL ontologies at the textual level also really does open up many possibilities. Having an environment that I control is also useful. I would like to extend Manchester syntax to support semantics-free identifiers (http://www.russet.org.uk/blog/2040). I can now make an initial implementation of this, using a pre-processsor to unwind the Alias: definitions to produce a “real” Manchester syntax file.



  1. David OS says:

    Hi Phil,

    Nice post.

    Could you post links to you .el files?


  2. Phillip Lord says:

    Will do soon. Just finishing off adding “Alias” support.

  3. An Exercise in Irrelevance » Blog Archive » Omn-mode now released says:

    […] recently published about my experiences of using Emacs for Ontology building (http://www.russet.org.uk/blog/2161). A fairly niche subject area, but I was did get a couple of responses asking for my code; […]

  4. Phillip Lord says:

    As the last trackback says, this mode is now up and available.

  5. An Exercise in Irrelevance » Blog Archive » Some Updates to omn-mode says:

    […] have described my experiences of using Emacs for writing ontologies previously (http://www.russet.org.uk/blog/2161). I was not entirely happy with omn-mode, even after recent changes […]

  6. An Exercise in Irrelevance » Blog Archive » Programming OWL says:

    […] is partly for this reason that I have been developing my own OWL Manchester syntax mode for Emacs (http://www.russet.org.uk/blog/2161); I lose a lot from Protege, but then I also gain the ability to manipulate large numbers of […]

  7. An Exercise in Irrelevance » Blog Archive » OWL Concepts as Lisp Atoms says:

    […] enforce this correctness in the Editor, while pabbrev.el (http://www.russet.org.uk/blog/2161) provides “correctness-by-completion”. None the less, these errors will happen and I do […]

  8. An Exercise in Irrelevance » Blog Archive » Fixing Emacs show-paren mode says:

    […] been writing a lot of lisp recently, both to extend my Emacs environment for OWL (http://www.russet.org.uk/blog/2161), and with my Clojure OWL library (http://www.russet.org.uk/blog/2254). I have been trying out two […]

  9. An Exercise in Irrelevance » Blog Archive » Simple HTML says:

    […] to server-side PHP generation. As an example, for instance, you can see the SimpleHTML for a recent article here. Metadata added via kblog-metadata (http://www.russet.org.uk/blog/2025) is still present, but […]

  10. Johan W. Klüwer says:

    Using Emacs for ontology authoring while remaining with reasoner support sounds excellent. I look forward to trying out the Tawny-OWL tools.

    However, on a smaller scale: You mention in this post a pre-processor for omn-mode to expand Alias declarations on saving/exporting. Have you actually published such a thing, preferably one that wouldn’t require the full Clojure environment (i.e., in elisp)?

    Having aliases available in Manchester Syntax would be extremely useful, not just for “semantics-free” identifiers but also for working with abbreviated and more readable class names.

  11. Phil Lord says:

    Unfortunately, I never got around to. Even omn-mode.el is languishing a bit; there are some known bugs in fontification that I haven’t fixed yet. In the end, I have decided that tawny is the way to go; I’d need to write a pile of tools (for example for syntax checking) to get direct omn-mode.el editing of ontologies plausible. As I would do this in clojure these days, you’d still need it. The other problem is that, while Manchester syntax is convienient for editing, it’s hard to parse; so the OWL API doesn’t always get it right.

    Nowadays, I pretty much use omn-mode.el for checking that tawny has done the right thing.

    Installing clojure is not that hard, BTW. You drop the leiningen shell file/batch file somewhere, and run it, and you are done. I do realise that using a new language is not a trivial endeavour, though.

  12. Johan W. Klüwer says:

    Well, this makes sense — I’ll try the tawny way. Thanks!

Leave a Reply