Skip to content

Commit

Permalink
Add initial data model for SWRL
Browse files Browse the repository at this point in the history
No support has been added to parsers yet, so this does not test or
fully compile.
  • Loading branch information
phillord committed Feb 13, 2024
1 parent e15fae2 commit 4b1a2ca
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ pub trait Kinded {
fn kind(&self) -> ComponentKind;
}

#[derive(Eq, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub enum HigherKind {
Axiom,
Meta,
Expand Down Expand Up @@ -1343,10 +1343,14 @@ components! {
Axiom AnnotationPropertyRange {
ap: AnnotationProperty<A>,
iri: IRI<A>
},

SWRL Rule {
head: Vec<Atom<A>>,
body: Vec<Atom<A>>
}
}


// TODO
impl<A:ForIRI> Default for OntologyID<A> {
fn default() -> Self {
Expand Down Expand Up @@ -1721,6 +1725,23 @@ impl<A: ForIRI> From<Class<A>> for Box<ClassExpression<A>> {
}
}

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Atom<A>{
DescriptionAtom(IObject<A>),
DataRangeAtom(DObject<A>),
IndividualValuedPropertyID(IObject<A>, IObject<A>),
DataValuedPropertyID(IObject<A>, DObject<A>),
SameAsAtom(IObject<A>, IObject<A>),
DifferentFromAtom(IObject<A>, IObject<A>),
BuiltInAtom(IRI<A>, DObject<A>),
}

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct IObject<A>(IRI<A>);

#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct DObject<A>(IRI<A>);

/// Access or change the `OntologyID` of an `Ontology`
pub trait Ontology<A> {
}
Expand Down Expand Up @@ -1919,4 +1940,19 @@ mod test {
let oxiri = iri.as_oxiri().unwrap();
assert_eq!(oxiri.authority(), Some("www.example.com"));
}


#[test]
fn test_axiom_kinded() {
let b = Build::new_rc();

let iri = b.iri("http://www.example.com");
let r = Rule{
head: vec![Atom::DescriptionAtom(IObject(iri))],
body: vec![Atom::DescriptionAtom(IObject(iri))],
};

assert_eq!(r.higher_kind(), HigherKind::SWRL);
}

}

0 comments on commit 4b1a2ca

Please sign in to comment.