[][src]Crate horned_functional

horned-functional Star me

An OWL2 Functional-style Syntax parser for horned-owl

TravisCI Codecov License Source Crate Documentation Changelog GitHub issues

Overview

This library provides an OWL Functional-style parser implementation for the horned-owl library, which provides the complete OWL2 model as a Rust library.

The parser is implemented as a pest parser, using a translation of the BNF grammar. It provides spanned errors to easily identify the faulty parts of an invalid OWL2 document.

All OWL2 entities also receive an implementation of FromFunctional, which can be used to deserialize each entity independently from their functional syntax representation. Since the deserialization is context-dependent when not considering the entire document, it is possible to provide a custom prefix mapping to handle compact identifiers in situations where one is needed.

Usage

Add horned-owl and horned-functional to the [dependencies] sections of your Cargo.toml manifest:

[dependencies]
horned-functional = "0.1.0"

The from_reader function is the easiest way to deserialize an OWL Functional document from a Read implementor:

extern crate ureq;
extern crate horned_functional;

fn main() {
    let url = "https://raw.githubusercontent.com/ha-mo-we/Racer/master/examples/owl2/owl-primer-mod.ofn";

    let response = ureq::get(url).call();
    let mut reader = response.into_reader();

    match horned_functional::from_reader(reader) {
      Ok((ont, _)) => println!("Number of axioms: {}", ont.iter().count()),
      Err(e) => panic!("could not parse document: {}", e)
    };
}

Feedback

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker of the project if you need to report or ask something. If you are filling in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

About

This project was developed by Martin Larralde as part of a Master's Degree internship in the BBOP team of the Lawrence Berkeley National Laboratory, under the supervision of Chris Mungall.

Enums

Error

The error type for this crate.

Traits

FromFunctional

A trait for OWL elements that can be deserialized from OWL strings.

Functions

from_file

Parse an entire OWL document from a file on the local filesystem..

from_reader

Parse an entire OWL document from a Read implementor.

from_str

Parse an entire OWL document from a string.

Type Definitions

Result

The result type for this crate.