Scowl: a Scala DSL for programming with the OWL API

James P. BalhoffJ. Open Source Softw 2016 · DBLP

Abstract

Scowl is a Scala-based domain-specific language (DSL) designed to simplify interactions with the Java OWL API. By providing a declarative syntax and leveraging Scala's functional features like pattern matching and extension methods, Scowl enhances the readability and maintainability of ontology engineering tasks. This paper describes the implementation and primary use cases of Scowl in the context of Semantic Web and bioinformatics research.

Introduction

In the Semantic Web and bioinformatics domains, the Web Ontology Language (OWL) serves as the standard for defining complex relationships between concepts. However, programmatically interacting with these ontologies via the standard Java OWL API is often cumbersome. The native API's verbose and imperative nature makes writing and maintaining code for deeply nested logical expressions difficult.

Researchers frequently perform "ontology engineering" tasks, such as converting massive spreadsheets into formal axioms or auditing existing ontologies for errors. Doing this in pure Java often results in boilerplate code that obscures the underlying logic. Scowl addresses these challenges by wrapping the Java API in a Scala-based syntax that aligns more closely with how ontologists conceptualize data.

Implementation and Features

Scowl is implemented as an internal DSL within the Scala programming language, utilizing several language features to improve the developer experience:

  • Extension Methods: Scowl adds functionality to existing Java OWL API objects without requiring modifications to the original library. This allows developers to call Scowl-specific methods directly on standard OWL objects.
  • Dual Syntax Support: It supports both Manchester Syntax (a readable "pseudo-English" style) and OWL Functional Syntax (mirroring the formal OWL 2 specification).
  • Declarative Style: Instead of writing step-by-step instructions to build an object, developers can define the structure of the OWL construct in a single, readable block of code.
  • Pattern Matching: By leveraging Scala’s native pattern matching, Scowl allows for concise deconstruction and querying of OWL objects, offering a more streamlined alternative to the traditional Java "Visitor" pattern.

Applications and Use Cases

Scowl is particularly effective in environments like the Open Biomedical Ontologies (OBO) library, where complex ontology engineering is frequent. The library facilitates three primary use cases:

  1. Data Ingest: Programmatically converting tabular data (e.g., CSV or Excel files) into complex OWL axioms.
  2. Axiom Generation: Creating new ontology content based on existing patterns or data structures.
  3. Reporting and Auditing: Using pattern matching to scan ontologies to extract specific information or identify modeling inconsistencies.

Because Scowl is a thin wrapper around the standard Java OWL API, it maintains full compatibility with existing Java-based reasoners (such as Pellet or HermiT) and tools, allowing it to be integrated into existing workflows without reinventing core functionality.

Conclusion

By bridging the gap between programmatic data processing and formal logic-based modeling, Scowl significantly reduces code verbosity and increases the maintainability of ontology-driven software. While it requires familiarity with Scala, its interoperability with the Java ecosystem makes it a powerful tool for the Semantic Web community. Future work involves maintaining compatibility with evolving Java OWL API and Scala versions to ensure long-term utility in the field.

Summary updated

BibTeX
@article{balhoff2016scowl,
  author = {James P. Balhoff and James Balhoff},
  title = {{Scowl: a Scala DSL for programming with the OWL API}},
  journal = {J. Open Source Softw.},
  year = {2016},
  doi = {10.21105/joss.00023},
}
Figure