diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..6f5425ea --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +--- +# CI configuration +# https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven + +name: Java CI + +on: +- push + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + java: + - 11.0.21 + - 17.0.9 + - 21.0.1 + steps: + - name: Check out + uses: actions/checkout@v4 + - name: Set up Java + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: temurin + - name: Build + run: mvn --batch-mode --update-snapshots --show-version install + + diff --git a/.gitignore b/.gitignore index 7d8d822e..cbf65870 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,14 @@ target/ +out/ .settings/ +.gradle/ .project .classpath .idea/ +.bsp/ *.iml .DS_Store Thumbs.db +.cache +.cache-main +.cache-tests diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 2390719c..00000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,21 +0,0 @@ - -# -# Configuration file for Scrutinizer -# https://scrutinizer-ci.com/ -# - - -checks: - java: true - -build: - environment: - java: java-8-oracle - - nodes: - analysis: - tests: - override: - - java-scrutinizer-run - - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0c7d264e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ - -# -# Configuration file for Travis CI -# https://travis-ci.org/ -# - -language: java - -jdk: - - openjdk8 - - openjdk11 - - oraclejdk8 - - oraclejdk11 - -install: - - mvn install -DskipTests=true -Dmaven.javadoc.skip=false -B -V - -after_success: - - mvn clean cobertura:cobertura coveralls:report - -sudo: false - - diff --git a/README.md b/README.md deleted file mode 100644 index b24a813a..00000000 --- a/README.md +++ /dev/null @@ -1,203 +0,0 @@ -# [jcel](https://julianmendez.github.io/jcel/) - -[![build](https://travis-ci.org/julianmendez/jcel.png?branch=master)](https://travis-ci.org/julianmendez/jcel) -[![maven central](https://maven-badges.herokuapp.com/maven-central/de.tu-dresden.inf.lat.jcel/jcel-parent/badge.svg)](https://search.maven.org/#search|ga|1|g%3A%22de.tu-dresden.inf.lat.jcel%22) -[![scrutinizer](https://scrutinizer-ci.com/g/julianmendez/jcel/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/julianmendez/jcel/?branch=master) -[![license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.txt) -[![license](https://img.shields.io/badge/license-LGPL%203.0-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0.txt) -[![download](https://img.shields.io/sourceforge/dm/jcel.svg)](http://sourceforge.net/projects/jcel/files/) -[![follow](https://img.shields.io/twitter/follow/jcelreasoner.svg?style=social)](https://twitter.com/jcelreasoner) - - -**jcel** is a reasoner for the [description logic](http://dl.kr.org) EL+. It uses the [OWL API](https://owlcs.github.io/owlapi/) and can be used as a plug-in for [Protege](https://protege.stanford.edu/). - - -## Download - -* [all-in-one ZIP file](https://sourceforge.net/projects/jcel/files/jcel/0.24.1/zip/jcel-0.24.1.zip/download) -* [The Central Repository](https://repo1.maven.org/maven2/de/tu-dresden/inf/lat/jcel/) -* [older releases](https://sourceforge.net/projects/jcel/files/) -* as dependency: - -```xml - - de.tu-dresden.inf.lat.jcel - jcel-owlapi - 0.24.1 - -``` - - -## Author - -[Julian Mendez](https://julianmendez.github.io) - - -## Licenses - -[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt), [LGPL 3.0](https://www.gnu.org/licenses/lgpl-3.0.txt) - - -## Main features - -* is an [OWL 2 EL](https://www.w3.org/2007/OWL/wiki/OWL_Working_Group) reasoner (albeit currently with some limitations) -* uses the [OWL API](http://owlapi.sourceforge.net) -* can be used in [Protégé](https://protege.stanford.edu) -* is free software and is licensed under [GNU Lesser General Public License version 3](https://www.gnu.org/licenses/lgpl.txt) and [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) -* is fully implemented in [Java](https://www.oracle.com/java/technologies/java-se.html) -* evaluated by the [SEALS Community](https://www.seals-project.eu/news/storage-and-reasoning-systems-news) having the lowest Average Reasoning Time in 2010 - - -## Suggested technologies - -* [Java Development Kit 8](https://java.sun.com/) (or higher) -* [Apache Maven 3.0.3](https://maven.apache.org/) (or higher) -* [Eclipse Mars](https://www.eclipse.org/) (or higher) - - -## Source code - -The project is hosted on [GitHub](https://github.com/julianmendez/jcel). To checkout and compile the project with [Apache Maven](https://maven.apache.org/): - -``` -$ git clone https://github.com/julianmendez/jcel.git -$ cd jcel -$ mvn clean install -``` - -The library, its sources and its Javadoc will be in `jcel-library/target`, the plug-in will be in `jcel-plugin/target`, the standalone will be in `jcel-standalone/target`, and the release ZIP file will be in `target`. - -To compile the project offline, first download the dependencies: - -``` -$ mvn dependency:go-offline -``` - -and once offline, use: - -``` -$ mvn --offline clean install -``` - -The bundles uploaded to [Sonatype](https://oss.sonatype.org/) are created with: - -``` -$ mvn clean install -DperformRelease=true -``` - -and then on each module: - -``` -$ cd target -$ jar -cf bundle.jar jcel-* -``` - -and on the main directory: - -``` -$ cd target -$ jar -cf bundle.jar jcel-parent-* -``` - -The version number is updated with: - -``` -$ mvn versions:set -DnewVersion=NEW_VERSION -``` - -where *NEW_VERSION* is the new version. -The file [VersionInfo.java](https://github.com/julianmendez/jcel/blob/master/jcel-reasoner/src/main/java/de/tudresden/inf/lat/jcel/reasoner/main/VersionInfo.java) is updated manually. - - -## Architecture - -### Modules - -The version under development has the following modules: - -* **jcel-coreontology** : set of normalized axioms -* **jcel-core** : classification algorithms using only normalized axioms -* **jcel-ontology** : set of all possible axioms and a procedure to normalize them -* **jcel-reasoner** : reasoner that can classify an ontology and can compute entailment -* **jcel-owlapi** : OWL API interface, performs the translation between the OWL API axioms and jcel axioms -* **jcel-protege** : module to connect to Protégé - -It also has the following module used to build the release: - -* **jcel-library** : module to create the library, its sources and its javadoc -* **jcel-plugin** : module to create the jar for Protégé -* **jcel-standalone** : module to create the standalone application -* **jcel-distribution** : module to create the release, a single ZIP file - - -### Algorithm - -* translate OWL API axioms into jcel axioms, which are composed by integer numbers -* detect the expressivity used in the axioms -* apply normalization rules to the set of axioms, producing a set of normalized axioms and auxiliary entities if necessary -* saturate the set of normalized axioms with deduced object property axioms -* create an extended ontonlogy based on the set of normalized axioms -* apply the completion rules while there is some change in the affected sets -* remove the auxiliary entities -* build a graph containing direct subsumers (parents), direct subsumees (children) and equivalents -* create OWL API data structures based on the jcel's integer representation - - -### Package dependencies - -If we consider each package as a node, and each dependency between two packages as a directed edge, the structure of package dependency should be a directed acyclic graph (DAG). The packages should only make public those classes that are or could be used by another package preserving the DAG structure. - - -## Example - -This [file](https://github.com/julianmendez/jcel/blob/master/docs/data/start-jcel.sh.txt) is an example of how to start jcel. - -This [file](https://github.com/julianmendez/jcel/blob/master/docs/data/example.owl) is an example ontology using ELHIfR+. - -Ontologies: - -* [Gene Ontology](http://www.geneontology.org/): input [owl](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/geneontology.owl.zip) [krss](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/go.cel.zip), output [xml](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/geneontology-inferred-0.12.0.xml.zip) -* [NCI Thesaurus](https://ncit.nci.nih.gov/ncitbrowser/): input [owl](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/nci.owl.zip), output [xml](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/nci-inferred-0.12.0.xml.zip) -* [CEL GALEN](http://www.opengalen.org/): input [owl](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/celgalen.owl.zip) [krss](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/celgalen.cel.zip), output [xml](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/celgalen-inferred-0.12.0.xml.zip) -* Not GALEN: input [owl](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/notgalen.owl.zip) [krss](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/notgalen.cel.zip), output [xml](https://lat.inf.tu-dresden.de/systems/jcel/ontologies/notgalen-inferred-0.12.0.xml.zip) -* [Foundational Model of Anatomy](http://sig.biostr.washington.edu/projects/fm/) -* [SNOMED CT](http://www.ihtsdo.org/our-standards/) - - -## Release notes -See [release notes](https://julianmendez.github.io/jcel/RELEASE-NOTES.html). - - -## Older versions - -* [Git SHA](https://github.com/julianmendez/jcel/blob/master/docs/data/gitsha.txt) -* [old SVN revision](https://github.com/julianmendez/jcel/blob/master/docs/data/svnrev.txt) -* [releases](https://sourceforge.net/projects/jcel/files/) - - -## More information - -* [Frequently Asked Questions](https://julianmendez.github.io/jcel/docs/faq.html) - - -## References - -* Theoretical foundation: - * [Master's thesis by J. A. Mendez](https://lat.inf.tu-dresden.de/research/mas/Men-Mas-11.pdf) - * [Master's thesis by Q. H. Vu](https://lat.inf.tu-dresden.de/research/mas/Vu-Mas-08.pdf) - * [Ph.D. thesis by B. Suntisrivaraporn](https://lat.inf.tu-dresden.de/research/phd/Sun-PhD-09.pdf) -* CEL: [main page](https://lat.inf.tu-dresden.de/systems/cel) - [source code](https://github.com/julianmendez/cel) -* OWL API: [main page](http://owlapi.sourceforge.net/) - [examples](http://owlapi.sourceforge.net/documentation.html) — [javadoc](http://owlapi.sourceforge.net/javadoc) -* OWL 2: [OWL Working Group](https://www.w3.org/2007/OWL/wiki/OWL_Working_Group) - - -## Support - -Any bug or unexpected behavior can be directly reported by sending a message to the author. Questions and suggestions are also very welcome. - - -## News -[@jcelreasoner](https://twitter.com/jcelreasoner) - - - diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md deleted file mode 100644 index 8896a246..00000000 --- a/RELEASE-NOTES.md +++ /dev/null @@ -1,454 +0,0 @@ - -## Release notes - -| version | release date | Java | OWL API | Protégé | -|:--------|:-------------|:----:|:--------------|:--------------| -| v0.25.0 | (unreleased) | 8 | 5.0.0 | (TBD) | -| v0.24.1 | 2017-04-28 | 8 | 4.2.8 | 5.2.0 | -| v0.24.0 | 2016-07-08 | 8 | 4.2.5 | 5.0.0 | -| v0.23.2 | 2015-12-24 | 7 | 4.1.3 | 5.0.0-beta-21 | -| v0.23.1 | 2015-12-23 | 7 | 3.5.1 | 5.0.0-beta-17 | -| v0.23.0 | 2015-11-30 | 7 | 4.1.3 | 5.0.0-beta-21 | -| v0.22.0 | 2015-08-24 | 7 | 3.5.1 | 5.0.0-beta-17 | -| v0.21.0 | 2015-04-13 | 7 | 3.5.0 | 4.3.0 | -| v0.20.0 | 2014-05-18 | 7 | 3.5.0 | 4.3.0 | -| v0.19.1 | 2013-07-16 | 6 | 3.4.4 | 4.1.0 | -| v0.19.0 | 2013-06-25 | 6 | 3.4.4 | 4.1.0 | -| v0.18.2 | 2013-03-05 | 6 | 3.4.2 | 4.1.0 | -| v0.18.1 | 2013-02-14 | 6 | 3.4.2 | 4.1.0 | -| v0.18.0 | 2012-12-02 | 6 | 3.4.1 | 4.1.0 | -| v0.17.1 | 2012-05-04 | 6 | 3.2.4 | 4.1.0 | -| v0.17.0 | 2012-04-16 | 6 | 3.2.4 | 4.1.0 | -| v0.16.1 | 2012-01-09 | 6 | 3.2.4 | 4.1.0 | -| v0.16.0 | 2011-10-31 | 6 | 3.2.4 | 4.1.0 | -| v0.15.0 | 2011-07-11 | 6 | 3.2.3 | 4.1.0 | -| v0.14.0 | 2011-04-01 | 6 | 2.2.0 , 3.2.2 | 4.1.0 | -| v0.13.0 | 2011-03-11 | 6 | 2.2.0 , 3.2.2 | 4.1.0 | -| v0.12.0 | 2011-03-01 | 6 | 2.2.0 , 3.2.2 | 4.1.0 | -| v0.11.0 | 2011-01-01 | 6 | 2.2.0 , 3.1.0 | 4.1.0 | -| v0.10.0 | 2010-11-01 | 6 | 2.2.0 , 3.1.0 | 4.1.0 | -| v0.9.0 | 2010-10-28 | 6 | 2.2.0 , 3.0.0 | 4.0.2 | -| v0.8.0 | 2010-04-30 | 6 | 2.2.0 , 3.0.0 | 4.0.2 | -| v0.7.0 | 2010-04-14 | 6 | 2.2.0 , 3.0.0 | 4.0.2 | -| v0.6.0 | 2010-03-23 | 6 | 2.2.0 , 3.0.0 | 4.0.2 | -| v0.5.0 | 2010-02-26 | 6 | 2.2.0 | 4.0.2 | - - - -### v0.25.0 -*(unreleased)* -* uses the OWL API 5.0.0 -* build commands: -``` -$ mvn clean install -``` -* release: `target/jcel-0.25.0.zip` -* plug-in: `jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.25.0.jar` - - -### v0.24.1 -*2017-04-28* -* uses the OWL API 4.2.8 -* can be used as a plug-in for Protégé 5.2.0 -* build commands: -``` -$ mvn clean install -``` -* release: `target/jcel-0.24.1.zip` -* plug-in: `jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.24.1.jar` - - -### v0.24.0 -*(2016-07-08)* -* runs on Java 8 -* uses the OWL API 4.2.5 -* can be used as a plug-in for Protégé 5.0.0 -* fixes module extractor -* improves annotations in normalized axioms -* build commands: -``` -$ mvn clean install -``` -* release: `target/jcel-0.24.0.zip` -* plug-in: `jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.24.0.jar` - - -### v0.23.2 -*(2015-12-24)* -* uses the OWL API 4.1.3 -* can be used as a plug-in for Protégé 5.0.0-beta-21 -* build commands: -``` -$ mvn clean install -``` -* release: `target/jcel-0.23.2.zip` -* plug-in: `jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.23.2.jar` - - -### v0.23.1 -*(2015-12-23)* -* uses the OWL API 3.5.1 -* can be used as a plug-in for Protégé 5.0.0-beta-17 -* build commands: -``` -$ mvn clean install -``` -* release: `target/jcel-0.23.1.zip` -* plug-in: `jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.23.1.jar` - - -### v0.23.0 -*(2015-11-30)* -* does not longer have [Apache Ant + Apache Ivy](https://ant.apache.org/ivy/) build files -* uses the OWL API 4.1.3 -* can be used as a plug-in for Protégé 5.0.0-beta-21 -* the plug-in for Protégé can be used as a library -* the module `jcel-build` has been removed -* build commands: -``` -$ mvn clean install -``` -* release: `target/jcel-0.23.0.zip` -* plug-in: `jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.23.0.jar` - - -### v0.22.0 -*(2015-08-24)* -* POM files changed: the new `groupId` is `de.tu-dresden.inf.lat.jcel` -* includes Maven POM files to be deployed in [Sonatype](https://oss.sonatype.org/) -* is available at [The Central Repository](https://repo1.maven.org/maven2/de/tu-dresden/inf/lat/jcel/) -* module `jcel-build` contains only [Apache Ant + Apache Ivy](https://ant.apache.org/ivy/) configuration files, and its submodules became modules: - * `jcel-library` : creates the library - * `jcel-plugin` : creates the plug-in for Protégé - * `jcel-standalone` : creates a standlone application - * `jcel-distribution` : creates the release -* uses the OWL API 3.5.1, and can be used as a plug-in for Protégé 5.0.0-beta-17 -* build commands: -``` -$ mvn clean install -``` -* release: `target/jcel-0.22.0.zip` -* plug-in: `jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.22.0.jar` -* or -``` -$ ant -``` -* release: `jcel-build/target/jcel-0.22.0.zip` -* plug-in: `jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.22.0.jar` - - -### v0.21.0 -*(2015-04-13)* -* normalizes the ontology propagating the annotations -* build commands: -``` -$ cd jcel -$ mvn clean install -``` -* or -``` -$ cd jcel -$ ant -``` -* release: `jcel/jcel-build/target/jcel-0.21.0.zip` -* plug-in: `jcel/jcel-build/jcel-plugin/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.20.0 -*(2014-05-18)* -* uses [Apache Ivy](https://ant.apache.org/ivy/) to compile the project -* build commands: -``` -$ cd jcel/jcel-build -$ ant -``` -* release: `jcel/jcel-build/target/jcel-0.20.0.zip` -* plug-in: `jcel/jcel-build/plugin/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.19.1 -*(2013-07-16)* -* includes a configurable timeout for the classification phase -* build commands: -``` -$ cd jcel/jcel-build -$ ant -``` -* release: `jcel/jcel-build/target/jcel-0.19.1.zip` -* plug-in: `jcel/jcel-build/plugin/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.19.0 -*(2013-06-25)* -* is dual-licensed, i.e. released under two different licenses: [GNU Lesser General Public License version 3](https://www.gnu.org/licenses/lgpl-3.0.txt) and [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) -* has subprojects with a different name convention: they use hyphen ("`jcel-`") instead of dot ("`jcel.`") -* shows a progress monitor when executed in Protégé -* includes new parameters in the console mode, including consistency, sat, classification, and entailment -* uses OWL API 3.4.4 and JUnit 4.11 -* build commands: -``` -$ cd jcel/jcel-build -$ ant -``` -* release: `jcel/jcel-build/target/jcel-0.19.0.zip` -* plug-in: `jcel/jcel-build/plugin/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.18.2 -*(2013-03-05)* -* fixes a bug in processing Nothing (bottom class) -* performs a faster classification of small ontologies -* build commands: -``` -$ cd jcel/jcel.build -$ ant -``` -* release: `jcel/jcel.build/target/jcel-0.18.2.zip` -* plug-in: `jcel/jcel.build/plugin/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.18.1 -*(2013-02-14)* -* fixes a bug in the retrieval of subclasses and superclasses of Nothing (bottom class) and Thing (top class) -* build commands: -``` -$ cd jcel/jcel.build -$ ant -``` -* release: `jcel/jcel.build/target/jcel-0.18.1.zip` -* plug-in: `jcel/jcel.build/plugin/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.18.0 -*(2012-12-02)* -* classifies faster and using less memory -* fixes a bug in entailment of subclasses -* uses a more efficient way of processing the S-entries and R-entries -* has a single subproject for the build process, `jcel.build`, which includes the following subdirectories: - * `jars` : contains the external jars needed by the build - * `library` : creates the library - * `plugin` : creates the plug-in for Protégé - * `standalone` : creates a standlone application -* build commands: -``` -$ cd jcel/jcel.build -$ ant -``` -* release: `jcel/jcel.build/target/jcel-0.18.0.zip` -* plug-in: `jcel/jcel.build/plugin/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.17.1 -*(2012-05-04)* -* corrects the retrieval of equivalent classes -* excludes the original class when computing ancestors and descendants -* includes new unit tests in `jcel.reasoner` and `jcel.core` -* build commands: -``` -$ cd jcel/jcel.distribution -$ ant -``` -* release: `jcel/jcel.distribution/target/jcel-0.17.1.zip` -* plug-in: `jcel/jcel.bundle/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.17.0 -*(2012-04-16)* -* has a more efficient use of memory -* has the following modules: - * `jcel.coreontology` : set of normalized axioms - * `jcel.core` : classification algorithms using only normalized axioms - * `jcel.ontology` : set of all possible axioms and a procedure to normalize them - * `jcel.reasoner` : reasoner that can classify an ontology and can compute entailment - * `jcel.owlapi` : OWL API 3.2.4 interface, performs the translation between the OWL API axioms and jcel axioms - * `jcel.protege` : module to connect to Protégé -and the following modules are used to build the release: - * `jcel.jars` : local repository of required jars - * `jcel.bundle` : module to create the bundle, i.e., the jar for Protégé - * `jcel.distribution` : module to produce the release, which includes libs, javadoc, sources, and the bundle -* build commands: -``` -$ cd jcel/jcel.distribution -$ ant -``` -* release: `jcel/jcel.distribution/target/jcel-0.17.0.zip` -* plug-in: `jcel/jcel.bundle/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.16.1 -*(2012-01-09)* -* fixes a bug in entailment present in version 0.16.0 -* build commands: -``` -$ cd jcel/jcel.protege -$ ant -buildfile build-bundle.xml -``` -* release: `jcel/jcel.protege/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.16.0 -*(2011-10-31)* -* can answer complex queries -* has a new package in `jcel.core` (reasoner) to answer the queries, changing the interface between `jcel.owlapi` and `jcel.core` -* has unique identifiers in the core managed by a factory, making extension and debugging easier -* build commands: -``` -$ cd jcel/jcel.protege -$ ant -buildfile build-bundle.xml -``` -* release: `jcel/jcel.protege/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.15.0 -*(2011-07-11)* -* breaks the backwards compatibility with OWL API 2.2.0 -* cannot be used in Protégé 4.0.2 -* uses a new module called `jcel.ontology` which contains the axioms extracted from the core, therefore the modules are: - * `jcel.ontology`: interfaces and classes to manage an internal representation of axioms and ontologies - * `jcel.core`: interfaces and classes implementing the algorithms used by the reasoner - * `jcel.owlapi`: interfaces and classes connecting with the OWL API 3.2.3 - * `jcel.protege`: interfaces and classes connecting with Protege 4.1 (build 235) -* build commands: -``` -$ cd jcel/jcel.protege -$ ant -buildfile build-bundle.xml -``` -* release: `jcel/jcel.protege/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.14.0 -*(2011-04-01)* -* is identical to v0.13.0 in the Java source code, but is created using a different repository structure. -* can be compiled using [Apache Maven](https://maven.apache.org/). -* build commands: -``` -$ cd jcel/protege -$ ant -buildfile build-bundle.xml -``` -* release: `jcel/protege/target/de.tudresden.inf.lat.jcel.jar` - - -### v0.13.0 -*(2011-03-11)* -* classifies ELHIfR+ using less memory -* build commands: -``` -$ cd jcel-jars -$ ant -``` -* release: `de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - -### v0.12.0 -*(2011-03-01)* -* can classify the description logic ELHIfR+ -* uses the OWL API 3.2.3 and can be used in Protégé 4.1 beta (build 218) -* can classify SNOMED CT faster -* build commands: -``` -$ cd jcel-jars -$ ant -``` -* release: `de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - -### v0.11.0 -*(2011-01-01)* -* includes a rule-based algorithm -* can classify SNOMED CT faster -* build commands: -``` -$ cd jcel-jars -$ ant -``` -* release: `de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - -### v0.10.0 -*(2010-11-01)* -* is compatible with the OWL API 3.1.0, and still with the OWL API 2.2.0, but not with the OWL API 3.0.0 -* can still be used in Protégé 4.0.2 and in Protégé 4.1 beta (build 213) -* build commands: -``` -$ cd jcel-jars -$ ant -``` -* release: `de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - -### v0.9.0 -*(2010-10-28)* -* has a check for non-nullity for every public method -* is a little faster -* has a smaller output avoiding singletons for equivalent classes and equivalent object properties -* can still be used in Protégé 4.0.2 and in Protégé 4.1 (up to build 206) -* build commands: -``` -$ cd jcel-jars -$ ant -``` -* release: `de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - -### v0.8.0 -*(2010-04-30)* -* includes a module processor which divides a set of axioms in modules -* has an improved interface in the core which simplifies its extension -* build commands: -``` -$ cd jcel-jars -$ ant -``` -* release: `de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - -### v0.7.0 -*(2010-04-14)* -* can be used in Protégé 4.0.2 and in Protégé 4.1 (build 102) -* has improvements in the core to reduce the use of memory -* generates an inferred ontology that is compatible with the OWL 2 specification -* can classify large ontologies like SNOMED CT -* build commands: -``` -$ cd jcel-jars -$ ant -``` -* release: `de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - -### v0.6.0 -*(2010-03-23)* -* passes the basic tests for an OWL 2 EL reasoner (albeit currently with some limitations) -* uses the OWL API 3.0.0 -* uses an adapter to keep backward compatibility with OWL API 2.2.0 -* can be used in Protégé 4.0.2 -* has improvements in the core to reduce classification times -* has the following modules: - * `jcel-core` : core, module that makes the classification - * `jcel-owlapi` : an OWL API 3 interface, transforms data between the OWL API and the internal representation used by the core - * `jcel-adapter` : adapter to transform an OWL API 3 into an OWL API 2, it is an independent module - * `jcel-protege` : module to make jcel a plug-in for Protégé 4.0.2 -* build commands: -``` -$ cd de.tudresden.inf.lat.jcel.protege -$ ant -``` -* release: `de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - -### v0.5.0 -*(2010-02-26)* -* is the first beta version -* can be used in Protégé 4.0.2 -* uses the OWL API 2.2.0 -* has the following modules: - * `jcel-core` : core - * `jcel-protege` : module to make jcel a plug-in for Protégé 4.0.2 -* build commamds: -``` -$ cd de.tudresden.inf.lat.jcel -$ ant -``` -* release: `de.tudresden.inf.lat.jcel/dist/bundle/de.tudresden.inf.lat.jcel.jar` - - diff --git a/COPYING-LESSER.txt b/docs/COPYING-LESSER.txt similarity index 100% rename from COPYING-LESSER.txt rename to docs/COPYING-LESSER.txt diff --git a/COPYING.txt b/docs/COPYING.txt similarity index 100% rename from COPYING.txt rename to docs/COPYING.txt diff --git a/LICENSE.txt b/docs/LICENSE.txt similarity index 100% rename from LICENSE.txt rename to docs/LICENSE.txt diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..8ae86934 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,229 @@ +# [jcel](https://julianmendez.github.io/jcel/) + +[![License 1](https://img.shields.io/badge/License%201-Apache%202.0-blue.svg)][license1] +[![license 2](https://img.shields.io/badge/License%202-LGPL%203.0-blue.svg)][license2] +[![Maven Central](https://img.shields.io/maven-central/v/de.tu-dresden.inf.lat.jcel/jcel-parent.svg?label=Maven%20Central)][maven-central] +[![build](https://github.com/julianmendez/jcel/workflows/Java%20CI/badge.svg)][build-status] +[![download](https://img.shields.io/sourceforge/dm/jcel.svg)][releases] +[![follow](https://img.shields.io/twitter/follow/jcelreasoner.svg?style=social)][twitter] + +**jcel** is a reasoner for the [description logic][description-logics] EL+. It uses the [OWL +API][owl-api] and can be used as a plug-in for [Protege][protege]. + + +## Download + +* [all-in-one ZIP file][zip-file] +* [The Central Repository][central-repository] +* [all releases][releases] +* as dependency: + +```xml + + de.tu-dresden.inf.lat.jcel + jcel-owlapi + 0.24.1 + +``` + + +## Author + +[Julian Alfredo Mendez][author] + + +## Licenses + +[Apache 2.0][license1], [LGPL 3.0][license2] + + +## Main features + +* is an [OWL 2 EL][owl-2-el] reasoner (albeit currently with some limitations) +* uses the [OWL API][owl-api] +* can be used in [Protégé][protege] +* is free software and is licensed under [Apache License, Version 2.0][license1] and +[GNU Lesser General Public License version 3][license2] +* is fully implemented in [Java][java] +* evaluated by the [SEALS Community](https://web.archive.org/web/20130723132747/http://www.seals-project.eu/news/storage-and-reasoning-systems-news) having the lowest Average Reasoning Time in 2010 + + +## Suggested technologies + +* [Java Development Kit 11][java] (or higher) +* [Apache Maven 3.6.3][maven] (or higher) + + +## Source code + +The project is hosted on [GitHub][jcel-source]. +To check out and compile the project with [Apache Maven][maven]: + +``` +$ git clone https://github.com/julianmendez/jcel.git +$ cd jcel +$ mvn clean install +``` + +The library, its sources and its Javadoc will be in `jcel-library/target`, the plug-in will be in `jcel-plugin/target`, the standalone will be in `jcel-standalone/target`, and the release ZIP file will be in `target`. + +To compile the project offline, first download the dependencies: + +``` +$ mvn dependency:go-offline +``` + +and once offline, use: + +``` +$ mvn --offline clean install +``` + +The bundles uploaded to [Sonatype][sonatype] are created with: + +``` +$ mvn clean install -DperformRelease=true +``` + +and then on each module: + +``` +$ cd target +$ jar -cf bundle.jar jcel-* +``` + +and on the main directory: + +``` +$ cd target +$ jar -cf bundle.jar jcel-parent-* +``` + +The version number is updated with: + +``` +$ mvn versions:set -DnewVersion=NEW_VERSION +``` + +where *NEW_VERSION* is the new version. +The file [VersionInfo.java][jcel-version-java] is updated manually. + + +## Architecture + + +### Modules + +The version under development has the following modules: + +* **jcel-coreontology** : set of normalized axioms +* **jcel-core** : classification algorithms using only normalized axioms +* **jcel-ontology** : set of all possible axioms and a procedure to normalize them +* **jcel-reasoner** : reasoner that can classify an ontology and can compute entailment +* **jcel-owlapi** : OWL API interface, performs the translation between the OWL API axioms and jcel axioms +* **jcel-protege** : module to connect to Protégé + +It also has the following module used to build the release: + +* **jcel-library** : module to create the library, its sources and its javadoc +* **jcel-plugin** : module to create the jar for Protégé +* **jcel-standalone** : module to create the standalone application +* **jcel-distribution** : module to create the release, a single ZIP file + + +### Algorithm + +* translate OWL API axioms into jcel axioms, which are composed by integer numbers +* detect the expressivity used in the axioms +* apply normalization rules to the set of axioms, producing a set of normalized axioms and auxiliary entities if necessary +* saturate the set of normalized axioms with deduced object property axioms +* create an extended ontology based on the set of normalized axioms +* apply the completion rules while there is some change in the affected sets +* remove the auxiliary entities +* build a graph containing direct subsumers (parents), direct subsumees (children) and equivalents +* create OWL API data structures based on the jcel's integer representation + + +### Package dependencies + +If we consider each package as a node, and each dependency between two packages as a directed edge, the structure of package dependency should be a directed acyclic graph (DAG). The packages should only make public those classes that are or could be used by another package preserving the DAG structure. + + +## Example + +This [file](https://github.com/julianmendez/jcel/blob/master/docs/data/start-jcel.sh.txt) is an example of how to start jcel. + +This [file](https://github.com/julianmendez/jcel/blob/master/docs/data/example.owl) is an example ontology using ELHIfR+. + +Ontologies: + +* [Gene Ontology](http://geneontology.org/): input [owl](https://sourceforge.net/projects/jcel/files/ontologies/geneontology.owl.zip) [krss](https://sourceforge.net/projects/jcel/files/ontologies/go.cel.zip), output [xml](https://sourceforge.net/projects/jcel/files/ontologies/geneontology-inferred-0.12.0.xml.zip) +* [NCI Thesaurus](https://ncit.nci.nih.gov/ncitbrowser/): input [owl](https://sourceforge.net/projects/jcel/files/ontologies/nci.owl.zip), output [xml](https://sourceforge.net/projects/jcel/files/ontologies/nci-inferred-0.12.0.xml.zip) +* [CEL GALEN](http://www.opengalen.org/): input [owl](https://sourceforge.net/projects/jcel/files/ontologies/celgalen.owl.zip) [krss](https://sourceforge.net/projects/jcel/files/ontologies/celgalen.cel.zip), output [xml](https://sourceforge.net/projects/jcel/files/ontologies/celgalen-inferred-0.12.0.xml.zip) +* Not GALEN: input [owl](https://sourceforge.net/projects/jcel/files/ontologies/notgalen.owl.zip), output [xml](https://sourceforge.net/projects/jcel/files/ontologies/notgalen-inferred-0.12.0.xml.zip) +* [Foundational Model of Anatomy](http://si.washington.edu/projects/fma) +* [SNOMED CT](https://www.snomed.org/) + + +## Release notes +See [release notes][release-notes]. + + +## Older versions + +* [Git SHA](https://github.com/julianmendez/jcel/blob/master/docs/data/gitsha.txt) +* [old SVN revision](https://github.com/julianmendez/jcel/blob/master/docs/data/svnrev.txt) +* [releases][releases] + + +## More information + +* [Frequently Asked Questions][faq] + + +## References + +* Theoretical foundation: + * [Master's thesis by J. A. Mendez](https://lat.inf.tu-dresden.de/research/mas/Men-Mas-11.pdf) + * [Master's thesis by Q. H. Vu](https://lat.inf.tu-dresden.de/research/mas/Vu-Mas-08.pdf) + * [Ph.D. thesis by B. Suntisrivaraporn](https://lat.inf.tu-dresden.de/research/phd/Sun-PhD-09.pdf) +* CEL: [main page][cel-home] - [source code][cel-source] +* OWL API: [main page][owl-api] +* OWL 2: [OWL Working Group](https://www.w3.org/2007/OWL/wiki/OWL_Working_Group) + + +## Support + +Any bug or unexpected behavior can be directly reported by sending a message to the author. +Questions and suggestions are also very welcome. +In case you need more information, please contact [julianmendez][author]. + + +## News +[@jcelreasoner][twitter] + +[author]: https://julianmendez.github.io +[license1]: https://www.apache.org/licenses/LICENSE-2.0.txt +[license2]: https://www.gnu.org/licenses/lgpl-3.0.txt +[maven-central]: https://search.maven.org/artifact/de.tu-dresden.inf.lat.jcel/jcel-owlapi +[build-status]: https://github.com/julianmendez/jcel/actions +[central-repository]: https://repo1.maven.org/maven2/de/tu-dresden/inf/lat/jcel/ +[zip-file]: https://sourceforge.net/projects/jcel/files/jcel/0.24.1/zip/jcel-0.24.1.zip/download +[releases]: https://sourceforge.net/projects/jcel/files/ +[release-notes]: https://julianmendez.github.io/jcel/RELEASE-NOTES.html +[faq]: https://julianmendez.github.io/jcel/faq.html +[jcel-home]: https://julianmendez.github.io/jcel +[jcel-source]: https://github.com/julianmendez/jcel +[twitter]: https://twitter.com/jcelreasoner +[jcel-version-java]: https://github.com/julianmendez/jcel/blob/master/jcel-reasoner/src/main/java/de/tudresden/inf/lat/jcel/reasoner/main/VersionInfo.java +[sonatype]: https://oss.sonatype.org +[java]: https://www.oracle.com/java/technologies/ +[maven]: https://maven.apache.org +[description-logics]: http://dl.kr.org +[owl-api]: https://owlcs.github.io/owlapi/ +[owl-2-el]: https://www.w3.org/TR/owl2-profiles/#OWL_2_EL +[protege]: https://protege.stanford.edu +[cel-home]: https://julianmendez.github.io/cel +[cel-source]: https://github.com/julianmendez/cel + + diff --git a/docs/RELEASE-NOTES.md b/docs/RELEASE-NOTES.md new file mode 100644 index 00000000..90af28c8 --- /dev/null +++ b/docs/RELEASE-NOTES.md @@ -0,0 +1,373 @@ +## Release Notes +--- +- - summary: + - v0.25.0 (unreleased), Java 11, OWL API 4.5.26 , Protege 5.5.0 + - v0.24.1 (2017-04-28), Java 8, OWL API 4.2.8 , Protege 5.2.0 + - v0.24.0 (2016-07-08), Java 8, OWL API 4.2.5 , Protege 5.0.0 + - v0.23.2 (2015-12-24), Java 7, OWL API 4.1.3 , Protege 5.0.0-beta-21 + - v0.23.1 (2015-12-23), Java 7, OWL API 3.5.1 , Protege 5.0.0-beta-17 + - v0.23.0 (2015-11-30), Java 7, OWL API 4.1.3 , Protege 5.0.0-beta-21 + - v0.22.0 (2015-08-24), Java 7, OWL API 3.5.1 , Protege 5.0.0-beta-17 + - v0.21.0 (2015-04-13), Java 7, OWL API 3.5.0 , Protege 4.3.0 + - v0.20.0 (2014-05-18), Java 7, OWL API 3.5.0 , Protege 4.3.0 + - v0.19.1 (2013-07-16), Java 6, OWL API 3.4.4 , Protege 4.1.0 + - v0.19.0 (2013-06-25), Java 6, OWL API 3.4.4 , Protege 4.1.0 + - v0.18.2 (2013-03-05), Java 6, OWL API 3.4.2 , Protege 4.1.0 + - v0.18.1 (2013-02-14), Java 6, OWL API 3.4.2 , Protege 4.1.0 + - v0.18.0 (2012-12-02), Java 6, OWL API 3.4.1 , Protege 4.1.0 + - v0.17.1 (2012-05-04), Java 6, OWL API 3.2.4 , Protege 4.1.0 + - v0.17.0 (2012-04-16), Java 6, OWL API 3.2.4 , Protege 4.1.0 + - v0.16.1 (2012-01-09), Java 6, OWL API 3.2.4 , Protege 4.1.0 + - v0.16.0 (2011-10-31), Java 6, OWL API 3.2.4 , Protege 4.1.0 + - v0.15.0 (2011-07-11), Java 6, OWL API 3.2.3 , Protege 4.1.0 + - v0.14.0 (2011-04-01), Java 6, OWL API 2.2.0 and 3.2.2, Protege 4.1.0 + - v0.13.0 (2011-03-11), Java 6, OWL API 2.2.0 and 3.2.2, Protege 4.1.0 + - v0.12.0 (2011-03-01), Java 6, OWL API 2.2.0 and 3.2.2, Protege 4.1.0 + - v0.11.0 (2011-01-01), Java 6, OWL API 2.2.0 and 3.1.0, Protege 4.1.0 + - v0.10.0 (2010-11-01), Java 6, OWL API 2.2.0 and 3.1.0, Protege 4.1.0 + - v0.9.0 (2010-10-28), Java 6, OWL API 2.2.0 and 3.0.0, Protege 4.0.2 + - v0.8.0 (2010-04-30), Java 6, OWL API 2.2.0 and 3.0.0, Protege 4.0.2 + - v0.7.0 (2010-04-14), Java 6, OWL API 2.2.0 and 3.0.0, Protege 4.0.2 + - v0.6.0 (2010-03-23), Java 6, OWL API 2.2.0 and 3.0.0, Protege 4.0.2 + - v0.5.0 (2010-02-26), Java 6, OWL API 2.2.0 , Protege 4.0.2 +- - version: v0.25.0 + - date: unreleased + - features: + - uses the OWL API 4.5.26 + - build: $ `mvn clean install` + - release: target/jcel-0.25.0.zip + - plug-in: jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.25.0.jar +- - version: v0.24.1 + - date: '2017-04-28' + - features: + - uses the OWL API 4.2.8 + - can be used as a plug-in for Protege 5.2.0 + - build: $ `mvn clean install` + - release: target/jcel-0.24.1.zip + - plug-in: jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.24.1.jar +- - version: v0.24.0 + - date: '2016-07-08' + - features: + - runs on Java 8 + - uses the OWL API 4.2.5 + - can be used as a plug-in for Protege 5.0.0 + - fixes module extractor + - improves annotations in normalized axioms + - build: $ `mvn clean install` + - release: target/jcel-0.24.0.zip + - plug-in: jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.24.0.jar +- - version: v0.23.2 + - date: '2015-12-24' + - features: + - uses the OWL API 4.1.3 + - can be used as a plug-in for Protege 5.0.0-beta-21 + - build: $ `mvn clean install` + - release: target/jcel-0.23.2.zip + - plug-in: jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.23.2.jar +- - version: v0.23.1 + - date: '2015-12-23' + - features: + - uses the OWL API 3.5.1 + - can be used as a plug-in for Protege 5.0.0-beta-17 + - build: $ `mvn clean install` + - release: target/jcel-0.23.1.zip + - plug-in: jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.23.1.jar +- - version: v0.23.0 + - date: '2015-11-30' + - features: + - does not have [Apache Ant + Apache Ivy](https://ant.apache.org/ivy/) build files + - uses the OWL API 4.1.3 + - can be used as a plug-in for Protege 5.0.0-beta-21 + - the plug-in for Protege can be used as a library + - the module `jcel-build` has been removed + - build: $ `mvn clean install` + - release: target/jcel-0.23.0.zip + - plug-in: jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.23.0.jar +- - version: v0.22.0 + - date: '2015-08-24' + - features: + - POM files changed: the new `groupId` is `de.tu-dresden.inf.lat.jcel` + - includes Maven POM files to be deployed in [Sonatype](https://oss.sonatype.org/) + - is available at [The Central Repository](https://repo1.maven.org/maven2/de/tu-dresden/inf/lat/jcel/) + - module `jcel-build`: contains only [Apache Ant + Apache Ivy](https://ant.apache.org/ivy/) + configuration files, and its submodules became modules + - module `jcel-library`: creates the library + - module `jcel-plugin`: creates the plug-in for Protege + - module `jcel-standalone`: creates a standalone application + - module `jcel-distribution`: creates the release + - uses the OWL API 3.5.1, and can be used as a plug-in for Protege 5.0.0-beta-17 + - build: $ `mvn clean install` + - release: target/jcel-0.22.0.zip + - plug-in: jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.22.0.jar + - build-with-ant: $ `ant` + - release-with-ant: jcel-build/target/jcel-0.22.0.zip + - plug-in-with-ant: jcel-plugin/target/de.tu-dresden.inf.lat.jcel-0.22.0.jar +- - version: v0.21.0 + - date: '2015-04-13' + - features: + - normalizes the ontology propagating the annotations + - build: + - $ `cd jcel` + - $ `mvn clean install` + - or + - $ `cd jcel` + - $ `ant` + - release: jcel/jcel-build/target/jcel-0.21.0.zip + - plug-in: jcel/jcel-build/jcel-plugin/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.20.0 + - date: '2014-05-18' + - features: + - uses [Apache Ivy](https://ant.apache.org/ivy/) to compile the project + - build: + - $ `cd jcel/jcel-build` + - $ `ant` + - release: jcel/jcel-build/target/jcel-0.20.0.zip + - plug-in: jcel/jcel-build/plugin/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.19.1 + - date: '2013-07-16' + - features: + - includes a configurable timeout for the classification phase + - build: + - $ `cd jcel/jcel-build` + - $ `ant` + - release: jcel/jcel-build/target/jcel-0.19.1.zip + - plug-in: jcel/jcel-build/plugin/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.19.0 + - date: '2013-06-25' + - features: + - is dual-licensed, i.e. released under two different licenses, [GNU Lesser General + Public License version 3](https://www.gnu.org/licenses/lgpl-3.0.txt) and [Apache + License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + - has subprojects with a different name convention: they use hyphen ("`jcel-`") + instead of dot ("`jcel.`") + - shows a progress monitor when executed in Protege + - includes new parameters in the console mode, including consistency, sat, classification, + and entailment + - uses OWL API 3.4.4 and JUnit 4.11 + - build: + - $ `cd jcel/jcel-build` + - $ `ant` + - release: jcel/jcel-build/target/jcel-0.19.0.zip + - plug-in: jcel/jcel-build/plugin/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.18.2 + - date: '2013-03-05' + - features: + - fixes a bug in processing Nothing (bottom class) + - performs a faster classification of small ontologies + - build: + - $ `cd jcel/jcel.build` + - $ `ant` + - release: jcel/jcel.build/target/jcel-0.18.2.zip + - plug-in: jcel/jcel.build/plugin/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.18.1 + - date: '2013-02-14' + - features: + - fixes a bug in the retrieval of subclasses and superclasses of Nothing (bottom + class) and Thing (top class) + - build: + - $ `cd jcel/jcel.build` + - $ `ant` + - release: jcel/jcel.build/target/jcel-0.18.1.zip + - plug-in: jcel/jcel.build/plugin/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.18.0 + - date: '2012-12-02' + - features: + - classifies faster and using less memory + - fixes a bug in entailment of subclasses + - uses a more efficient way of processing the S-entries and R-entries + - has a single subproject for the build process, `jcel.build`, which includes + the following subdirectories + - module `jars`: contains the external jars needed by the build + - module `library`: creates the library + - module `plugin`: creates the plug-in for Protege + - module `standalone`: creates a standalone application + - build: + - $ `cd jcel/jcel.build` + - $ `ant` + - release: jcel/jcel.build/target/jcel-0.18.0.zip + - plug-in: jcel/jcel.build/plugin/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.17.1 + - date: '2012-05-04' + - features: + - corrects the retrieval of equivalent classes + - excludes the original class when computing ancestors and descendants + - includes new unit tests in `jcel.reasoner` and `jcel.core` + - build: + - $ `cd jcel/jcel.distribution` + - $ `ant` + - release: jcel/jcel.distribution/target/jcel-0.17.1.zip + - plug-in: jcel/jcel.bundle/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.17.0 + - date: '2012-04-16' + - features: + - has a more efficient use of memory + - has the following modules + - module `jcel.coreontology`: set of normalized axioms + - module `jcel.core`: classification algorithms using only normalized axioms + - module `jcel.ontology`: set of all possible axioms and a procedure to normalize + them + - module `jcel.reasoner`: reasoner that can classify an ontology and can compute + entailment + - module `jcel.owlapi`: OWL API 3.2.4 interface, performs the translation between + the OWL API axioms and jcel axioms + - module `jcel.protege`: module to connect to Protege and the following modules + are used to build the release + - module `jcel.jars`: local repository of required jars + - module `jcel.bundle`: module to create the bundle, i.e., the jar for Protege + - module `jcel.distribution`: module to produce the release, which includes libs, + javadoc, sources, and the bundle + - build: + - $ `cd jcel/jcel.distribution` + - $ `ant` + - release: jcel/jcel.distribution/target/jcel-0.17.0.zip + - plug-in: jcel/jcel.bundle/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.16.1 + - date: '2012-01-09' + - features: + - fixes a bug in entailment present in version 0.16.0 + - build: + - $ `cd jcel/jcel.protege` + - $ `ant -buildfile build-bundle.xml` + - release: jcel/jcel.protege/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.16.0 + - date: '2011-10-31' + - features: + - can answer complex queries + - has a new package in `jcel.core` (reasoner) to answer the queries, changing + the interface between `jcel.owlapi` and `jcel.core` + - has unique identifiers in the core managed by a factory, making extension and + debugging easier + - build: + - $ `cd jcel/jcel.protege` + - $ `ant -buildfile build-bundle.xml` + - release: jcel/jcel.protege/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.15.0 + - date: '2011-07-11' + - features: + - breaks the backwards compatibility with OWL API 2.2.0 + - cannot be used in Protege 4.0.2 + - uses a new module called `jcel.ontology` which contains the axioms extracted + from the core, therefore the modules are + - module `jcel.ontology`: interfaces and classes to manage an internal representation + of axioms and ontologies + - module `jcel.core`: interfaces and classes implementing the algorithms used + by the reasoner + - module `jcel.owlapi`: interfaces and classes connecting with the OWL API 3.2.3 + - module `jcel.protege`: interfaces and classes connecting with Protege 4.1 (build + 235) + - build: + - $ `cd jcel/jcel.protege` + - $ `ant -buildfile build-bundle.xml` + - release: jcel/jcel.protege/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.14.0 + - date: '2011-04-01' + - features: + - is identical to v0.13.0 in the Java source code, but is created using a different + repository structure. + - can be compiled using [Apache Maven](https://maven.apache.org/). + - build: + - $ `cd jcel/protege` + - $ `ant -buildfile build-bundle.xml` + - release: jcel/protege/target/de.tudresden.inf.lat.jcel.jar +- - version: v0.13.0 + - date: '2011-03-11' + - features: + - classifies ELHIfR+ using less memory + - build: + - $ `cd jcel-jars` + - $ `ant` + - release: de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar +- - version: v0.12.0 + - date: '2011-03-01' + - features: + - can classify the description logic ELHIfR+ + - uses the OWL API 3.2.3 and can be used in Protege 4.1 beta (build 218) + - can classify SNOMED CT faster + - build: + - $ `cd jcel-jars` + - $ `ant` + - release: de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar +- - version: v0.11.0 + - date: '2011-01-01' + - features: + - includes a rule-based algorithm + - can classify SNOMED CT faster + - build: + - $ `cd jcel-jars` + - $ `ant` + - release: de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar +- - version: v0.10.0 + - date: '2010-11-01' + - features: + - is compatible with the OWL API 3.1.0, and still with the OWL API 2.2.0, but + not with the OWL API 3.0.0 + - can still be used in Protege 4.0.2 and in Protege 4.1 beta (build 213) + - build: + - $ `cd jcel-jars` + - $ `ant` + - release: de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar +- - version: v0.9.0 + - date: '2010-10-28' + - features: + - has a check for non-nullity for every public method + - is a little faster + - has a smaller output avoiding singletons for equivalent classes and equivalent + object properties + - can still be used in Protege 4.0.2 and in Protege 4.1 (up to build 206) + - build: + - $ `cd jcel-jars` + - $ `ant` + - release: de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar +- - version: v0.8.0 + - date: '2010-04-30' + - features: + - includes a module processor which divides a set of axioms in modules + - has an improved interface in the core which simplifies its extension + - build: + - $ `cd jcel-jars` + - $ `ant` + - release: de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar +- - version: v0.7.0 + - date: '2010-04-14' + - features: + - can be used in Protege 4.0.2 and in Protege 4.1 (build 102) + - has improvements in the core to reduce the use of memory + - generates an inferred ontology that is compatible with the OWL 2 specification + - can classify large ontologies like SNOMED CT + - build: + - $ `cd jcel-jars` + - $ `ant` + - release: de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar +- - version: v0.6.0 + - date: '2010-03-23' + - features: + - passes the basic tests for an OWL 2 EL reasoner (albeit currently with some + limitations) + - uses the OWL API 3.0.0 + - uses an adapter to keep backward compatibility with OWL API 2.2.0 + - can be used in Protege 4.0.2 + - has improvements in the core to reduce classification times + - has the following modules + - module `jcel-core`: core, module that makes the classification + - module `jcel-owlapi`: an OWL API 3 interface, transforms data between the OWL + API and the internal representation used by the core + - module `jcel-adapter`: adapter to transform an OWL API 3 into an OWL API 2, + it is an independent module + - module `jcel-protege`: module to make jcel a plug-in for Protege 4.0.2 + - build: + - $ `cd de.tudresden.inf.lat.jcel.protege` + - $ `ant` + - release: de.tudresden.inf.lat.jcel.protege/dist/bundle/de.tudresden.inf.lat.jcel.jar +- - version: v0.5.0 + - date: '2010-02-26' + - features: + - is the first beta version + - can be used in Protege 4.0.2 + - uses the OWL API 2.2.0 + - has the following modules + - module `jcel-core`: core + - module `jcel-protege`: module to make jcel a plug-in for Protege 4.0.2 + - build: + - $ `cd de.tudresden.inf.lat.jcel` + - $ `ant` + - release: de.tudresden.inf.lat.jcel/dist/bundle/de.tudresden.inf.lat.jcel.jar diff --git a/_config.yml b/docs/_config.yml similarity index 100% rename from _config.yml rename to docs/_config.yml diff --git a/docs/faq.md b/docs/faq.md index b91be95a..5374ef55 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,4 +1,6 @@ + + ## Frequently asked questions @@ -37,15 +39,18 @@ jcel is able to classify description logics of the EL family. These are: * R+ : r ∘ r ⊑ r * role composition : r1 ∘ ... ∘ rn ⊑ s + #### experimental * I : r- * F : r functional * ABox : C(a), r(a,b) * O : {a} + #### planned * (D) : p(x1, ... , xn) + #### not planned * universal : ∀r.A * disjunction : A ⊔ B @@ -53,7 +58,6 @@ jcel is able to classify description logics of the EL family. These are: * N : (≤ n ) * Q : (≤ n C) - where * n : natural number, * A, B, C : concepts, @@ -63,7 +67,6 @@ where * x1, ..., xn : concrete objects - ### How can I use jcel? jcel can be used in three different ways: as a Protégé plug-in, as a standalone application, or as a library. @@ -72,5 +75,3 @@ jcel can be used in three different ways: as a Protégé plug-in, as a standalon Please refer to the download page. - - diff --git a/jcel-core/pom.xml b/jcel-core/pom.xml index 63b5a93a..4a688812 100644 --- a/jcel-core/pom.xml +++ b/jcel-core/pom.xml @@ -61,8 +61,13 @@ - junit - junit + de.tu-dresden.inf.lat.util + util-map + + + + org.junit.jupiter + junit-jupiter-api diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/cel/CelExtendedOntology.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/cel/CelExtendedOntology.java index 24f7ab0d..a538b713 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/cel/CelExtendedOntology.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/cel/CelExtendedOntology.java @@ -51,8 +51,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import de.tudresden.inf.lat.jcel.coreontology.axiom.FunctObjectPropAxiom; @@ -67,6 +67,8 @@ import de.tudresden.inf.lat.jcel.coreontology.axiom.RI2Axiom; import de.tudresden.inf.lat.jcel.coreontology.axiom.RI3Axiom; import de.tudresden.inf.lat.jcel.coreontology.axiom.RangeAxiom; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; /** * This class models an extended ontology. This is referred in the documentation @@ -76,10 +78,11 @@ */ public class CelExtendedOntology implements NormalizedIntegerAxiomVisitor { - private final Map> ohatOfClass = new HashMap<>(); - private final Map>> ohatOfExistential = new HashMap<>(); - private final Map> subPropertyAxiomSetByLeft = new HashMap<>(); - private final Map> subPropertyAxiomSetByRight = new HashMap<>(); + private final OptMap> ohatOfClass = new OptMapImpl<>(new HashMap<>()); + private final OptMap>> ohatOfExistential = new OptMapImpl<>( + new HashMap<>()); + private final OptMap> subPropertyAxiomSetByLeft = new OptMapImpl<>(new HashMap<>()); + private final OptMap> subPropertyAxiomSetByRight = new OptMapImpl<>(new HashMap<>()); /** * Constructs a new CEL extended ontology. @@ -87,24 +90,20 @@ public class CelExtendedOntology implements NormalizedIntegerAxiomVisitor()); } + this.ohatOfClass.get(classId).get().add(entry); } - private void addClassEntry(Integer classId, ExtensionEntry entry) { - addClass(classId); - this.ohatOfClass.get(classId).add(entry); - } - - private void addTo(Integer property, RI3Axiom axiom, Map> map) { - Set axiomSet = map.get(property); - if (Objects.isNull(axiomSet)) { - axiomSet = new HashSet<>(); - map.put(property, axiomSet); + private void addTo(Integer property, RI3Axiom axiom, OptMap> map) { + Optional> optAxiomSet = map.get(property); + if (!optAxiomSet.isPresent()) { + optAxiomSet = Optional.of(new HashSet<>()); + map.put(property, optAxiomSet.get()); } - axiomSet.add(axiom); + optAxiomSet.get().add(axiom); } /** @@ -126,11 +125,11 @@ public void clear() { */ public Set getClassEntries(Integer classId) { Objects.requireNonNull(classId); - Set ret = this.ohatOfClass.get(classId); - if (Objects.isNull(ret)) { - ret = Collections.emptySet(); + Optional> optSet = this.ohatOfClass.get(classId); + if (!optSet.isPresent()) { + optSet = Optional.of(Collections.emptySet()); } - return Collections.unmodifiableSet(ret); + return Collections.unmodifiableSet(optSet.get()); } /** @@ -157,10 +156,12 @@ public Set getExistentialEntries(Integer propertyId, Integer cla Objects.requireNonNull(propertyId); Objects.requireNonNull(classId); Set ret = Collections.emptySet(); - Map> map = this.ohatOfExistential.get(propertyId); - if (Objects.nonNull(map)) { - ret = map.get(classId); - if (Objects.isNull(ret)) { + Optional>> optMap = this.ohatOfExistential.get(propertyId); + if (optMap.isPresent()) { + Optional> optSet = optMap.get().get(classId); + if (optSet.isPresent()) { + ret = optSet.get(); + } else { ret = Collections.emptySet(); } } @@ -179,11 +180,11 @@ public Set getExistentialEntries(Integer propertyId, Integer cla */ public Set getSubPropertyAxiomSetByLeft(Integer elem) { Objects.requireNonNull(elem); - Set ret = this.subPropertyAxiomSetByLeft.get(elem); - if (Objects.isNull(ret)) { - ret = Collections.emptySet(); + Optional> optSet = this.subPropertyAxiomSetByLeft.get(elem); + if (!optSet.isPresent()) { + optSet = Optional.of(Collections.emptySet()); } - return Collections.unmodifiableSet(ret); + return Collections.unmodifiableSet(optSet.get()); } /** @@ -197,11 +198,11 @@ public Set getSubPropertyAxiomSetByLeft(Integer elem) { */ public Set getSubPropertyAxiomSetByRight(Integer elem) { Objects.requireNonNull(elem); - Set ret = this.subPropertyAxiomSetByRight.get(elem); - if (Objects.isNull(ret)) { - ret = Collections.emptySet(); + Optional> optSet = this.subPropertyAxiomSetByRight.get(elem); + if (!optSet.isPresent()) { + optSet = Optional.of(Collections.emptySet()); } - return Collections.unmodifiableSet(ret); + return Collections.unmodifiableSet(optSet.get()); } /** @@ -278,13 +279,19 @@ public Boolean visit(GCI3Axiom axiom) { ExtensionEntry entry = new ImplicationEntry(new HashSet<>(), axiom.getSuperClass()); Integer propertyId = axiom.getPropertyInSubClass(); Integer classId = axiom.getClassInSubClass(); - Map> map = this.ohatOfExistential.get(propertyId); - if (Objects.isNull(map)) { - map = new HashMap<>(); + Optional>> optMap = this.ohatOfExistential.get(propertyId); + OptMap> map = null; + if (optMap.isPresent()) { + map = optMap.get(); + } else { + map = new OptMapImpl<>(new HashMap<>()); this.ohatOfExistential.put(propertyId, map); } - Set set = map.get(classId); - if (Objects.isNull(set)) { + Optional> optSet = map.get(classId); + Set set = null; + if (optSet.isPresent()) { + set = optSet.get(); + } else { set = new HashSet<>(); map.put(classId, set); } diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/cel/CelProcessor.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/cel/CelProcessor.java index 70811dc7..1abc0090 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/cel/CelProcessor.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/cel/CelProcessor.java @@ -54,6 +54,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.logging.Logger; @@ -70,6 +71,8 @@ import de.tudresden.inf.lat.jcel.coreontology.axiom.RI2Axiom; import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityManager; import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityType; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; /** * Classifies an ontology using the CEL algorithm. The rules are: @@ -107,18 +110,18 @@ public class CelProcessor implements Processor { private IntegerSubsumerGraphImpl classGraph = null; private IntegerHierarchicalGraph classHierarchy = null; private IntegerHierarchicalGraph dataPropertyHierarchy = null; - private Map> directTypes = null; + private OptMap> directTypes = null; private final IntegerEntityManager entityManager; private CelExtendedOntology extendedOntology = null; private boolean isReady = false; private IntegerSubsumerGraphImpl objectPropertyGraph = null; private IntegerHierarchicalGraph objectPropertyHierarchy = null; - private Map> propertyUsedByClass = null; + private OptMap> propertyUsedByClass = null; private final Deque queueEntries = new ArrayDeque(); private final Deque queueKeys = new ArrayDeque(); private IntegerRelationMapImpl relationSet = null; - private Map> sameIndividualMap = null; - private Map> transitiveSubsumed = null; + private OptMap> sameIndividualMap = null; + private OptMap> transitiveSubsumed = null; /** * Constructs a new CEL processor. @@ -159,8 +162,8 @@ private void addToQueue(Integer className, Collection entrySet) * graph containing direct subsumers * @return a map with all the direct types for each individual. */ - private Map> computeDirectTypes(IntegerHierarchicalGraph hierarchicalGraph) { - Map> ret = new HashMap<>(); + private OptMap> computeDirectTypes(IntegerHierarchicalGraph hierarchicalGraph) { + OptMap> ret = new OptMapImpl<>(new HashMap<>()); Set individuals = getEntityManager().getEntities(IntegerEntityType.INDIVIDUAL, false); individuals.forEach(indiv -> { Set subsumers = hierarchicalGraph.getParents(getEntityManager().getAuxiliaryNominal(indiv).get()); @@ -174,8 +177,8 @@ private Map> computeDirectTypes(IntegerHierarchicalGraph h return ret; } - private Map> computeSameIndividualMap(IntegerHierarchicalGraph hierarchicalGraph) { - Map> ret = new HashMap<>(); + private OptMap> computeSameIndividualMap(IntegerHierarchicalGraph hierarchicalGraph) { + OptMap> ret = new OptMapImpl<>(new HashMap<>()); Set individuals = getEntityManager().getEntities(IntegerEntityType.INDIVIDUAL, false); individuals.forEach(indiv -> { Set equivalentClasses = hierarchicalGraph @@ -220,8 +223,8 @@ private IntegerSubsumerGraphImpl createObjectPropertyGraph(Set original return ret; } - private Map> createPropertyUseMap() { - Map> ret = new HashMap<>(); + private OptMap> createPropertyUseMap() { + OptMap> ret = new OptMapImpl<>(new HashMap<>()); getClassGraph().getElements().forEach(cA -> { Set propertySet = new HashSet<>(); getObjectPropertyGraph().getElements().forEach(r -> { @@ -240,8 +243,8 @@ private IntegerRelationMapImpl createRelationSet(Collection collection) return ret; } - private Map> createTransitiveSubsumed() { - Map> ret = new HashMap<>(); + private OptMap> createTransitiveSubsumed() { + OptMap> ret = new OptMapImpl<>(new HashMap<>()); getObjectPropertyGraph().getElements().forEach(r -> { Set related = new HashSet<>(); getObjectPropertyGraph().getElements().forEach(s -> { @@ -309,7 +312,7 @@ public Map> getDirectTypes() { if (!isReady()) { throw new UnclassifiedOntologyException(); } - return Collections.unmodifiableMap(this.directTypes); + return Collections.unmodifiableMap(this.directTypes.asMap()); } /** @@ -342,7 +345,12 @@ public NormalizedIntegerAxiomFactory getOntologyObjectFactory() { } private Set getPropertyUsedByClass(Integer cA) { - return this.propertyUsedByClass.get(cA); + Optional> optSet = this.propertyUsedByClass.get(cA); + if (optSet.isPresent()) { + return optSet.get(); + } else { + return Collections.emptySet(); + } } /** @@ -373,7 +381,7 @@ public Map> getSameIndividualMap() { if (!isReady()) { throw new UnclassifiedOntologyException(); } - return Collections.unmodifiableMap(this.sameIndividualMap); + return Collections.unmodifiableMap(this.sameIndividualMap.asMap()); } /** @@ -631,7 +639,9 @@ private void processImplication(Integer cA, ImplicationEntry eX) { } private void processNewEdge(Integer cA, Integer r, Integer cB) { - this.transitiveSubsumed.get(r).forEach(s -> { + Optional> optSet = this.transitiveSubsumed.get(r); + assert optSet.isPresent(); + optSet.get().forEach(s -> { this.relationSet.add(s, cA, cB); getPropertyUsedByClass(cB).add(s); diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/module/DefaultModuleExtractor.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/module/DefaultModuleExtractor.java index da36c1a8..af53c5dd 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/module/DefaultModuleExtractor.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/module/DefaultModuleExtractor.java @@ -49,13 +49,14 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; -import java.util.Map; -import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.TreeSet; import de.tudresden.inf.lat.jcel.coreontology.axiom.NormalizedIntegerAxiom; import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerAxiom; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; /** * An object of this class is a module extractor, i.e. it can extract a subset @@ -80,17 +81,18 @@ public DefaultModuleExtractor() { * @return a map that relates a class with the set of axioms where this * class occurs on the left side of the axiom */ - Map> buildMapOfAxioms(Set normalizedAxioms) { - Map> map = new HashMap<>(); + OptMap> buildMapOfAxioms( + Set normalizedAxioms) { + OptMap> map = new OptMapImpl<>(new HashMap<>()); normalizedAxioms.forEach(axiom -> { Set classesOnTheLeft = axiom.getClassesOnTheLeft(); classesOnTheLeft.forEach(classId -> { - Set value = map.get(classId); - if (Objects.isNull(value)) { - value = new HashSet<>(); - map.put(classId, value); + Optional> optValue = map.get(classId); + if (!optValue.isPresent()) { + optValue = Optional.of(new HashSet<>()); + map.put(classId, optValue.get()); } - value.add(axiom); + optValue.get().add(axiom); }); }); return map; @@ -107,12 +109,12 @@ Set getAxiomsWithoutEntitiesOnTheLeft(Set getAxiomsWithClassesOnTheLeft(Set classesToVisit, - Map> map) { + OptMap> map) { Set ret = new HashSet<>(); classesToVisit.forEach(classId -> { - Set newAxioms = map.get(classId); - if (Objects.nonNull(newAxioms)) { - ret.addAll(newAxioms); + Optional> optNewAxioms = map.get(classId); + if (optNewAxioms.isPresent()) { + ret.addAll(optNewAxioms.get()); } }); return ret; @@ -146,7 +148,7 @@ public Module extractModule(Collection setOfAxioms, Set< newAxioms.addAll(getAxiomsWithoutEntitiesOnTheLeft(axioms)); - Map> map = buildMapOfAxioms(axioms); + OptMap> map = buildMapOfAxioms(axioms); Set visitedClasses = new TreeSet<>(); Set classesToVisit = new TreeSet<>(); diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/ClassifierStatusImpl.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/ClassifierStatusImpl.java index 6edba3f0..1ca36ebc 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/ClassifierStatusImpl.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/ClassifierStatusImpl.java @@ -53,9 +53,9 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.TreeSet; @@ -71,6 +71,8 @@ import de.tudresden.inf.lat.jcel.coreontology.axiom.RI2Axiom; import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityManager; import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityType; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; /** * An object of this class keeps the status of the classifier. @@ -87,15 +89,15 @@ public class ClassifierStatusImpl implements ClassifierStatus { private static final int topObjectPropertyId = IntegerEntityManager.topObjectPropertyId; private IntegerSubsumerGraphImpl classGraph = null; - private final Map> cognateFunctPropMap = new HashMap<>(); + private final OptMap> cognateFunctPropMap = new OptMapImpl<>(new HashMap<>()); private final ExtendedOntology extendedOntology; private IntegerEntityManager entityManager = null; - private final Map invNodeSet = new HashMap<>(); + private final OptMap invNodeSet = new OptMapImpl<>(new HashMap<>()); private final Object monitorClassGraph = new Object(); private final Object monitorRelationSet = new Object(); private final Object monitorSetQsubR = new Object(); private final Object monitorSetQsubS = new Object(); - private final Map nodeSet = new HashMap<>(); + private final OptMap nodeSet = new OptMapImpl<>(new HashMap<>()); private IntegerSubsumerBidirectionalGraphImpl objectPropertyGraph = null; private IntegerRelationMapImpl relationSet = null; private final Set setQsubR = new TreeSet<>(); @@ -181,7 +183,11 @@ public boolean addToS(int subClass, int superClass) { @Override public boolean contains(VNode node) { Objects.requireNonNull(node); - return Objects.nonNull(this.invNodeSet.get(node)); + boolean ret = false; + if (node instanceof VNodeImpl) { + ret = this.invNodeSet.get((VNodeImpl) node).isPresent(); + } + return ret; } private void createClassGraph() { @@ -201,12 +207,12 @@ private void createMapOfObjectPropertiesWithFunctionalAncestor() { this.extendedOntology.getFunctionalObjectProperties().forEach(s -> { Collection cognates = getSubObjectProperties(s); cognates.forEach(r -> { - Set currentSet = this.cognateFunctPropMap.get(r); - if (Objects.isNull(currentSet)) { - currentSet = new HashSet<>(); - this.cognateFunctPropMap.put(r, currentSet); + Optional> optCurrentSet = this.cognateFunctPropMap.get(r); + if (!optCurrentSet.isPresent()) { + optCurrentSet = Optional.of(new HashSet<>()); + this.cognateFunctPropMap.put(r, optCurrentSet.get()); } - currentSet.addAll(cognates); + optCurrentSet.get().addAll(cognates); }); }); } @@ -233,18 +239,21 @@ private void createObjectPropertyGraph() { @Override public int createOrGetNodeId(VNode node) { Objects.requireNonNull(node); - Integer ret = this.invNodeSet.get(node); - if (Objects.isNull(ret)) { - ret = node.getClassId(); + Optional optNodeId = Optional.empty(); + if (node instanceof VNodeImpl) { + optNodeId = this.invNodeSet.get((VNodeImpl) node); + } + if (!optNodeId.isPresent()) { + optNodeId = Optional.of(node.getClassId()); if (!node.isEmpty()) { - ret = getIdGenerator().createAnonymousEntity(IntegerEntityType.CLASS, true); + optNodeId = Optional.of(getIdGenerator().createAnonymousEntity(IntegerEntityType.CLASS, true)); VNodeImpl newNode = new VNodeImpl(node.getClassId()); newNode.addExistentialsOf(node); - this.nodeSet.put(ret, newNode); - this.invNodeSet.put(newNode, ret); + this.nodeSet.put(optNodeId.get(), newNode); + this.invNodeSet.put(newNode, optNodeId.get()); } } - return ret; + return optNodeId.get(); } private void createRelationSet() { @@ -321,7 +330,7 @@ public long getDeepSizeOfS() { * @return the number of elements in the node set */ public long getDeepSizeOfV() { - return this.nodeSet.keySet().stream().map(nodeId -> this.nodeSet.get(nodeId).getDeepSize()).reduce(0L, + return this.nodeSet.keySet().stream().map(nodeId -> this.nodeSet.get(nodeId).get().getDeepSize()).reduce(0L, (accum, elem) -> (accum + elem)); } @@ -354,8 +363,13 @@ public int getInverseObjectPropertyOf(int propertyId) { } @Override - public VNode getNode(int nodeId) { - return this.nodeSet.get(nodeId); + public Optional getNode(int nodeId) { + Optional node = this.nodeSet.get(nodeId); + Optional ret = Optional.empty(); + if (node.isPresent()) { + ret = Optional.of(node.get()); + } + return ret; } /** @@ -405,13 +419,13 @@ public Collection getObjectPropertiesBySecond(int cA) { @Override public Set getObjectPropertiesWithFunctionalAncestor(int objectProperty) { - Set ret = this.cognateFunctPropMap.get(objectProperty); - if (Objects.isNull(ret)) { - ret = Collections.emptySet(); + Optional> optSet = this.cognateFunctPropMap.get(objectProperty); + if (!optSet.isPresent()) { + optSet = Optional.of(Collections.emptySet()); } else { - ret = Collections.unmodifiableSet(ret); + optSet = Optional.of(Collections.unmodifiableSet(optSet.get())); } - return ret; + return optSet.get(); } /** diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/RuleBasedProcessor.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/RuleBasedProcessor.java index b557180e..ae83be2a 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/RuleBasedProcessor.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/RuleBasedProcessor.java @@ -58,6 +58,7 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.logging.Logger; @@ -78,6 +79,8 @@ import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityManager; import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityType; import de.tudresden.inf.lat.jcel.coreontology.datatype.OntologyExpressivity; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; /** * An object of this class is an implementation of a classification algorithm. @@ -128,7 +131,7 @@ public void run() { private SChain chainS = null; private IntegerHierarchicalGraph classHierarchy = null; private IntegerHierarchicalGraph dataPropertyHierarchy = null; - private Map> directTypes = null; + private OptMap> directTypes = null; private final IntegerEntityManager entityManager; private final NormalizedIntegerAxiomFactory factory; private boolean isReady = false; @@ -136,7 +139,7 @@ public void run() { private long loggingCount = loggingFrequency; private final boolean multiThreadedMode = false; private IntegerHierarchicalGraph objectPropertyHierarchy = null; - private Map> sameIndividualMap = null; + private OptMap> sameIndividualMap = null; private ClassifierStatusImpl status = null; private WorkerThreadR threadR1 = null; private WorkerThreadR threadR2 = null; @@ -192,8 +195,8 @@ public void addAxioms(Set normalizedAxiomSet) { * graph containing direct subsumers * @return a map with all the direct types for each individual. */ - private Map> computeDirectTypes(IntegerHierarchicalGraph hierarchicalGraph) { - Map> ret = new HashMap<>(); + private OptMap> computeDirectTypes(IntegerHierarchicalGraph hierarchicalGraph) { + OptMap> ret = new OptMapImpl<>(new HashMap<>()); Set individuals = getEntityManager().getIndividuals(); individuals.forEach(indiv -> { Set subsumers = hierarchicalGraph.getParents(getEntityManager().getAuxiliaryNominal(indiv).get()); @@ -235,17 +238,17 @@ private Set computeReachability(Integer c) { return ret; } - private Set computeReachability(Integer c, Map> reachableNodeCache) { - Set reachableNodes = reachableNodeCache.get(c); - if (Objects.isNull(reachableNodes)) { - reachableNodes = computeReachability(c); - reachableNodeCache.put(c, reachableNodes); + private Set computeReachability(Integer c, OptMap> reachableNodeCache) { + Optional> optReachableNodes = reachableNodeCache.get(c); + if (!optReachableNodes.isPresent()) { + optReachableNodes = Optional.of(computeReachability(c)); + reachableNodeCache.put(c, optReachableNodes.get()); } - return reachableNodes; + return optReachableNodes.get(); } - private Map> computeSameIndividualMap(IntegerHierarchicalGraph hierarchicalGraph) { - Map> ret = new HashMap<>(); + private OptMap> computeSameIndividualMap(IntegerHierarchicalGraph hierarchicalGraph) { + OptMap> ret = new OptMapImpl<>(new HashMap<>()); Set individuals = getEntityManager().getIndividuals(); individuals.forEach(indiv -> { Set equivalentClasses = hierarchicalGraph @@ -269,7 +272,7 @@ private Map> computeSameIndividualMap(IntegerHierarchicalG * key * @param value * value - * @return a map entry created using the paramenters + * @return a map entry created using the parameters */ private Map.Entry createEntry(String key, String value) { return new AbstractMap.SimpleEntry(key, value); @@ -365,7 +368,7 @@ public Map> getDirectTypes() { if (!isReady()) { throw new UnclassifiedOntologyException(); } - return Collections.unmodifiableMap(this.directTypes); + return Collections.unmodifiableMap(this.directTypes.asMap()); } protected IntegerEntityManager getEntityManager() { @@ -421,7 +424,7 @@ public Map> getSameIndividualMap() { if (!isReady()) { throw new UnclassifiedOntologyException(); } - return Collections.unmodifiableMap(this.sameIndividualMap); + return Collections.unmodifiableMap(this.sameIndividualMap.asMap()); } /** @@ -594,7 +597,7 @@ private boolean processMultiThreaded() { * the hierarchical graph */ private void processNominals(IntegerHierarchicalGraph hierarchicalGraph) { - Map> reachabilityCache = new HashMap<>(); + OptMap> reachabilityCache = new OptMapImpl<>(new HashMap<>()); Set nominals = getEntityManager().getAuxiliaryNominals(); nominals.forEach(indiv -> { Set descendants = getDescendants(hierarchicalGraph, indiv); diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/TurtleRenderer.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/TurtleRenderer.java index cd6a8845..a2c3d1db 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/TurtleRenderer.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/algorithm/rulebased/TurtleRenderer.java @@ -52,10 +52,13 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.Collection; -import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.TreeMap; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; + /** * An object of this class creates a stream in a particular case of Turtle * (Terse RDF Triple Language). @@ -75,7 +78,7 @@ public class TurtleRenderer { private static final String space = " "; private static final String uriDelimiterLeft = "<"; private static final String uriDelimiterRight = ">"; - private final Map mapOfPrefixes = new TreeMap<>(); + private final OptMap mapOfPrefixes = new OptMapImpl<>(new TreeMap<>()); private final BufferedWriter output; @@ -124,9 +127,9 @@ private String getTurtleEntity(String name) { URI uri = new URI(name); String prefix = getPrefix(uri); if (prefix.length() > 0) { - String prefixId = this.mapOfPrefixes.get(prefix); - if (Objects.nonNull(prefixId)) { - ret = prefixId + prefixSeparator + getName(uri); + Optional optPrefixId = this.mapOfPrefixes.get(prefix); + if (optPrefixId.isPresent()) { + ret = optPrefixId.get() + prefixSeparator + getName(uri); } else { ret = uriDelimiterLeft + name + uriDelimiterRight; } @@ -168,10 +171,10 @@ public boolean loadPrefixes(Collection identifiers) { */ public void renderPrefixes() throws IOException { for (String prefix : this.mapOfPrefixes.keySet()) { - String prefixId = this.mapOfPrefixes.get(prefix); + Optional optPrefixId = this.mapOfPrefixes.get(prefix); this.output.write(prefixKeyword); this.output.write(space); - this.output.write(prefixId); + this.output.write(optPrefixId.get()); this.output.write(prefixSeparator); this.output.write(space); this.output.write(uriDelimiterLeft); diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/common/ClassifierStatus.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/common/ClassifierStatus.java index cc14e035..2d7df782 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/common/ClassifierStatus.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/common/ClassifierStatus.java @@ -47,6 +47,7 @@ package de.tudresden.inf.lat.jcel.core.completion.common; import java.util.Collection; +import java.util.Optional; import java.util.Set; import de.tudresden.inf.lat.jcel.core.graph.VNode; @@ -145,7 +146,7 @@ public interface ClassifierStatus { * node identifier * @return the node for the given node identifier */ - VNode getNode(int nodeId); + Optional getNode(int nodeId); /** * Returns the set of object properties related with a certain class as a diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR6RExtRule.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR6RExtRule.java index a74c7895..be4a5334 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR6RExtRule.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR6RExtRule.java @@ -47,6 +47,7 @@ package de.tudresden.inf.lat.jcel.core.completion.ext; import java.util.Objects; +import java.util.Optional; import de.tudresden.inf.lat.jcel.core.completion.common.ClassifierStatus; import de.tudresden.inf.lat.jcel.core.completion.common.CompletionRuleMonitor; @@ -94,9 +95,12 @@ private boolean applyRule(ClassifierStatus status, int r, int x, int y) { status.getExtendedOntology().getGCI3rAAxioms(sMinus, a).forEach(axiom -> { int b = axiom.getSuperClass(); if (!status.getSubsumers(y).contains(b)) { - VNode psiNode = status.getNode(y); - VNodeImpl newNode = new VNodeImpl(psiNode.getClassId()); - newNode.addExistentialsOf(psiNode); + Optional optPsiNode = status.getNode(y); + if (!optPsiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + y + "'."); + } + VNodeImpl newNode = new VNodeImpl(optPsiNode.get().getClassId()); + newNode.addExistentialsOf(optPsiNode.get()); newNode.addExistential(rMinus, a); boolean inV = status.contains(newNode); int v = status.createOrGetNodeId(newNode); diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR6SExtRule.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR6SExtRule.java index 9cbd9ccc..d20a08cf 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR6SExtRule.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR6SExtRule.java @@ -47,6 +47,7 @@ package de.tudresden.inf.lat.jcel.core.completion.ext; import java.util.Objects; +import java.util.Optional; import de.tudresden.inf.lat.jcel.core.completion.common.ClassifierStatus; import de.tudresden.inf.lat.jcel.core.completion.common.CompletionRuleMonitor; @@ -94,9 +95,12 @@ private boolean applyRule(ClassifierStatus status, int x, int a) { int b = axiom.getSuperClass(); status.getSecondByFirst(r, x).forEach(y -> { if (!status.getSubsumers(y).contains(b)) { - VNode psiNode = status.getNode(y); - VNodeImpl newNode = new VNodeImpl(psiNode.getClassId()); - newNode.addExistentialsOf(psiNode); + Optional optPsiNode = status.getNode(y); + if (!optPsiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + y + "'."); + } + VNodeImpl newNode = new VNodeImpl(optPsiNode.get().getClassId()); + newNode.addExistentialsOf(optPsiNode.get()); newNode.addExistential(rMinus, a); boolean inV = status.contains(newNode); int v = status.createOrGetNodeId(newNode); diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR7RExtRule.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR7RExtRule.java index cecc6ad6..98022979 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR7RExtRule.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR7RExtRule.java @@ -47,6 +47,7 @@ package de.tudresden.inf.lat.jcel.core.completion.ext; import java.util.Objects; +import java.util.Optional; import de.tudresden.inf.lat.jcel.core.completion.common.ClassifierStatus; import de.tudresden.inf.lat.jcel.core.completion.common.CompletionRuleMonitor; @@ -89,8 +90,14 @@ public boolean apply(ClassifierStatus status, int property, int leftClass, int r private boolean applyRule(ClassifierStatus status, int r2, int x, int y) { CompletionRuleMonitor ret = new CompletionRuleMonitor(); - VNode phiNode = status.getNode(x); - VNode psiNode = status.getNode(y); + Optional optPhiNode = status.getNode(x); + if (!optPhiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + x + "'."); + } + Optional optPsiNode = status.getNode(y); + if (!optPsiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + y + "'."); + } status.getSuperObjectProperties(r2).forEach(r -> { if (status.getExtendedOntology().getTransitiveObjectProperties().contains(r)) { int rMinus = status.getInverseObjectPropertyOf(r); @@ -101,9 +108,9 @@ private boolean applyRule(ClassifierStatus status, int r2, int x, int y) { int b = axiom.getSuperClass(); status.getSubObjectProperties(r).forEach(r1 -> { int r1Minus = status.getInverseObjectPropertyOf(r1); - if (phiNode.containsExistential(r1Minus, a)) { - VNodeImpl newNode = new VNodeImpl(psiNode.getClassId()); - newNode.addExistentialsOf(psiNode); + if (optPhiNode.get().containsExistential(r1Minus, a)) { + VNodeImpl newNode = new VNodeImpl(optPsiNode.get().getClassId()); + newNode.addExistentialsOf(optPsiNode.get()); newNode.addExistential(rMinus, a); boolean inV = status.contains(newNode); int v = status.createOrGetNodeId(newNode); diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR9RExtOptRule.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR9RExtOptRule.java index f6d97b43..642476d8 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR9RExtOptRule.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR9RExtOptRule.java @@ -48,11 +48,13 @@ import java.util.HashSet; import java.util.Objects; +import java.util.Optional; import java.util.Set; import de.tudresden.inf.lat.jcel.core.completion.common.ClassifierStatus; import de.tudresden.inf.lat.jcel.core.completion.common.CompletionRuleMonitor; import de.tudresden.inf.lat.jcel.core.completion.common.RObserverRule; +import de.tudresden.inf.lat.jcel.core.graph.VNode; import de.tudresden.inf.lat.jcel.core.graph.VNodeImpl; import de.tudresden.inf.lat.jcel.coreontology.datatype.IntegerEntityManager; @@ -94,13 +96,21 @@ public boolean apply(ClassifierStatus status, int property, int leftClass, int r private boolean applyRule(ClassifierStatus status, int r1, int x, int y) { CompletionRuleMonitor ret = new CompletionRuleMonitor(); - if (status.getNode(y).getClassId() == IntegerEntityManager.topClassId) { + Optional optPsiNode = status.getNode(y); + if (!optPsiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + y + "'."); + } + if (optPsiNode.get().getClassId() == IntegerEntityManager.topClassId) { Set valid = new HashSet<>(); valid.add(y); status.getObjectPropertiesWithFunctionalAncestor(r1).forEach(r2 -> { status.getSecondByFirst(r2, x).forEach(yi -> { - if (status.getNode(yi).getClassId() == IntegerEntityManager.topClassId) { + Optional optPhiNode = status.getNode(yi); + if (!optPhiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + yi + "'."); + } + if (optPhiNode.get().getClassId() == IntegerEntityManager.topClassId) { valid.add(yi); } }); @@ -109,7 +119,11 @@ private boolean applyRule(ClassifierStatus status, int r1, int x, int y) { if (valid.size() > 1) { VNodeImpl newNode = new VNodeImpl(IntegerEntityManager.topClassId); valid.forEach(yi -> { - newNode.addExistentialsOf(status.getNode(yi)); + Optional optPhiNode = status.getNode(yi); + if (!optPsiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + yi + "'."); + } + newNode.addExistentialsOf(optPhiNode.get()); }); int v = status.createOrGetNodeId(newNode); valid.forEach(yi -> { diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR9RExtRule.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR9RExtRule.java index 7a67cd85..54b48b15 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR9RExtRule.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/completion/ext/CR9RExtRule.java @@ -47,6 +47,7 @@ package de.tudresden.inf.lat.jcel.core.completion.ext; import java.util.Objects; +import java.util.Optional; import de.tudresden.inf.lat.jcel.core.completion.common.ClassifierStatus; import de.tudresden.inf.lat.jcel.core.completion.common.CompletionRuleMonitor; @@ -89,16 +90,22 @@ public boolean apply(ClassifierStatus status, int property, int leftClass, int r private boolean applyRule(ClassifierStatus status, int r1, int x, int y) { CompletionRuleMonitor ret = new CompletionRuleMonitor(); - VNode psiNode = status.getNode(y); - if (psiNode.getClassId() == IntegerEntityManager.topClassId) { + Optional optPsiNode = status.getNode(y); + if (!optPsiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + y + "'."); + } + if (optPsiNode.get().getClassId() == IntegerEntityManager.topClassId) { status.getObjectPropertiesWithFunctionalAncestor(r1).forEach(r2 -> { status.getSecondByFirst(r2, x).forEach(z -> { - VNode phiNode = status.getNode(z); - if (phiNode.getClassId() == IntegerEntityManager.topClassId) { + Optional optPhiNode = status.getNode(z); + if (!optPsiNode.isPresent()) { + throw new IllegalStateException("Node not found in internal structure '" + z + "'."); + } + if (optPhiNode.get().getClassId() == IntegerEntityManager.topClassId) { if (y != z) { VNodeImpl newNode = new VNodeImpl(IntegerEntityManager.topClassId); - newNode.addExistentialsOf(psiNode); - newNode.addExistentialsOf(phiNode); + newNode.addExistentialsOf(optPsiNode.get()); + newNode.addExistentialsOf(optPhiNode.get()); int v = status.createOrGetNodeId(newNode); status.getSubsumers(y).forEach(p -> { diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerBinaryRelationImpl.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerBinaryRelationImpl.java index b79c2747..2518f05f 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerBinaryRelationImpl.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerBinaryRelationImpl.java @@ -48,11 +48,13 @@ import java.util.Collection; import java.util.Collections; -import java.util.Map; -import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; + /** * This class implements a binary relation. Its elements are integer numbers. * @@ -60,8 +62,8 @@ */ public class IntegerBinaryRelationImpl implements IntegerBinaryRelation { - private final Map> byFirstComp = new ConcurrentHashMap<>(); - private final Map> bySecondComp = new ConcurrentHashMap<>(); + private final OptMap> byFirstComp = new OptMapImpl<>(new ConcurrentHashMap<>()); + private final OptMap> bySecondComp = new OptMapImpl<>(new ConcurrentHashMap<>()); /** * Constructs an empty binary relation. @@ -100,27 +102,34 @@ public boolean add(int first, int second) { ret |= add(first); ret |= add(second); - Collection byFirst = this.byFirstComp.get(first); - Collection bySecond = this.bySecondComp.get(second); + Optional> optByFirst = this.byFirstComp.get(first); + if (!optByFirst.isPresent()) { + throw new IllegalStateException("Element is not present in the relation: '" + first + "'."); + } + + Optional> optBySecond = this.bySecondComp.get(second); + if (!optBySecond.isPresent()) { + throw new IllegalStateException("Element is not present in the relation: '" + second + "'."); + } boolean found = false; - if (byFirst.size() < bySecond.size()) { - found = byFirst.contains(second); + if (optByFirst.get().size() < optBySecond.get().size()) { + found = optByFirst.get().contains(second); } else { - found = bySecond.contains(first); + found = optBySecond.get().contains(first); } if (!found) { - ret |= byFirst.add(second); - ret |= bySecond.add(first); + ret |= optByFirst.get().add(second); + ret |= optBySecond.get().add(first); } return ret; } - private boolean addTo(int elem, Map> map) { + private boolean addTo(int elem, OptMap> map) { boolean ret = false; - if (Objects.isNull(map.get(elem))) { + if (!map.get(elem).isPresent()) { map.put(elem, new ArraySet()); ret = true; } @@ -130,8 +139,8 @@ private boolean addTo(int elem, Map> map) { @Override public boolean contains(int first, int second) { boolean ret = false; - Collection byFirst = this.byFirstComp.get(first); - ret = (Objects.nonNull(byFirst)) && byFirst.contains(second); + Optional> byFirst = this.byFirstComp.get(first); + ret = (byFirst.isPresent()) && byFirst.get().contains(second); return ret; } @@ -150,9 +159,9 @@ public boolean equals(Object o) { @Override public Collection getByFirst(int first) { Collection ret = Collections.emptySet(); - Collection set = this.byFirstComp.get(first); - if (Objects.nonNull(set)) { - ret = Collections.unmodifiableCollection(set); + Optional> optSet = this.byFirstComp.get(first); + if (optSet.isPresent()) { + ret = Collections.unmodifiableCollection(optSet.get()); } return ret; } @@ -160,9 +169,9 @@ public Collection getByFirst(int first) { @Override public Collection getBySecond(int second) { Collection ret = Collections.emptySet(); - Collection set = this.bySecondComp.get(second); - if (Objects.nonNull(set)) { - ret = Collections.unmodifiableCollection(set); + Optional> optSet = this.bySecondComp.get(second); + if (optSet.isPresent()) { + ret = Collections.unmodifiableCollection(optSet.get()); } return ret; } @@ -179,11 +188,11 @@ public long getDeepSize() { long ret = 0; ret += this.byFirstComp.keySet().stream() // - .map(key -> this.byFirstComp.get(key).size()) // + .map(key -> this.byFirstComp.get(key).get().size()) // .reduce(0, (accum, elem) -> (accum + elem)); ret += this.bySecondComp.keySet().stream() // - .map(key -> this.bySecondComp.get(key).size()) // + .map(key -> this.bySecondComp.get(key).get().size()) // .reduce(0, (accum, elem) -> (accum + elem)); return ret; diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerHierarchicalGraphImpl.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerHierarchicalGraphImpl.java index bd12a24a..494b1c18 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerHierarchicalGraphImpl.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerHierarchicalGraphImpl.java @@ -49,12 +49,15 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; + /** * This class implements the algorithm that computes the class hierarchy from * the subsumer set. This implementation starts finding direct subsumees from @@ -66,10 +69,10 @@ public class IntegerHierarchicalGraphImpl implements IntegerHierarchicalGraph { private final Integer bottomElement; - private final Map> children = new TreeMap<>(); - private final Map> equivalents = new TreeMap<>(); - private final Map> parents = new TreeMap<>(); - private final Map representative = new TreeMap<>(); + private final OptMap> children = new OptMapImpl<>(new TreeMap<>()); + private final OptMap> equivalents = new OptMapImpl<>(new TreeMap<>()); + private final OptMap> parents = new OptMapImpl<>(new TreeMap<>()); + private final OptMap representative = new OptMapImpl<>(new TreeMap<>()); private final Integer topElement; /** @@ -87,6 +90,14 @@ public IntegerHierarchicalGraphImpl(Integer bottom, Integer top) { this.topElement = top; } + private Set get(OptMap> map, Integer key) { + Optional> optSet = map.get(key); + if (!optSet.isPresent()) { + throw new IllegalStateException("Illegal state of internal map, error retrieving '" + key + "'."); + } + return optSet.get(); + } + /** * Constructs a hierarchical graph using another graph. * @@ -162,14 +173,14 @@ private void dagClassify(Integer cA, Set classified, IntegerSubsumerGra private void dagInsert(Integer cA, Set candidates) { Set marked = new TreeSet<>(); candidates.forEach(cB -> { - Set parentSet = this.parents.get(cB); + Set parentSet = get(this.parents, cB); parentSet.forEach(cX -> marked.add(cX)); }); Set notMarkedCandidates = new TreeSet<>(); notMarkedCandidates.addAll(candidates); notMarkedCandidates.removeAll(marked); this.parents.put(cA, notMarkedCandidates); - notMarkedCandidates.forEach(cB -> this.children.get(cB).add(cA)); + notMarkedCandidates.forEach(cB -> get(this.children, cB).add(cA)); } /** @@ -197,20 +208,20 @@ && getTopElement().equals(otherGraph.getTopElement())) { otherSet.addAll(otherGraph.getElements()); otherSet.forEach(elem -> { - if (Objects.isNull(this.children.get(elem))) { + if (!this.children.get(elem).isPresent()) { this.children.put(elem, new HashSet<>()); } - this.children.get(elem).addAll(otherGraph.getChildren(elem)); + get(this.children, elem).addAll(otherGraph.getChildren(elem)); - if (Objects.isNull(this.parents.get(elem))) { + if (!this.parents.get(elem).isPresent()) { this.parents.put(elem, new HashSet<>()); } - this.parents.get(elem).addAll(otherGraph.getParents(elem)); + get(this.parents, elem).addAll(otherGraph.getParents(elem)); - if (Objects.isNull(this.equivalents.get(elem))) { + if (!this.equivalents.get(elem).isPresent()) { this.equivalents.put(elem, new HashSet<>()); } - if (Objects.isNull(this.representative.get(elem))) { + if (!this.representative.get(elem).isPresent()) { this.representative.put(elem, elem); } otherGraph.getEquivalents(elem).forEach(otherElem -> makeEquivalent(elem, otherElem)); @@ -243,13 +254,13 @@ public Set getAncestors(Integer orig) { Objects.requireNonNull(orig); Set ret = new HashSet<>(); Set toVisit = new HashSet<>(); - toVisit.addAll(this.parents.get(orig)); + toVisit.addAll(get(this.parents, orig)); while (!toVisit.isEmpty()) { Integer elem = toVisit.iterator().next(); toVisit.remove(elem); ret.add(elem); Set related = new HashSet<>(); - related.addAll(this.parents.get(elem)); + related.addAll(get(this.parents, elem)); related.removeAll(ret); toVisit.addAll(related); } @@ -264,7 +275,7 @@ public Integer getBottomElement() { @Override public Set getChildren(Integer elem) { Objects.requireNonNull(elem); - return Collections.unmodifiableSet(this.children.get(elem)); + return Collections.unmodifiableSet(get(this.children, elem)); } @Override @@ -272,13 +283,13 @@ public Set getDescendants(Integer orig) { Objects.requireNonNull(orig); Set ret = new HashSet<>(); Set toVisit = new HashSet<>(); - toVisit.addAll(this.children.get(orig)); + toVisit.addAll(get(this.children, orig)); while (!toVisit.isEmpty()) { Integer elem = toVisit.iterator().next(); toVisit.remove(elem); ret.add(elem); Set related = new HashSet<>(); - related.addAll(this.children.get(elem)); + related.addAll(get(this.children, elem)); related.removeAll(ret); toVisit.addAll(related); } @@ -293,7 +304,10 @@ public Set getElements() { @Override public Set getEquivalents(Integer elem) { Objects.requireNonNull(elem); - return Collections.unmodifiableSet(this.equivalents.get(this.representative.get(elem))); + if (!this.representative.get(elem).isPresent()) { + throw new IllegalStateException("Representative not found: '" + elem + "'."); + } + return Collections.unmodifiableSet(get(this.equivalents, this.representative.get(elem).get())); } /** @@ -308,7 +322,7 @@ public Set getNonEquivalentElements() { @Override public Set getParents(Integer elem) { Objects.requireNonNull(elem); - return Collections.unmodifiableSet(this.parents.get(elem)); + return Collections.unmodifiableSet(get(this.parents, elem)); } @Override @@ -322,13 +336,21 @@ public int hashCode() { } private void makeEquivalent(Integer cA, Integer cB) { - Integer repA = this.representative.get(cA); - Integer repB = this.representative.get(cB); + if (!this.representative.get(cA).isPresent()) { + throw new IllegalStateException("Representative not found: '" + cA + "'."); + } + Integer repA = this.representative.get(cA).get(); + + if (!this.representative.get(cB).isPresent()) { + throw new IllegalStateException("Representative not found: '" + cB + "'."); + } + Integer repB = this.representative.get(cB).get(); + if (!repA.equals(repB)) { Integer rep = Math.min(repA, repB); Integer exRep = Math.max(repA, repB); - this.equivalents.get(rep).addAll(this.equivalents.get(exRep)); - this.equivalents.get(exRep).forEach(elem -> this.representative.put(elem, rep)); + get(this.equivalents, rep).addAll(get(this.equivalents, exRep)); + get(this.equivalents, exRep).forEach(elem -> this.representative.put(elem, rep)); this.equivalents.remove(exRep); } } @@ -367,16 +389,16 @@ public String toString() { private void updateBottom() { Set parentsOfBottom = new HashSet<>(); getElements().forEach(elem -> { - if (this.children.get(elem).isEmpty()) { + if (get(this.children, elem).isEmpty()) { parentsOfBottom.add(elem); } }); - Set equivToBottom = this.equivalents.get(this.bottomElement); + Set equivToBottom = get(this.equivalents, this.bottomElement); parentsOfBottom.removeAll(equivToBottom); if (!equivToBottom.contains(this.topElement) && parentsOfBottom.isEmpty()) { parentsOfBottom.add(this.topElement); } - parentsOfBottom.forEach(elem -> this.children.get(elem).add(this.bottomElement)); + parentsOfBottom.forEach(elem -> get(this.children, elem).add(this.bottomElement)); equivToBottom.forEach(elem -> this.parents.put(elem, parentsOfBottom)); } @@ -384,7 +406,7 @@ private void updateChildren() { getElements().forEach(elem -> { Set elemChildren = new HashSet<>(); getEquivalents(elem).forEach(index -> { - this.children.get(index).forEach(child -> elemChildren.addAll(getEquivalents(child))); + get(this.children, index).forEach(child -> elemChildren.addAll(getEquivalents(child))); }); getEquivalents(elem).forEach(index -> this.children.put(index, elemChildren)); }); @@ -394,7 +416,7 @@ private void updateParents() { getElements().forEach(elem -> { Set elemParents = new HashSet<>(); getEquivalents(elem).forEach(index -> { - this.parents.get(index).forEach(parent -> elemParents.addAll(getEquivalents(parent))); + get(this.parents, index).forEach(parent -> elemParents.addAll(getEquivalents(parent))); }); getEquivalents(elem).forEach(index -> this.parents.put(index, elemParents)); }); diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerRelationMapImpl.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerRelationMapImpl.java index 94ed140e..8a36f30c 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerRelationMapImpl.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerRelationMapImpl.java @@ -48,11 +48,13 @@ import java.util.Collection; import java.util.Collections; -import java.util.Map; -import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; + /** * This class implements a map of binary relations. * @@ -60,9 +62,10 @@ */ public class IntegerRelationMapImpl implements IntegerRelationMap { - private final Map relationMap = new ConcurrentHashMap<>(); - private final Map> relationSetByFirst = new ConcurrentHashMap<>(); - private final Map> relationSetBySecond = new ConcurrentHashMap<>(); + private final OptMap relationMap = new OptMapImpl<>(new ConcurrentHashMap<>()); + private final OptMap> relationSetByFirst = new OptMapImpl<>(new ConcurrentHashMap<>()); + private final OptMap> relationSetBySecond = new OptMapImpl<>( + new ConcurrentHashMap<>()); /** * Constructs an empty map of binary relations. @@ -100,29 +103,29 @@ public boolean add(int relationId) { */ public boolean add(int relationId, int first, int second) { boolean ret = false; - IntegerBinaryRelationImpl relation = this.relationMap.get(relationId); - if (Objects.isNull(relation)) { - relation = new IntegerBinaryRelationImpl(); - this.relationMap.put(relationId, relation); + Optional optRelation = this.relationMap.get(relationId); + if (!optRelation.isPresent()) { + optRelation = Optional.of(new IntegerBinaryRelationImpl()); + this.relationMap.put(relationId, optRelation.get()); ret = true; } - ret |= relation.add(first, second); + ret |= optRelation.get().add(first, second); - Collection byFirst = this.relationSetByFirst.get(first); - if (Objects.isNull(byFirst)) { - byFirst = new ArraySet(); - this.relationSetByFirst.put(first, byFirst); + Optional> optByFirst = this.relationSetByFirst.get(first); + if (!optByFirst.isPresent()) { + optByFirst = Optional.of(new ArraySet()); + this.relationSetByFirst.put(first, optByFirst.get()); ret = true; } - ret |= byFirst.add(relationId); + ret |= optByFirst.get().add(relationId); - Collection bySecond = this.relationSetBySecond.get(second); - if (Objects.isNull(bySecond)) { - bySecond = new ArraySet(); - this.relationSetBySecond.put(second, bySecond); + Optional> optBySecond = this.relationSetBySecond.get(second); + if (!optBySecond.isPresent()) { + optBySecond = Optional.of(new ArraySet()); + this.relationSetBySecond.put(second, optBySecond.get()); ret = true; } - ret |= bySecond.add(relationId); + ret |= optBySecond.get().add(relationId); return ret; } @@ -135,9 +138,9 @@ public boolean contains(int relationId) { @Override public boolean contains(int relationId, int first, int second) { boolean ret = false; - IntegerBinaryRelation relation = this.relationMap.get(relationId); - if (Objects.nonNull(relation)) { - ret = relation.contains(first, second); + Optional optRelation = this.relationMap.get(relationId); + if (optRelation.isPresent()) { + ret = optRelation.get().contains(first, second); } return ret; } @@ -156,15 +159,21 @@ public boolean equals(Object o) { @Override public IntegerBinaryRelation get(int relationId) { - return this.relationMap.get(relationId); + IntegerBinaryRelation ret = null; + if (this.relationMap.get(relationId).isPresent()) { + ret = this.relationMap.get(relationId).get(); + } else { + ret = new IntegerBinaryRelationImpl(); + } + return ret; } @Override public Collection getByFirst(int relationId, int first) { Collection ret = Collections.emptySet(); - IntegerBinaryRelation relation = this.relationMap.get(relationId); - if (Objects.nonNull(relation)) { - ret = relation.getByFirst(first); + Optional optRelation = this.relationMap.get(relationId); + if (optRelation.isPresent()) { + ret = optRelation.get().getByFirst(first); } return ret; } @@ -172,9 +181,9 @@ public Collection getByFirst(int relationId, int first) { @Override public Collection getBySecond(int relationId, int second) { Collection ret = Collections.emptySet(); - IntegerBinaryRelation relation = this.relationMap.get(relationId); - if (Objects.nonNull(relation)) { - ret = relation.getBySecond(second); + Optional optRelation = this.relationMap.get(relationId); + if (optRelation.isPresent()) { + ret = optRelation.get().getBySecond(second); } return ret; } @@ -191,15 +200,15 @@ public long getDeepSize() { long ret = 0; ret += this.relationMap.keySet().stream() // - .map(key -> this.relationMap.get(key).getDeepSize()) // + .map(key -> this.relationMap.get(key).get().getDeepSize()) // .reduce(0L, (accum, elem) -> (accum + elem)); ret += this.relationSetByFirst.keySet().stream() // - .map(key -> this.relationSetByFirst.get(key).size()) // + .map(key -> this.relationSetByFirst.get(key).get().size()) // .reduce(0, (accum, elem) -> (accum + elem)); ret += this.relationSetBySecond.keySet().stream() // - .map(key -> this.relationSetBySecond.get(key).size()) // + .map(key -> this.relationSetBySecond.get(key).get().size()) // .reduce(0, (accum, elem) -> (accum + elem)); return ret; @@ -212,20 +221,20 @@ public Set getElements() { @Override public Collection getRelationsByFirst(int first) { - Collection ret = this.relationSetByFirst.get(first); - if (Objects.isNull(ret)) { - ret = Collections.emptySet(); + Optional> optSet = this.relationSetByFirst.get(first); + if (!optSet.isPresent()) { + optSet = Optional.of(Collections.emptySet()); } - return Collections.unmodifiableCollection(ret); + return Collections.unmodifiableCollection(optSet.get()); } @Override public Collection getRelationsBySecond(int second) { - Collection ret = this.relationSetBySecond.get(second); - if (Objects.isNull(ret)) { - ret = Collections.emptySet(); + Optional> optSet = this.relationSetBySecond.get(second); + if (!optSet.isPresent()) { + optSet = Optional.of(Collections.emptySet()); } - return Collections.unmodifiableCollection(ret); + return Collections.unmodifiableCollection(optSet.get()); } @Override diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerSubsumerBidirectionalGraphImpl.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerSubsumerBidirectionalGraphImpl.java index a24248e9..7bbfbecf 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerSubsumerBidirectionalGraphImpl.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerSubsumerBidirectionalGraphImpl.java @@ -103,7 +103,7 @@ public void addAncestor(int subId, int superId) { @Override public boolean containsPair(int subsumee, int subsumer) { - return Objects.nonNull(getSubsumers(subsumee)) && getSubsumers(subsumee).contains(subsumer); + return getSubsumers(subsumee).contains(subsumer); } @Override diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerSubsumerGraphImpl.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerSubsumerGraphImpl.java index 7bd5339a..9b1415a5 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerSubsumerGraphImpl.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/graph/IntegerSubsumerGraphImpl.java @@ -49,11 +49,14 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; -import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; + /** * This class implements a subsumer graph. This implementation keeps a set of * subsumers for each vertex. It also considers bottom and its equivalents as @@ -66,7 +69,7 @@ public class IntegerSubsumerGraphImpl implements IntegerSubsumerGraph { private final int bottomElement; private final Collection emptyCollection = Collections.unmodifiableCollection(new ArraySet()); private final Set equivToBottom = new HashSet<>(); - private final Map> setS = new ConcurrentHashMap<>(); + private final OptMap> setS = new OptMapImpl<>(new ConcurrentHashMap<>()); private final int topElement; /** @@ -120,9 +123,12 @@ public boolean addAncestor(int subId, int superId) { } else { ret |= add(subId); ret |= add(superId); - Collection set = this.setS.get(subId); - if (!set.contains(superId)) { - ret |= set.add(superId); + Optional> optSet = this.setS.get(subId); + if (!optSet.isPresent()) { + throw new IllegalStateException("Element was not added: '" + subId + "'."); + } + if (!optSet.get().contains(superId)) { + ret |= optSet.get().add(superId); } } } @@ -131,7 +137,7 @@ public boolean addAncestor(int subId, int superId) { @Override public boolean containsPair(int subsumee, int subsumer) { - return Objects.nonNull(getSubsumers(subsumee)) && getSubsumers(subsumee).contains(subsumer); + return getSubsumers(subsumee).contains(subsumer); } @Override @@ -161,7 +167,7 @@ public int getBottomElement() { */ public long getDeepSize() { return this.setS.keySet().stream() // - .map(key -> this.setS.get(key).size()) // + .map(key -> this.setS.get(key).get().size()) // .reduce(0, (accum, elem) -> (accum + elem)); } @@ -172,18 +178,18 @@ public Collection getElements() { @Override public Collection getSubsumers(int vertex) { - Collection ret; + Optional> optSet; if (this.equivToBottom.contains(vertex)) { - ret = getElements(); + optSet = Optional.of(getElements()); } else { - ret = this.setS.get(vertex); - if (Objects.isNull(ret)) { - ret = Collections.emptySet(); + optSet = this.setS.get(vertex); + if (!optSet.isPresent()) { + optSet = Optional.of(Collections.emptySet()); } else { - ret = Collections.unmodifiableCollection(ret); + optSet = Optional.of(Collections.unmodifiableCollection(optSet.get())); } } - return ret; + return optSet.get(); } @Override diff --git a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/saturation/SR4Rule.java b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/saturation/SR4Rule.java index 69869920..eab4497e 100644 --- a/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/saturation/SR4Rule.java +++ b/jcel-core/src/main/java/de/tudresden/inf/lat/jcel/core/saturation/SR4Rule.java @@ -48,13 +48,14 @@ import java.util.Collections; import java.util.HashSet; -import java.util.Map; import java.util.Objects; import java.util.Set; import de.tudresden.inf.lat.jcel.coreontology.axiom.FunctObjectPropAxiom; import de.tudresden.inf.lat.jcel.coreontology.axiom.NormalizedIntegerAxiom; import de.tudresden.inf.lat.jcel.coreontology.axiom.NormalizedIntegerAxiomFactory; +import de.tudresden.inf.lat.util.map.OptMap; +import de.tudresden.inf.lat.util.map.OptMapImpl; /** *