├── LICENSE ├── README.md ├── ecco.bat ├── ecco.sh ├── eccov.sh ├── pom.xml └── src └── main ├── java └── uk │ └── ac │ └── manchester │ └── cs │ └── diff │ ├── Ecco.java │ ├── EccoRunner.java │ ├── EccoSettings.java │ ├── axiom │ ├── AxiomDiff.java │ ├── CategoricalDiff.java │ ├── LogicalDiff.java │ ├── LogicalDiffConcurrent.java │ ├── StructuralDiff.java │ ├── change │ │ ├── CategorisedChange.java │ │ ├── CategorisedEffectualAddition.java │ │ ├── CategorisedEffectualChange.java │ │ ├── CategorisedEffectualRemoval.java │ │ ├── CategorisedIneffectualAddition.java │ │ ├── CategorisedIneffectualRemoval.java │ │ ├── LogicalAddition.java │ │ ├── LogicalChange.java │ │ ├── LogicalRemoval.java │ │ ├── StructuralAddition.java │ │ ├── StructuralChange.java │ │ └── StructuralRemoval.java │ └── changeset │ │ ├── AxiomChangeSet.java │ │ ├── CategorisedChangeSet.java │ │ ├── LogicalChangeSet.java │ │ └── StructuralChangeSet.java │ ├── concept │ ├── ConceptDiff.java │ ├── ContentCVSDiff.java │ ├── GrammarDiff.java │ ├── SubconceptDiff.java │ ├── change │ │ ├── ConceptChange.java │ │ ├── LHSConceptChange.java │ │ └── RHSConceptChange.java │ ├── changeset │ │ └── ConceptChangeSet.java │ ├── sigma │ │ └── Signature.java │ └── witnesses │ │ ├── WitnessAxioms.java │ │ ├── WitnessConcepts.java │ │ └── WitnessGroup.java │ ├── exception │ ├── DuplicateArgumentException.java │ ├── InconsistentOntologyException.java │ ├── InsufficientArgumentsException.java │ ├── MissingArgumentException.java │ ├── NotImplementedException.java │ └── UnrecognizedArgumentException.java │ ├── justifications │ ├── JustificationFinder.java │ └── LaconicJustificationFinder.java │ ├── output │ ├── GenSymShortFormProvider.java │ ├── LabelShortFormProvider.java │ ├── OutputHandler.java │ ├── csv │ │ ├── CSVAxiomDiffReport.java │ │ ├── CSVConceptDiffReport.java │ │ └── CSVDiffReport.java │ └── xml │ │ ├── XMLAxiomDiffReport.java │ │ ├── XMLConceptDiffReport.java │ │ ├── XMLDiffReport.java │ │ └── XMLUnifiedDiffReport.java │ ├── test │ ├── Diff.java │ ├── DiffResult.java │ └── SubconceptDiffAlternative.java │ ├── unity │ ├── ChangeAligner.java │ ├── ChangeAlignerExperimental.java │ ├── WitnessJustifier.java │ └── changeset │ │ ├── AlignedChangeSet.java │ │ ├── AlignedChangeSetInt.java │ │ ├── AlignedDirectChangeSet.java │ │ ├── AlignedIndirectChangeSet.java │ │ └── ChangeSet.java │ └── utils │ ├── ConceptDiffRunner.java │ ├── OntologyLoader.java │ ├── ProgressMonitor.java │ ├── ReasonerLoader.java │ ├── SignatureSampler.java │ ├── SilentChangeBroadcastStrategy.java │ └── XMLTransformer.java └── resources ├── css ├── reveal.css └── style.css ├── images ├── blank.png ├── favicon.png ├── info_bubble.png ├── logomanchester.png ├── minus.png ├── modal-gloss.png ├── plus.png ├── tt_bottom.gif ├── tt_left.gif ├── tt_top.gif └── x_icon.gif ├── js ├── jquery-1.4.4.js ├── jquery-ui-1.8.12.custom.min.js ├── jquery.checkboxtree.js ├── jquery.reveal.js ├── jscript.js └── script.js └── xslt ├── xslt_client.xsl ├── xslt_full_client.xsl └── xslt_full_client_examples.xsl /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | *ecco* 2 | ==== 3 | 4 | #### a diff tool for OWL 2 ontologies #### 5 | 6 | Built using the [OWL API](http://owlapi.sourceforge.net/). For demo purposes there is a Web-based front-end [here](http://ecco-rsgtools.rhcloud.com/). 7 | 8 | 9 | summary 10 | -------------------- 11 | *ecco* identifies changes according to OWL's notion of [structural equivalence](http://www.w3.org/TR/owl2-syntax/#Structural_Specification), 12 | and then verifies whether these changes produce any *effect on entailments*, i.e. whether they are logically effectual or ineffectual. 13 | Subsequently these differences are aligned according to their impact (or lack thereof). 14 | 15 | Additionally, *ecco* now has an option (`-c`) to detect which concepts had their meaning affected by axiom changes. This is done by checking which (atomic) concepts have different sub- or super-concepts between ontologies, where the latter can be: 16 | 17 | * `-c at` Atomic concepts 18 | * `-c sub` Subconcepts asserted in either ontology 19 | * `-c gr` Concepts of the form `r some C`, `r only C`, `not C`, `C or C'`, `C and C'`, where `C, C'` are subconcepts asserted in either ontology, and `r` is an atomic role 20 | * `-c cvs` Concepts of the form `r some A`, `r only A`, `not A`, where `A` is an atomic concept, and `r` is an atomic role 21 | 22 | Note that these are all sound but incomplete approximations of the *minimal [concept] change set*, as defined [here](http://www.cs.man.ac.uk/~goncalvj/files/2012_iswc_diff.pdf). The last option: `-c cvs` is based on the entailment grammar employed in [ContentCVS](http://www.cs.ox.ac.uk/isg/tools/ContentCVS). 23 | 24 | After detecting the set of affected concepts, *ecco* distinguishes between concepts that are directly or indirectly affected, that is, whether some concept `A` changed due to a change in some concept `B`, where both ontologies entail that `A => B`. 25 | 26 | Finally, axiom changes are aligned with the concepts that they affect; these are shown on the right hand side columns. When hovering over affected concepts, the tool will show the entailment differences for each concept change. 27 | 28 | For full details, check [my thesis](https://www.escholar.manchester.ac.uk/uk-ac-man-scw:220347), particularly Chapter 7 where a tool walkthrough is carried out. 29 | 30 | 31 | usage 32 | -------------------- 33 | 34 | `[SCRIPT]` **-ont1** `[ONTOLOGY]` **-ont2** `[ONTOLOGY]` `[OPTIONS]` 35 | 36 | * `[SCRIPT]` in **Windows**: use *ecco.bat*, in **UNIX**-based systems: use *ecco.sh* 37 | 38 | * `[ONTOLOGY]` an input ontology file path or URL 39 | 40 | * `[OPTIONS]` 41 | * `-o` Output directory for generated files [ default: {ecco.jar.dir}/ecco-output ] 42 | * `-t` Transform XML diff report into HTML 43 | * `-c` Compute one of: [ at | sub | gr | cvs ] concept diff [ default: atomic ] 44 | * `-r` Analyse root ontologies only, i.e. ignore imports 45 | * `-n` Normalize entity URIs, i.e. if two ontologies have the same entity names in a different namespace, this trigger establishes a common namespace (comparison of entity names is by syntactic string equality) 46 | * `-i` Ignore Abox axioms 47 | * `-j` Maximum number of justifications computed per ineffectual change 48 | * `-v` Verbose mode 49 | * `-h` `-help` Print this help message 50 | 51 | The standard output of *ecco* is an XML file representing the change set. With the **-t** flag, *ecco* will transform this XML file into HTML. 52 | 53 | By default, the output goes to a folder named **_ecco-output_**, which contains the required files for appropriate rendering on a Web browser. The output folder can be altered via the **-o** flag. For a more informative progress monitoring, use the **-v** flag. 54 | 55 | In order to deploy *ecco* on a set of versions, the script `eccov.sh` can be used. Instructions for doing so are in the script itself. 56 | 57 | 58 | deployment 59 | -------------------- 60 | *ecco* is compatible with **Java 1.7 (or above)**, and requires [Java JDK](http://www.oracle.com/technetwork/java/javase/downloads) and [Apache Maven](http://maven.apache.org/) installed in order to be built from sources. 61 | 62 | The tool relies directly on the following projects: 63 | 64 | * [OWL API](http://owlapi.sourceforge.net/) (v3.5.1) 65 | * [HermiT](http://www.hermit-reasoner.com/) reasoner (v1.3.8) 66 | * [JFact](http://jfact.sourceforge.net/) reasoner (v1.2.2) 67 | * [Guava](https://github.com/google/guava) (v14.0.1) 68 | * [Saxon-HE](http://saxon.sourceforge.net/) XSLT and XQuery processor (v9.6.0) 69 | * [Apache commons-io](http://commons.apache.org/proper/commons-io/) (v2.4) 70 | 71 | 72 | future plans 73 | -------------------- 74 | * An alternative, term-centric view of changes between ontologies 75 | -------------------------------------------------------------------------------- /ecco.bat: -------------------------------------------------------------------------------- 1 | :: This script is untested! Please let me know if any problems occur 2 | :: 3 | :: ecco: a diff tool for OWL ontologies 4 | :: Copyright 2011-2014, The University of Manchester 5 | :: 6 | :: This script builds (if necessary) and runs ecco. The requirements 7 | :: to build and run ecco are Java 1.7 (or above) and Apache Maven. 8 | :: 9 | :: Last updated: 16-Feb-15 10 | :: 11 | :: Build project if ecco.jar does not exist 12 | @echo off 13 | set mem=8G 14 | set lib=".\lib" 15 | if not exist target\ecco.jar ( 16 | echo. 17 | echo building ecco... 18 | echo. 19 | call mvn install 20 | echo done 21 | ) 22 | :: 23 | :: Run ecco with the specified arguments 24 | :: Maximum heap space is set to: 8GB, and Java library path to: .\lib 25 | echo. 26 | echo starting ecco... 27 | echo. 28 | java -Xmx%mem% -Djava.library.path=%lib% -DentityExpansionLimit=100000000 -jar target\ecco.jar %* -------------------------------------------------------------------------------- /ecco.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ecco: a diff tool for OWL 2 ontologies 4 | # Copyright 2011-2014, The University of Manchester 5 | # 6 | # This script builds (if necessary) and runs ecco. The requirements 7 | # to build and run ecco are Java 1.7 (or above) and Apache Maven. 8 | # 9 | # Last updated: 16-Feb-15 10 | # 11 | # Build project if ecco.jar does not exist 12 | if [ ! -f target/ecco.jar ]; 13 | then 14 | if [ -d target ] 15 | then 16 | echo "cleaning up..."$'\n' 17 | mvn clean 18 | fi 19 | echo $'\n'"building ecco..."$'\n' 20 | mvn install 21 | echo "done"$'\n' 22 | fi 23 | # 24 | # Set the maximum memory to be used, by default, 8GB 25 | maxmem="8G" 26 | # 27 | # deprecated: Pointer to lib folder 28 | # lib=`pwd`"/target/lib" -Djava.library.path="$lib" 29 | # 30 | # Run ecco with the specified arguments 31 | echo "starting ecco..." 32 | java -Xmx"$maxmem" -DentityExpansionLimit=100000000 -jar target/ecco.jar $* -------------------------------------------------------------------------------- /eccov.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ecco: a diff tool for OWL 2 ontologies 4 | # Copyright 2011-2014, The University of Manchester 5 | # 6 | # This script builds (if necessary) and runs ecco on a set of versions. The requirements 7 | # to build and run ecco are Java 1.7 (or above) and Apache Maven. The set of versions 8 | # must be organised either as appropriately-sorted files within a folder, or a set of 9 | # folders: each containing an ontology whose filename must be specified here. 10 | # 11 | # For ecco's optional arguments (that can be passed onto it from here), do: sh ecco.sh -h 12 | # 13 | # Last updated: 16-Feb-15 14 | # 15 | # Build project if ecco.jar does not exist 16 | if [ -f target/ecco.jar ] 17 | then 18 | echo "Building ecco (this requires an internet connection to fetch dependencies)"$'\n' 19 | mvn install 20 | echo "done"$'\n' 21 | fi 22 | # 23 | # Default argument values (which can be altered via options below) 24 | # 25 | maxmem="8G" # Maximum heap space allocated to the JVM. Default: 8GB 26 | lib=`pwd`"/lib" # Java library folder 27 | # 28 | # Iterate arguments 29 | # 30 | ontbase="" 31 | ontname="" 32 | usage(){ 33 | echo "" 34 | echo "Usage: sh ecco.sh -b DIRECTORY [-o FILENAME] [-m MEMORY] [-f DIRECTORY] [ECCO OPTIONS]" 35 | echo "" 36 | echo " -b --base Base folder where the the ontology files or folders are contained" 37 | echo " -o --ont If the 'base' folder contains folders, then -o must specify a single, universal ontology name" 38 | echo " -m --mem Maximum heap space (memory) allocated to the JVM. Default: 8G (8 GB)" 39 | echo " -l --lib Java library path. Default: ./lib/" 40 | echo "" 41 | } 42 | while : 43 | do 44 | case $1 in 45 | -h | --help | -\?) 46 | usage 47 | exit 0 48 | ;; 49 | -b | --base) 50 | ontbase=$2 51 | echo "Ontology base folder: $2" 52 | shift 2 53 | ;; 54 | -o | --ont) 55 | ontname=$2 56 | echo "Ontology name: $2" 57 | shift 2 58 | ;; 59 | -m | --mem) 60 | maxmem=$2 61 | echo "JVM heap space: $2" 62 | shift 2 63 | ;; 64 | -l | --lib) 65 | lib=$2 66 | echo "Java lib path: $2" 67 | shift 2 68 | ;; 69 | --) 70 | shift 71 | break 72 | ;; 73 | -*) 74 | echo "Warning: Unknown option (ignored): $1" >&2 75 | break 76 | ;; 77 | *) 78 | break 79 | ;; 80 | esac 81 | done 82 | echo "ecco arguments: $@" 83 | # 84 | # Ensure required argument is specified 85 | # 86 | if [ ! "$ontbase" ]; then 87 | echo "Error: Required option '--base or -b DIRECTORY' not given. See --help" >&2 88 | exit 1 89 | fi 90 | # 91 | # The input parameters beyond this script will go on to ecco. Note that -ont1 and -ont2 92 | # are established here. So pass onto ecco only optional commands (like -v for verbose) 93 | # 94 | versions=( $ontbase/* ) 95 | for (( i = 0 ; i < ${#versions[@]}-1 ; i++ )) 96 | do 97 | if [ ! "$ontname" ]; then 98 | ont1=${versions[$i]} 99 | ont2=${versions[$i+1]} 100 | else 101 | ont1=${versions[$i]}/"$ontname" 102 | ont2=${versions[$i+1]}/"$ontname" 103 | fi 104 | # Run ecco with the specified arguments 105 | java -Xmx"$maxmem" -Djava.library.path="$lib" -DentityExpansionLimit=100000000 -jar target/ecco.jar -ont1 "$ont1" -ont2 "$ont2" "$@" 106 | done -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.sonatype.oss 7 | oss-parent 8 | 9 9 | 10 | 11 | ecco 12 | https://github.com/rsgoncalves/ecco 13 | a diff tool for OWL 2 ontologies that computes differences with respect to axiom and term changes 14 | 15 | com.github.rsgoncalves 16 | ecco 17 | 2.7.0-SNAPSHOT 18 | jar 19 | 20 | 21 | 22 | rsgoncalves 23 | Rafael Goncalves 24 | rafael.goncalves@stanford.edu 25 | 26 | 27 | 28 | 29 | 30 | net.sourceforge.owlapi 31 | owlapi-distribution 32 | 3.5.1 33 | javadoc 34 | 35 | 36 | net.sourceforge.owlapi 37 | owlexplanation 38 | 1.1.0 39 | 40 | 41 | net.sourceforge.owlapi 42 | telemetry 43 | 1.0.0 44 | 45 | 46 | com.google.guava 47 | guava 48 | 14.0.1 49 | 50 | 51 | com.hermit-reasoner 52 | org.semanticweb.hermit 53 | 1.3.8.4 54 | 55 | 56 | net.sourceforge.owlapi 57 | jfact 58 | 1.2.2 59 | 60 | 61 | net.sf.saxon 62 | Saxon-HE 63 | 9.6.0-4 64 | 65 | 66 | org.apache.directory.studio 67 | org.apache.commons.io 68 | 2.4 69 | 70 | 71 | 72 | 73 | 74 | release-sign-artifacts 75 | 76 | 77 | performRelease 78 | true 79 | 80 | 81 | 82 | 83 | 84 | org.apache.maven.plugins 85 | maven-gpg-plugin 86 | 1.4 87 | 88 | 89 | sign-artifacts 90 | verify 91 | 92 | sign 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | GitHub 104 | https://github.com/rsgoncalves/ecco/issues 105 | 106 | 107 | 108 | UTF-8 109 | 110 | 111 | 112 | target 113 | target/classes 114 | ${project.artifactId}-${project.version} 115 | 116 | 117 | org.apache.maven.plugins 118 | maven-jar-plugin 119 | 2.5 120 | 121 | 122 | 123 | true 124 | lib/ 125 | uk.ac.manchester.cs.diff.EccoRunner 126 | 127 | 128 | 129 | 130 | 131 | 132 | org.apache.maven.plugins 133 | maven-compiler-plugin 134 | 2.3.2 135 | 136 | 1.8 137 | 1.8 138 | UTF-8 139 | 140 | 141 | 142 | 143 | org.apache.maven.plugins 144 | maven-source-plugin 145 | 2.1.2 146 | 147 | 148 | attach-sources 149 | 150 | jar 151 | 152 | 153 | 154 | 155 | 156 | 157 | org.apache.maven.plugins 158 | maven-javadoc-plugin 159 | 2.9.1 160 | 161 | 162 | attach-javadocs 163 | 164 | jar 165 | 166 | 167 | 168 | 169 | 170 | 171 | maven-dependency-plugin 172 | 173 | 174 | install 175 | 176 | copy-dependencies 177 | 178 | 179 | ${project.build.directory}/lib 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | git@github.com:rsgoncalves/ecco.git 189 | scm:git:git@github.com:rsgoncalves/ecco.git 190 | scm:git:git@github.com:rsgoncalves/ecco.git 191 | 192 | 193 | 194 | 195 | GNU LGPL Version 3.0 196 | http://www.gnu.org/licenses/lgpl.txt 197 | repo 198 | 199 | 200 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/AxiomDiff.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom; 20 | 21 | import uk.ac.manchester.cs.diff.axiom.changeset.AxiomChangeSet; 22 | import uk.ac.manchester.cs.diff.output.xml.XMLAxiomDiffReport; 23 | 24 | /** 25 | * @author Rafael S. Goncalves
26 | * Information Management Group (IMG)
27 | * School of Computer Science
28 | * University of Manchester
29 | */ 30 | public interface AxiomDiff { 31 | 32 | /** 33 | * Compute the diff and return a change set containing all differences 34 | * @return Change set with the differences 35 | */ 36 | public AxiomChangeSet getDiff(); 37 | 38 | 39 | /** 40 | * Check if the given ontologies are equivalent w.r.t. the (instantiated) diff's equivalence notion 41 | * @return true if ontologies are equivalent, false otherwise 42 | */ 43 | public boolean isEquivalent(); 44 | 45 | 46 | /** 47 | * Get an XML file which represents the change set 48 | * @return XML file containing the change set 49 | */ 50 | public XMLAxiomDiffReport getXMLReport(); 51 | 52 | 53 | /** 54 | * Get a summary CSV file containing the number and types of changes 55 | * @return CSV file containing a summary of the number and types of changes 56 | */ 57 | public String getCSVChangeReport(); 58 | 59 | 60 | /** 61 | * Print the diff results to stdout 62 | */ 63 | public void printDiff(); 64 | 65 | } -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/LogicalDiff.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom; 20 | 21 | import java.util.HashSet; 22 | import java.util.Set; 23 | 24 | import org.semanticweb.owlapi.model.OWLAxiom; 25 | import org.semanticweb.owlapi.model.OWLEntity; 26 | import org.semanticweb.owlapi.model.OWLOntology; 27 | import org.semanticweb.owlapi.reasoner.OWLReasoner; 28 | 29 | import uk.ac.manchester.cs.diff.axiom.changeset.LogicalChangeSet; 30 | import uk.ac.manchester.cs.diff.axiom.changeset.StructuralChangeSet; 31 | import uk.ac.manchester.cs.diff.exception.InconsistentOntologyException; 32 | import uk.ac.manchester.cs.diff.output.csv.CSVAxiomDiffReport; 33 | import uk.ac.manchester.cs.diff.output.xml.XMLAxiomDiffReport; 34 | import uk.ac.manchester.cs.diff.utils.ReasonerLoader; 35 | 36 | /** 37 | * @author Rafael S. Goncalves
38 | * Information Management Group (IMG)
39 | * School of Computer Science
40 | * University of Manchester
41 | */ 42 | public class LogicalDiff implements AxiomDiff { 43 | private OWLOntology ont1, ont2; 44 | private StructuralChangeSet structChangeSet; 45 | private LogicalChangeSet logicalChangeSet; 46 | private OWLReasoner ont1reasoner, ont2reasoner; 47 | private double diffTime; 48 | private boolean verbose; 49 | 50 | /** 51 | * Constructor 52 | * @param ont1 Ontology 1 53 | * @param ont2 Ontology 2 54 | * @param verbose Verbose mode 55 | */ 56 | public LogicalDiff(OWLOntology ont1, OWLOntology ont2, boolean verbose) { 57 | this.ont1 = ont1; 58 | this.ont2 = ont2; 59 | this.verbose = verbose; 60 | } 61 | 62 | 63 | /** 64 | * Constructor that takes a structural change set 65 | * @param ont1 Ontology 1 66 | * @param ont2 Ontology 2 67 | * @param changeSet Structural change set 68 | * @param verbose Verbose mode 69 | */ 70 | public LogicalDiff(OWLOntology ont1, OWLOntology ont2, StructuralChangeSet changeSet, boolean verbose) { 71 | this.ont1 = ont1; 72 | this.ont2 = ont2; 73 | this.structChangeSet = changeSet; 74 | this.verbose = verbose; 75 | } 76 | 77 | 78 | /** 79 | * Get logical changes between ontologies given a reasoner instance per ontology 80 | * @param ont1reasoner Instance of a reasoner loaded with ontology 1 81 | * @param ont2reasoner Instance of a reasoner loaded with ontology 2 82 | * @return Logical change set 83 | */ 84 | public LogicalChangeSet getDiff(OWLReasoner ont1reasoner, OWLReasoner ont2reasoner) { 85 | this.ont1reasoner = ont1reasoner; 86 | this.ont2reasoner = ont2reasoner; 87 | return getDiff(); 88 | } 89 | 90 | 91 | /** 92 | * Get logical changes between ontologies 93 | * @return Logical change set 94 | */ 95 | @SuppressWarnings("deprecation") 96 | public LogicalChangeSet getDiff() { 97 | if(logicalChangeSet != null) return logicalChangeSet; 98 | if(structChangeSet == null) structChangeSet = new StructuralDiff(ont1, ont2, verbose).getDiff(); 99 | 100 | if(ont1reasoner == null) ont1reasoner = new ReasonerLoader(ont1).createReasoner(false); 101 | if(ont2reasoner == null) ont2reasoner = new ReasonerLoader(ont2).createReasoner(false); 102 | 103 | if(!ont1reasoner.isConsistent()) 104 | throw new InconsistentOntologyException("Ontology 1 is inconsistent. Cannot perform logical diff on inconsistent input."); 105 | if(!ont2reasoner.isConsistent()) 106 | throw new InconsistentOntologyException("Ontology 2 is inconsistent. Cannot perform logical diff on inconsistent input."); 107 | 108 | if(verbose) System.out.print(" Verifying axiom impact... "); 109 | long start = System.currentTimeMillis(); 110 | 111 | Set ineffectualAdditions = getIneffectualChanges(structChangeSet.getAddedAxioms(), ont1reasoner); 112 | Set effectualAdditions = new HashSet(structChangeSet.getAddedAxioms()); 113 | effectualAdditions.removeAll(ineffectualAdditions); 114 | 115 | Set ineffectualRemovals = getIneffectualChanges(structChangeSet.getRemovedAxioms(), ont2reasoner); 116 | Set effectualRemovals = new HashSet(structChangeSet.getRemovedAxioms()); 117 | effectualRemovals.removeAll(ineffectualRemovals); 118 | 119 | long end = System.currentTimeMillis(); 120 | diffTime = (end-start)/1000.0; 121 | 122 | logicalChangeSet = new LogicalChangeSet(effectualAdditions, ineffectualAdditions, effectualRemovals, ineffectualRemovals, structChangeSet); 123 | logicalChangeSet.setDiffTime(diffTime); 124 | 125 | if(verbose) System.out.println("done (" + diffTime + " secs)"); 126 | if(verbose) printDiff(); 127 | return logicalChangeSet; 128 | } 129 | 130 | 131 | /** 132 | * Get ineffectual changes 133 | * @param axioms Set of axioms to check 134 | * @param reasoner OWL reasoner 135 | * @return Set of ineffectual changes 136 | */ 137 | private Set getIneffectualChanges(Set axioms, OWLReasoner reasoner) { 138 | Set ontSig = reasoner.getRootOntology().getSignature(); 139 | Set ineffectual = new HashSet(); 140 | for(OWLAxiom axiom : axioms) { 141 | if(ontSig.containsAll(axiom.getSignature())) { 142 | if(reasoner.isEntailed(axiom)) 143 | ineffectual.add(axiom); 144 | } 145 | } 146 | return ineffectual; 147 | } 148 | 149 | 150 | /** 151 | * Print diff results 152 | */ 153 | public void printDiff() { 154 | System.out.println( 155 | "\tEffectual Additions: " + logicalChangeSet.getEffectualAdditionAxioms().size() + 156 | "\n\tEffectual Removals: " + logicalChangeSet.getEffectualRemovalAxioms().size() + 157 | "\n\tIneffectual Additions: " + logicalChangeSet.getIneffectualAdditionAxioms().size() + 158 | "\n\tIneffectual Removals: " + logicalChangeSet.getIneffectualRemovalAxioms().size()); 159 | } 160 | 161 | 162 | /** 163 | * Get an XML change report for the change set computed by this diff 164 | * @return XML change report object 165 | */ 166 | public XMLAxiomDiffReport getXMLReport() { 167 | if(logicalChangeSet == null) logicalChangeSet = getDiff(); 168 | return new XMLAxiomDiffReport(ont1, ont2, logicalChangeSet); 169 | } 170 | 171 | 172 | /** 173 | * Get a CSV change report 174 | * @return Change report as a CSV document 175 | */ 176 | public String getCSVChangeReport() { 177 | if(logicalChangeSet == null) logicalChangeSet = getDiff(); 178 | return new CSVAxiomDiffReport().getReport(logicalChangeSet); 179 | } 180 | 181 | 182 | /** 183 | * Determine if ontologies are logically equivalent 184 | * @return true if ontologies are logically equivalent, false otherwise 185 | */ 186 | public boolean isEquivalent() { 187 | if(logicalChangeSet == null) logicalChangeSet = getDiff(); 188 | if(logicalChangeSet.getEffectualAdditionAxioms().isEmpty() && logicalChangeSet.getEffectualRemovalAxioms().isEmpty()) 189 | return true; 190 | else 191 | return false; 192 | } 193 | 194 | 195 | /** 196 | * Convenience method to get the StructuralChangeSet 197 | * @return Structural diff change set 198 | */ 199 | public StructuralChangeSet getStructuralChangeSet() { 200 | if(structChangeSet != null) 201 | return structChangeSet; 202 | else 203 | return new StructuralDiff(ont1, ont2, verbose).getDiff(); 204 | } 205 | 206 | 207 | /** 208 | * Get the time to compute the diff 209 | * @return Diff time (in seconds) 210 | */ 211 | public double getDiffTime() { 212 | return diffTime; 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/StructuralDiff.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom; 20 | 21 | import java.util.HashSet; 22 | import java.util.Set; 23 | 24 | import org.semanticweb.owlapi.model.OWLAxiom; 25 | import org.semanticweb.owlapi.model.OWLLogicalAxiom; 26 | import org.semanticweb.owlapi.model.OWLOntology; 27 | import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; 28 | 29 | import uk.ac.manchester.cs.diff.axiom.changeset.StructuralChangeSet; 30 | import uk.ac.manchester.cs.diff.output.csv.CSVAxiomDiffReport; 31 | import uk.ac.manchester.cs.diff.output.xml.XMLAxiomDiffReport; 32 | 33 | /** 34 | * @author Rafael S. Goncalves
35 | * Information Management Group (IMG)
36 | * School of Computer Science
37 | * University of Manchester
38 | */ 39 | public class StructuralDiff implements AxiomDiff { 40 | private OWLOntology ont1, ont2; 41 | private String ont1name, ont2name; 42 | private StructuralChangeSet changeSet; 43 | private double diffTime; 44 | private boolean verbose; 45 | 46 | /** 47 | * Constructor 48 | * @param ont1 Ontology 1 49 | * @param ont2 Ontology 2 50 | * @param verbose true if detailed output should be printed, false otherwise 51 | */ 52 | public StructuralDiff(OWLOntology ont1, OWLOntology ont2, boolean verbose) { 53 | this.ont1 = ont1; 54 | this.ont2 = ont2; 55 | this.verbose = verbose; 56 | } 57 | 58 | 59 | /** 60 | * Constructor 2 61 | * @param ont1 Ontology 1 62 | * @param ont2 Ontology 2 63 | * @param ont1name Ontology 1 filename 64 | * @param ont2name Ontology 2 filename 65 | * @param verbose true if detailed output should be printed, false otherwise 66 | */ 67 | public StructuralDiff(OWLOntology ont1, OWLOntology ont2, String ont1name, String ont2name, boolean verbose) { 68 | this.ont1 = ont1; 69 | this.ont2 = ont2; 70 | this.ont1name = ont1name; 71 | this.ont2name = ont2name; 72 | this.verbose = verbose; 73 | } 74 | 75 | 76 | /** 77 | * Get structural changes between ontologies 78 | * @return Structural change set 79 | */ 80 | @SuppressWarnings("deprecation") 81 | public StructuralChangeSet getDiff() { 82 | if(changeSet != null) return changeSet; 83 | 84 | if(verbose) System.out.print(" Computing structural differences... "); 85 | Set o1axs = ont1.getLogicalAxioms(); 86 | Set o2axs = ont2.getLogicalAxioms(); 87 | 88 | Set additions = new HashSet(); 89 | Set removals = new HashSet(); 90 | Set shared = new HashSet(); 91 | 92 | long start = System.currentTimeMillis(); 93 | for(OWLAxiom ax : o1axs) { 94 | if(!o2axs.contains(ax)) { 95 | if(ax instanceof OWLSubClassOfAxiom) { 96 | if(!((OWLSubClassOfAxiom)ax).getSuperClass().isTopEntity()) 97 | removals.add(ax); 98 | } 99 | else removals.add(ax); 100 | } 101 | else shared.add(ax); 102 | } 103 | o2axs.removeAll(shared); 104 | for(OWLAxiom ax : o2axs) { 105 | if(!o1axs.contains(ax)) { 106 | if(ax instanceof OWLSubClassOfAxiom) { 107 | if(!((OWLSubClassOfAxiom)ax).getSuperClass().isTopEntity()) 108 | additions.add(ax); 109 | } 110 | else additions.add(ax); 111 | } 112 | else shared.add(ax); 113 | } 114 | 115 | long end = System.currentTimeMillis(); 116 | diffTime = (end-start)/1000.0; 117 | 118 | changeSet = new StructuralChangeSet(additions, removals, shared); 119 | addOntologyFileNames(); changeSet.setDiffTime(diffTime); 120 | 121 | if(verbose) System.out.println("done (" + diffTime + " secs)"); 122 | if(verbose) printDiff(); 123 | return changeSet; 124 | } 125 | 126 | 127 | /** 128 | * Print diff results 129 | */ 130 | public void printDiff() { 131 | System.out.println( 132 | "\tAdditions: " + changeSet.getAddedAxioms().size() + 133 | "\n\tRemovals: " + changeSet.getRemovedAxioms().size() + 134 | "\n\tShared: " + changeSet.getShared().size()); 135 | } 136 | 137 | 138 | /** 139 | * Record file names of given ontologies in the change set 140 | */ 141 | @SuppressWarnings("deprecation") 142 | private void addOntologyFileNames() { 143 | if(ont1name == null) changeSet.setOntologyName(1, "Ont1"); 144 | else changeSet.setOntologyName(1, ont1name); 145 | 146 | if(ont2name == null) changeSet.setOntologyName(2, "Ont2"); 147 | else changeSet.setOntologyName(2, ont2name); 148 | } 149 | 150 | 151 | /** 152 | * Get an XML change report for the change set computed by this diff 153 | * @return XML change report object 154 | */ 155 | public XMLAxiomDiffReport getXMLReport() { 156 | if(changeSet == null) changeSet = getDiff(); 157 | return new XMLAxiomDiffReport(ont1, ont2, changeSet); 158 | } 159 | 160 | 161 | /** 162 | * Get a CSV change report 163 | * @return Change report as a CSV document 164 | */ 165 | public String getCSVChangeReport() { 166 | if(changeSet == null) changeSet = getDiff(); 167 | return new CSVAxiomDiffReport().getReport(changeSet); 168 | } 169 | 170 | 171 | /** 172 | * Determine if ontologies are structurally equivalent (thus logically equivalent) 173 | * @return true if ontologies are structurally equivalent, false otherwise 174 | */ 175 | public boolean isEquivalent() { 176 | if(changeSet == null) changeSet = getDiff(); 177 | 178 | if(changeSet.isEmpty()) return true; 179 | else return false; 180 | } 181 | 182 | 183 | /** 184 | * Get the time to compute the diff 185 | * @return Diff time (in seconds) 186 | */ 187 | public double getDiffTime() { 188 | return diffTime; 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/CategorisedChange.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLAxiom; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class CategorisedChange extends LogicalChange { 30 | 31 | /** 32 | * @param axiom Changed axiom 33 | * @param isEffectual true if change is effectual, false otherwise 34 | */ 35 | public CategorisedChange(OWLAxiom axiom, boolean isEffectual) { 36 | super(axiom, isEffectual); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/CategorisedEffectualAddition.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import java.util.Set; 22 | 23 | import org.semanticweb.owlapi.model.OWLAxiom; 24 | import org.semanticweb.owlapi.model.OWLEntity; 25 | 26 | /** 27 | * @author Rafael S. Goncalves
28 | * Information Management Group (IMG)
29 | * School of Computer Science
30 | * University of Manchester
31 | */ 32 | public class CategorisedEffectualAddition extends CategorisedEffectualChange { 33 | private EffectualAdditionCategory cat; 34 | 35 | /** 36 | * Constructor 37 | * @param ax OWL Axiom 38 | * @param cat Change category 39 | * @param axAlignment Set of alignments 40 | * @param newTerms Set of new terms used in the axiom 41 | */ 42 | public CategorisedEffectualAddition(OWLAxiom ax, EffectualAdditionCategory cat, Set axAlignment, Set newTerms) { 43 | super(ax, axAlignment, newTerms); 44 | this.cat = cat; 45 | } 46 | 47 | 48 | /** 49 | * Get effectual addition category name 50 | * @return Change category name 51 | */ 52 | public String getCategoryName() { 53 | return cat.toString(); 54 | } 55 | 56 | 57 | /** 58 | * Get effectual addition category 59 | * @return Change category 60 | */ 61 | public EffectualAdditionCategory getCategory() { 62 | return cat; 63 | } 64 | 65 | 66 | /** 67 | * Categories of effectual additions 68 | */ 69 | public enum EffectualAdditionCategory { 70 | STRENGTHENING ("Strengthening"), 71 | STRENGTHENINGNT ("StrengtheningWithNewTerms"), 72 | PUREADDITION ("PureAddition"), 73 | PUREADDITIONNT ("PureAdditionWithNewTerms"), 74 | NEWDESCRIPTION ("NewDescription"), 75 | MODIFIEDDEFINITION ("NewModifiedDefinition"), 76 | MODIFIEDDEFINITIONNT ("NewModifiedDefinitionWithNewTerms"); 77 | 78 | String name; 79 | EffectualAdditionCategory(String name) { 80 | this.name = name; 81 | } 82 | 83 | public String toString() { 84 | return name; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/CategorisedEffectualChange.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import java.util.Set; 22 | 23 | import org.semanticweb.owlapi.model.OWLAxiom; 24 | import org.semanticweb.owlapi.model.OWLEntity; 25 | 26 | /** 27 | * @author Rafael S. Goncalves
28 | * Information Management Group (IMG)
29 | * School of Computer Science
30 | * University of Manchester
31 | */ 32 | public class CategorisedEffectualChange extends CategorisedChange { 33 | private Set axAlignment; 34 | private Set differentTerms; 35 | 36 | /** 37 | * Constructor 38 | * @param axiom OWL axiom 39 | * @param axAlignment Set of axioms with which this change aligns to 40 | * @param differentTerms Set of new or retired terms used in the axiom 41 | */ 42 | public CategorisedEffectualChange(OWLAxiom axiom, Set axAlignment, Set differentTerms) { 43 | super(axiom, true); 44 | this.axAlignment = axAlignment; 45 | this.differentTerms = differentTerms; 46 | } 47 | 48 | 49 | /** 50 | * Get the set of axiomatic alignments for this change 51 | * @return Set of axiomatic alignments for this change 52 | */ 53 | public Set getAxiomAlignment() { 54 | return axAlignment; 55 | } 56 | 57 | 58 | /** 59 | * Get the new terms used in this change 60 | * @return The set of new terms used in this change 61 | */ 62 | public Set getDifferentTerms() { 63 | return differentTerms; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/CategorisedEffectualRemoval.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import java.util.Set; 22 | 23 | import org.semanticweb.owlapi.model.OWLAxiom; 24 | import org.semanticweb.owlapi.model.OWLEntity; 25 | 26 | /** 27 | * @author Rafael S. Goncalves
28 | * Information Management Group (IMG)
29 | * School of Computer Science
30 | * University of Manchester
31 | */ 32 | public class CategorisedEffectualRemoval extends CategorisedEffectualChange { 33 | private EffectualRemovalCategory cat; 34 | 35 | /** 36 | * Constructor 37 | * @param ax OWL Axiom 38 | * @param cat Change category 39 | * @param axAlignment Set of alignments 40 | * @param retiredTerms Set of retired terms used in the axiom 41 | */ 42 | public CategorisedEffectualRemoval(OWLAxiom ax, EffectualRemovalCategory cat, Set axAlignment, Set retiredTerms) { 43 | super(ax, axAlignment, retiredTerms); 44 | this.cat = cat; 45 | } 46 | 47 | 48 | /** 49 | * Get effectual removal category name 50 | * @return Change category name 51 | */ 52 | public String getCategoryName() { 53 | return cat.toString(); 54 | } 55 | 56 | 57 | /** 58 | * Get effectual removal category 59 | * @return Change category 60 | */ 61 | public EffectualRemovalCategory getCategory() { 62 | return cat; 63 | } 64 | 65 | 66 | /** 67 | * Categories of effectual removals 68 | */ 69 | public enum EffectualRemovalCategory { 70 | WEAKENING ("Weakening"), 71 | WEAKENINGRT ("WeakeningWithRetiredTerms"), 72 | PUREREMOVAL ("PureRemoval"), 73 | PUREREMOVALRT ("PureRemovalWithRetiredTerms"), 74 | RETIREDDESCRIPTION ("RetiredDescription"), 75 | MODIFIEDDEFINITION ("RetiredModifiedDefinition"), 76 | MODIFIEDDEFINITIONRT ("RetiredModifiedDefinitionWithRetiredTerms"); 77 | 78 | String name; 79 | EffectualRemovalCategory(String name) { 80 | this.name = name; 81 | } 82 | 83 | public String toString() { 84 | return name; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/CategorisedIneffectualAddition.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import java.util.HashSet; 22 | import java.util.Map; 23 | import java.util.Set; 24 | 25 | import org.semanticweb.owl.explanation.api.Explanation; 26 | import org.semanticweb.owlapi.model.OWLAxiom; 27 | 28 | /** 29 | * @author Rafael S. Goncalves
30 | * Information Management Group (IMG)
31 | * School of Computer Science
32 | * University of Manchester
33 | */ 34 | public class CategorisedIneffectualAddition extends CategorisedChange { 35 | private Map,Set> cats; 36 | 37 | /** 38 | * Constructor 39 | * @param ax OWL Axiom 40 | * @param cats Map of justifications to change category 41 | */ 42 | public CategorisedIneffectualAddition(OWLAxiom ax, Map,Set> cats) { 43 | super(ax, false); 44 | this.cats = cats; 45 | } 46 | 47 | 48 | /** 49 | * Get the map of justifications to change category 50 | * @return Map of justifications to categories 51 | */ 52 | public Map,Set> getJustificationMap() { 53 | return cats; 54 | } 55 | 56 | 57 | /** 58 | * Get ineffectual addition categories 59 | * @return Change categories 60 | */ 61 | public Set getCategories() { 62 | Set result = new HashSet(); 63 | for(Explanation set : cats.keySet()) { 64 | result.addAll(cats.get(set)); 65 | } 66 | return result; 67 | } 68 | 69 | 70 | /** 71 | * Categories of ineffectual additions 72 | */ 73 | public enum IneffectualAdditionCategory { 74 | REWRITE ("AddedRewrite"), 75 | PREWRITE ("AddedPartialRewrite"), 76 | REDUNDANCY ("AddedRedundancy"), 77 | RESHUFFLEREDUNDANCY ("AddedReshuffleProspectiveRedundancy"), 78 | NEWPROSPREDUNDANCY ("AddedNewProspectiveRedundancy"); 79 | 80 | String name; 81 | IneffectualAdditionCategory(String name) { 82 | this.name = name; 83 | } 84 | 85 | public String toString() { 86 | return name; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/CategorisedIneffectualRemoval.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import java.util.HashSet; 22 | import java.util.Map; 23 | import java.util.Set; 24 | 25 | import org.semanticweb.owl.explanation.api.Explanation; 26 | import org.semanticweb.owlapi.model.OWLAxiom; 27 | 28 | /** 29 | * @author Rafael S. Goncalves
30 | * Information Management Group (IMG)
31 | * School of Computer Science
32 | * University of Manchester
33 | */ 34 | public class CategorisedIneffectualRemoval extends CategorisedChange { 35 | private Map,Set> cats; 36 | 37 | /** 38 | * Constructor 39 | * @param ax OWL Axiom 40 | * @param cats Map of justifications to change category 41 | */ 42 | public CategorisedIneffectualRemoval(OWLAxiom ax, Map,Set> cats) { 43 | super(ax, false); 44 | this.cats = cats; 45 | } 46 | 47 | 48 | /** 49 | * Get the map of justifications to change category 50 | * @return Map of justifications to categories 51 | */ 52 | public Map,Set> getJustificationMap() { 53 | return cats; 54 | } 55 | 56 | 57 | /** 58 | * Get ineffectual removal categories 59 | * @return Change categories 60 | */ 61 | public Set getCategories() { 62 | Set result = new HashSet(); 63 | for(Explanation set : cats.keySet()) { 64 | result.addAll(cats.get(set)); 65 | } 66 | return result; 67 | } 68 | 69 | 70 | /** 71 | * Categories of ineffectual removal 72 | */ 73 | public enum IneffectualRemovalCategory { 74 | REWRITE ("RemovedRewrite"), 75 | PREWRITE ("RemovedPartialRewrite"), 76 | REDUNDANCY ("RemovedRedundancy"), 77 | NEWPROSPREDUNDANCY ("RemovedNewProspectiveRedundancy"), 78 | RESHUFFLEREDUNDANCY ("RemovedReshuffleProspectiveRedundancy"); 79 | 80 | String name; 81 | IneffectualRemovalCategory(String name) { 82 | this.name = name; 83 | } 84 | 85 | public String toString() { 86 | return name; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/LogicalAddition.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLAxiom; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class LogicalAddition extends LogicalChange { 30 | /** 31 | * Constructor 32 | * @param axiom Axiom change 33 | * @param isEffectual true if change is logically effectual, false otherwise 34 | */ 35 | public LogicalAddition(OWLAxiom axiom, boolean isEffectual) { 36 | super(axiom, isEffectual); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/LogicalChange.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLAxiom; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class LogicalChange extends StructuralChange { 30 | private boolean isEffectual; 31 | 32 | /** 33 | * Constructor 34 | * @param axiom Changed axiom 35 | * @param isEffectual true if change is effectual, false otherwise 36 | */ 37 | public LogicalChange(OWLAxiom axiom, boolean isEffectual) { 38 | super(axiom); 39 | this.isEffectual = isEffectual; 40 | } 41 | 42 | 43 | /** 44 | * Check if change is logically effectual 45 | * @return true if change is logically effectual, false otherwise 46 | */ 47 | public boolean isEffectual() { 48 | return isEffectual; 49 | } 50 | 51 | 52 | /** 53 | * Check if change is logically ineffectual 54 | * @return true if change is logically ineffectual, false otherwise 55 | */ 56 | public boolean isIneffectual() { 57 | return !isEffectual; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/LogicalRemoval.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLAxiom; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class LogicalRemoval extends LogicalChange { 30 | /** 31 | * Constructor 32 | * @param axiom Axiom change 33 | * @param isEffectual true if change is logically effectual, false otherwise 34 | */ 35 | public LogicalRemoval(OWLAxiom axiom, boolean isEffectual) { 36 | super(axiom, isEffectual); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/StructuralAddition.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLAxiom; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class StructuralAddition extends StructuralChange { 30 | /** 31 | * Constructor 32 | * @param axiom Added axiom 33 | */ 34 | public StructuralAddition(OWLAxiom axiom) { 35 | super(axiom); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/StructuralChange.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLAxiom; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class StructuralChange { 30 | private OWLAxiom axiom; 31 | 32 | /** 33 | * Constructor 34 | * @param axiom Axiom change 35 | */ 36 | public StructuralChange(OWLAxiom axiom) { 37 | this.axiom = axiom; 38 | } 39 | 40 | 41 | /** 42 | * Get changed axiom 43 | * @return Changed axiom 44 | */ 45 | public OWLAxiom getAxiom() { 46 | return axiom; 47 | } 48 | 49 | 50 | /** 51 | * Check if change is a logical axiom 52 | * @return true if change is a logical axiom, false otherwise 53 | */ 54 | public boolean isLogicalAxiomChange() { 55 | if(axiom.isLogicalAxiom()) 56 | return true; 57 | else 58 | return false; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/change/StructuralRemoval.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLAxiom; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class StructuralRemoval extends StructuralChange { 30 | /** 31 | * Constructor 32 | * @param axiom Removed axiom 33 | */ 34 | public StructuralRemoval(OWLAxiom axiom) { 35 | super(axiom); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/changeset/AxiomChangeSet.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.changeset; 20 | 21 | import java.util.Set; 22 | 23 | import uk.ac.manchester.cs.diff.axiom.change.StructuralChange; 24 | import uk.ac.manchester.cs.diff.unity.changeset.ChangeSet; 25 | 26 | 27 | /** 28 | * @author Rafael S. Goncalves
29 | * Information Management Group (IMG)
30 | * School of Computer Science
31 | * University of Manchester
32 | */ 33 | public interface AxiomChangeSet extends ChangeSet { 34 | 35 | /** 36 | * Get the set of additions 37 | * @return Set of additions 38 | */ 39 | public Set getAdditions(); 40 | 41 | 42 | /** 43 | * Get the set of removals 44 | * @return Set of removals 45 | */ 46 | public Set getRemovals(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/changeset/LogicalChangeSet.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.changeset; 20 | 21 | import java.util.HashSet; 22 | import java.util.Set; 23 | 24 | import org.semanticweb.owlapi.model.OWLAxiom; 25 | 26 | import uk.ac.manchester.cs.diff.axiom.change.LogicalAddition; 27 | import uk.ac.manchester.cs.diff.axiom.change.LogicalRemoval; 28 | 29 | /** 30 | * @author Rafael S. Goncalves
31 | * Information Management Group (IMG)
32 | * School of Computer Science
33 | * University of Manchester
34 | */ 35 | public class LogicalChangeSet implements AxiomChangeSet { 36 | private Set effectualAdditions, ineffectualAdditions, effectualRemovals, ineffectualRemovals; 37 | private StructuralChangeSet structuralChangeSet; 38 | private double diffTime; 39 | 40 | /** 41 | * Constructor 42 | * @param effectualAdditions Effectual additions 43 | * @param ineffectualAdditions Ineffectual additions 44 | * @param effectualRemovals Effectual removals 45 | * @param ineffectualRemovals Ineffectual removals 46 | * @param structuralChangeSet Structural change set 47 | */ 48 | public LogicalChangeSet(Set effectualAdditions, Set ineffectualAdditions, 49 | Set effectualRemovals, Set ineffectualRemovals, StructuralChangeSet structuralChangeSet) { 50 | this.effectualAdditions = effectualAdditions; 51 | this.ineffectualAdditions = ineffectualAdditions; 52 | this.effectualRemovals = effectualRemovals; 53 | this.ineffectualRemovals = ineffectualRemovals; 54 | this.structuralChangeSet = structuralChangeSet; 55 | } 56 | 57 | 58 | /** 59 | * Get the structural change set between ontologies 60 | * @return Structural change set 61 | */ 62 | public StructuralChangeSet getStructuralChangeSet() { 63 | return structuralChangeSet; 64 | } 65 | 66 | 67 | /** 68 | * Set diff time 69 | * @param time Diff time 70 | * @deprecated 71 | */ 72 | public void setDiffTime(double time) { 73 | diffTime = time; 74 | } 75 | 76 | 77 | /** 78 | * Get the CPU time (in seconds) spent in structural diff 79 | * @return CPU time (in seconds) spent in structural diff 80 | */ 81 | public double getOperationTime() { 82 | return diffTime; 83 | } 84 | 85 | 86 | /** 87 | * Get the set of effectual and ineffectual additions 88 | * @return Set of effectual and ineffectual additions 89 | */ 90 | public Set getAdditions() { 91 | Set additionSet = new HashSet(); 92 | for(OWLAxiom ax : effectualAdditions) 93 | additionSet.add(new LogicalAddition(ax, true)); 94 | for(OWLAxiom ax : ineffectualAdditions) 95 | additionSet.add(new LogicalAddition(ax, false)); 96 | return additionSet; 97 | } 98 | 99 | 100 | /** 101 | * Get the set of effectual and ineffectual removals 102 | * @return Set of effectual and ineffectual removals 103 | */ 104 | public Set getRemovals() { 105 | Set removalSet = new HashSet(); 106 | for(OWLAxiom ax : effectualRemovals) 107 | removalSet.add(new LogicalRemoval(ax, true)); 108 | for(OWLAxiom ax : ineffectualRemovals) 109 | removalSet.add(new LogicalRemoval(ax, false)); 110 | return removalSet; 111 | } 112 | 113 | 114 | /** 115 | * Get the set of effectual addition axioms 116 | * @return Set of effectual addition axioms 117 | */ 118 | public Set getEffectualAdditionAxioms() { 119 | return effectualAdditions; 120 | } 121 | 122 | 123 | /** 124 | * Get the set of effectual removal axioms 125 | * @return Set of effectual removal axioms 126 | */ 127 | public Set getEffectualRemovalAxioms() { 128 | return effectualRemovals; 129 | } 130 | 131 | 132 | /** 133 | * Get the set of ineffectual addition axioms 134 | * @return Set of ineffectual addition axioms 135 | */ 136 | public Set getIneffectualAdditionAxioms() { 137 | return ineffectualAdditions; 138 | } 139 | 140 | 141 | /** 142 | * Get the set of ineffectual removal axioms 143 | * @return Set of ineffectual removal axioms 144 | */ 145 | public Set getIneffectualRemovalAxioms() { 146 | return ineffectualRemovals; 147 | } 148 | 149 | 150 | /** 151 | * Check if change set contains no changes 152 | * @return true if change set contains no changes, false otherwise 153 | */ 154 | public boolean isEmpty() { 155 | if(effectualAdditions.isEmpty() && effectualRemovals.isEmpty() 156 | && ineffectualAdditions.isEmpty() && ineffectualAdditions.isEmpty()) 157 | return true; 158 | else 159 | return false; 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/axiom/changeset/StructuralChangeSet.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.axiom.changeset; 20 | 21 | import java.util.HashSet; 22 | import java.util.Set; 23 | 24 | import org.semanticweb.owlapi.model.OWLAxiom; 25 | 26 | import uk.ac.manchester.cs.diff.axiom.change.StructuralAddition; 27 | import uk.ac.manchester.cs.diff.axiom.change.StructuralRemoval; 28 | 29 | /** 30 | * @author Rafael S. Goncalves
31 | * Information Management Group (IMG)
32 | * School of Computer Science
33 | * University of Manchester
34 | */ 35 | public class StructuralChangeSet implements AxiomChangeSet { 36 | private Set additions, removals, shared; 37 | private String ont1name, ont2name; 38 | private double diffTime; 39 | 40 | /** 41 | * Constructor 42 | * @param additions Set of added axioms 43 | * @param removals Set of removed axioms 44 | * @param shared Set of shared axioms 45 | */ 46 | public StructuralChangeSet(Set additions, Set removals, Set shared) { 47 | this.additions = additions; 48 | this.removals = removals; 49 | this.shared = shared; 50 | } 51 | 52 | 53 | /** 54 | * Set file name of specified ontology (1 or 2) 55 | * @param ontNr Ontology number 56 | * @param name Ontology file name 57 | * @deprecated 58 | */ 59 | public void setOntologyName(int ontNr, String name) { 60 | if(ontNr == 1) ont1name = name; 61 | else if(ontNr == 2) ont2name = name; 62 | } 63 | 64 | 65 | /** 66 | * Set diff time 67 | * @param time Diff time 68 | * @deprecated 69 | */ 70 | public void setDiffTime(double time) { 71 | diffTime = time; 72 | } 73 | 74 | 75 | /** 76 | * Get the CPU time (in seconds) spent in structural diff 77 | * @return CPU time (in seconds) spent in structural diff 78 | */ 79 | public double getOperationTime() { 80 | return diffTime; 81 | } 82 | 83 | 84 | /** 85 | * Get file name of ontology 1 86 | * @return File name of ontology 1 87 | */ 88 | public String getOntology1FileName() { 89 | return ont1name; 90 | } 91 | 92 | 93 | /** 94 | * Get file name of ontology 2 95 | * @return File name of ontology 2 96 | */ 97 | public String getOntology2FileName() { 98 | return ont2name; 99 | } 100 | 101 | 102 | /** 103 | * Get the set of structural additions 104 | * @return Set of structural additions 105 | */ 106 | public Set getAdditions() { 107 | Set additionSet = new HashSet(); 108 | for(OWLAxiom ax : additions) 109 | additionSet.add(new StructuralAddition(ax)); 110 | return additionSet; 111 | } 112 | 113 | 114 | /** 115 | * Get the set of structural removals 116 | * @return Set of structural removals 117 | */ 118 | public Set getRemovals() { 119 | Set removalSet = new HashSet(); 120 | for(OWLAxiom ax : removals) 121 | removalSet.add(new StructuralRemoval(ax)); 122 | return removalSet; 123 | } 124 | 125 | 126 | /** 127 | * Get the set of added axioms 128 | * @return Set of added axioms 129 | */ 130 | public Set getAddedAxioms() { 131 | return additions; 132 | } 133 | 134 | 135 | /** 136 | * Get the set of removed axioms 137 | * @return Set of removed axioms 138 | */ 139 | public Set getRemovedAxioms() { 140 | return removals; 141 | } 142 | 143 | 144 | /** 145 | * Get the set of shared axioms 146 | * @return Set of shared axioms 147 | */ 148 | public Set getShared() { 149 | return shared; 150 | } 151 | 152 | 153 | /** 154 | * Check if change set is empty (i.e., contains no additions or removals) 155 | */ 156 | public boolean isEmpty() { 157 | if(removals.isEmpty() && additions.isEmpty()) 158 | return true; 159 | else 160 | return false; 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/concept/ConceptDiff.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.concept; 20 | 21 | import uk.ac.manchester.cs.diff.concept.changeset.ConceptChangeSet; 22 | import uk.ac.manchester.cs.diff.output.xml.XMLConceptDiffReport; 23 | 24 | /** 25 | * @author Rafael S. Goncalves
26 | * Information Management Group (IMG)
27 | * School of Computer Science
28 | * University of Manchester
29 | */ 30 | public interface ConceptDiff { 31 | 32 | /** 33 | * Compute the concept diff and return a change set containing all differences 34 | * @return Change set with concept differences 35 | */ 36 | public ConceptChangeSet getDiff(); 37 | 38 | 39 | /** 40 | * Get an XML file which represents the change set 41 | * @return XML file containing the change set 42 | */ 43 | public XMLConceptDiffReport getXMLReport(); 44 | 45 | 46 | /** 47 | * Get a summary CSV file containing the number and types of changes 48 | * @return CSV file containing a summary of the number and types of changes 49 | */ 50 | public String getCSVChangeReport(); 51 | 52 | 53 | /** 54 | * Print the diff results to stdout 55 | */ 56 | public void printDiff(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/concept/ContentCVSDiff.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.concept; 20 | 21 | import java.util.HashMap; 22 | import java.util.HashSet; 23 | import java.util.Map; 24 | import java.util.Set; 25 | 26 | import org.semanticweb.owlapi.apibinding.OWLManager; 27 | import org.semanticweb.owlapi.model.IRI; 28 | import org.semanticweb.owlapi.model.OWLAxiom; 29 | import org.semanticweb.owlapi.model.OWLClass; 30 | import org.semanticweb.owlapi.model.OWLClassExpression; 31 | import org.semanticweb.owlapi.model.OWLEntity; 32 | import org.semanticweb.owlapi.model.OWLObjectProperty; 33 | import org.semanticweb.owlapi.model.OWLOntology; 34 | import org.semanticweb.owlapi.model.OWLOntologyManager; 35 | 36 | import uk.ac.manchester.cs.diff.concept.changeset.ConceptChangeSet; 37 | import uk.ac.manchester.cs.diff.concept.sigma.Signature; 38 | import uk.ac.manchester.cs.diff.utils.SilentChangeBroadcastStrategy; 39 | 40 | /** 41 | * @author Rafael S. Goncalves
42 | * Information Management Group (IMG)
43 | * School of Computer Science
44 | * University of Manchester
45 | */ 46 | public class ContentCVSDiff extends SubconceptDiff { 47 | private OWLOntologyManager man; 48 | 49 | /** 50 | * Constructor for contentcvs diff w.r.t. sigma := sig(O1) U sig(O2) 51 | * @param ont1 Ontology 1 52 | * @param ont2 Ontology 2 53 | * @param verbose Verbose mode 54 | */ 55 | public ContentCVSDiff(OWLOntology ont1, OWLOntology ont2, boolean verbose) { 56 | super(ont1, ont2, verbose); 57 | man = OWLManager.createOWLOntologyManager(); 58 | man.setDefaultChangeBroadcastStrategy(new SilentChangeBroadcastStrategy()); 59 | } 60 | 61 | 62 | /** 63 | * Constructor for contentcvs diff w.r.t. given signature 64 | * @param ont1 Ontology 1 65 | * @param ont2 Ontology 2 66 | * @param sig Signature (set of concept names) 67 | * @param verbose Verbose mode 68 | */ 69 | public ContentCVSDiff(OWLOntology ont1, OWLOntology ont2, Set sig, boolean verbose) { 70 | super(ont1, ont2, sig, verbose); 71 | man = OWLManager.createOWLOntologyManager(); 72 | man.setDefaultChangeBroadcastStrategy(new SilentChangeBroadcastStrategy()); 73 | } 74 | 75 | 76 | /** 77 | * Get the concept-based change set between the given ontologies 78 | * @return Concept-based change set 79 | */ 80 | public ConceptChangeSet getDiff() { 81 | long start = System.currentTimeMillis(); 82 | if(verbose) System.out.println("Input signature: sigma contains " + sigma.size() + " terms"); 83 | 84 | Map map = getSubConceptsMapping(); 85 | classifyOntologies(ont1, ont2); 86 | Set affected = computeChangeWitnesses(map); 87 | 88 | long mid = System.currentTimeMillis(); 89 | 90 | // Remove extra axioms and create fresh reasoner instances 91 | ont1.getOWLOntologyManager().removeAxioms(ont1, extraAxioms); 92 | ont2.getOWLOntologyManager().removeAxioms(ont2, extraAxioms); 93 | 94 | classifyOntologies(ont1, ont2); 95 | 96 | changeSet = splitDirectIndirectChanges(affected, ont1reasoner, ont2reasoner); 97 | long end = System.currentTimeMillis(); 98 | 99 | changeSet.setEntailmentDiffTime((mid-start)/1000.0); 100 | changeSet.setPartitioningTime((end-mid)/1000.0); 101 | 102 | if(verbose) printDiff(); 103 | System.out.println("finished (total diff time: " + (end-start)/1000.0 + " secs)"); 104 | return changeSet; 105 | } 106 | 107 | 108 | /** 109 | * Create a mapping between a new term "TempX" and each sub-concept, and add the appropriate 110 | * equivalence axioms to each ontology 111 | * @return Map of new terms to subconcepts 112 | */ 113 | private Map getSubConceptsMapping() { 114 | Set roles = new Signature().getSharedRoles(ont1, ont2); 115 | Map map = new HashMap(); 116 | 117 | Set concept_names = new HashSet(); 118 | for(OWLEntity e : sigma) { 119 | if(e.isOWLClass() && ont1.containsEntityInSignature(e) && ont2.containsEntityInSignature(e)) 120 | concept_names.add(e.asOWLClass()); 121 | } 122 | 123 | // Generate witnesses 124 | if(verbose) System.out.println("Inflating ontologies..."); 125 | Set wits = new HashSet(); 126 | wits.addAll(getExistentialWitnesses(concept_names, roles)); 127 | wits.addAll(getUniversalWitnesses(concept_names, roles)); 128 | wits.addAll(getNegationWitnesses(concept_names)); 129 | if(verbose) System.out.println("\tTotal nr. of witnesses: " + wits.size()); 130 | 131 | int counter = 1; 132 | extraAxioms = new HashSet(); 133 | for(OWLClassExpression ce : wits) { 134 | OWLClass c = df.getOWLClass(IRI.create("diffSubc_" + counter)); 135 | map.put(c, ce); 136 | OWLAxiom ax = df.getOWLEquivalentClassesAxiom(c, ce); 137 | extraAxioms.add(ax); counter++; 138 | } 139 | ont1.getOWLOntologyManager().addAxioms(ont1, extraAxioms); 140 | ont2.getOWLOntologyManager().addAxioms(ont2, extraAxioms); 141 | if(verbose) System.out.println("done (nr. of extra axioms: " + extraAxioms.size() + ")"); 142 | return map; 143 | } 144 | 145 | 146 | /** 147 | * Get the set of possible negation witnesses 148 | * @param sc Set of subconcepts 149 | * @return Set of negation witnesses 150 | */ 151 | private Set getNegationWitnesses(Set sc) { 152 | Set out = new HashSet(); 153 | for(OWLClassExpression c : sc) 154 | out.add(df.getOWLObjectComplementOf(c)); 155 | if(verbose) System.out.println("\tNegation witnesses: " + out.size()); 156 | return out; 157 | } 158 | 159 | 160 | /** 161 | * Get the set of possible existential witnesses 162 | * @param sc Set of subconcepts 163 | * @param roles Set of role names 164 | * @return Set of existential witnesses 165 | */ 166 | private Set getExistentialWitnesses(Set sc, Set roles) { 167 | Set out = new HashSet(); 168 | for(OWLClassExpression c : sc) { 169 | for(OWLObjectProperty r : roles) 170 | out.add(df.getOWLObjectSomeValuesFrom(r, c)); 171 | } 172 | if(verbose) System.out.println("\tExistential witnesses: " + out.size()); 173 | return out; 174 | } 175 | 176 | 177 | /** 178 | * Get the set of possible universal witnesses 179 | * @param sc Set of subconcepts 180 | * @param roles Set of role names 181 | * @return Set of universal witnesses 182 | */ 183 | private Set getUniversalWitnesses(Set sc, Set roles) { 184 | Set out = new HashSet(); 185 | for(OWLClassExpression c : sc) { 186 | for(OWLObjectProperty r : roles) 187 | out.add(df.getOWLObjectAllValuesFrom(r, c)); 188 | } 189 | if(verbose) System.out.println("\tUniversal witnesses: " + out.size()); 190 | return out; 191 | } 192 | } -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/concept/change/LHSConceptChange.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.concept.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLClass; 22 | 23 | import uk.ac.manchester.cs.diff.concept.witnesses.WitnessAxioms; 24 | 25 | /** 26 | * @author Rafael S. Goncalves
27 | * Information Management Group (IMG)
28 | * School of Computer Science
29 | * University of Manchester
30 | */ 31 | public class LHSConceptChange extends ConceptChange { 32 | 33 | /** 34 | * Constructor 35 | * @param c Concept name 36 | * @param specWits Witnesses for a specialisation 37 | * @param genWits Witnesses for a generalisation 38 | */ 39 | public LHSConceptChange(OWLClass c, WitnessAxioms specWits, WitnessAxioms genWits) { 40 | super(c, specWits, genWits); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/concept/change/RHSConceptChange.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.concept.change; 20 | 21 | import org.semanticweb.owlapi.model.OWLClass; 22 | 23 | import uk.ac.manchester.cs.diff.concept.witnesses.WitnessAxioms; 24 | 25 | /** 26 | * @author Rafael S. Goncalves
27 | * Information Management Group (IMG)
28 | * School of Computer Science
29 | * University of Manchester
30 | */ 31 | public class RHSConceptChange extends ConceptChange { 32 | 33 | /** 34 | * Constructor 35 | * @param c Concept name 36 | * @param specWits Witnesses for a specialisation 37 | * @param genWits Witnesses for a generalisation 38 | */ 39 | public RHSConceptChange(OWLClass c, WitnessAxioms specWits, WitnessAxioms genWits) { 40 | super(c, specWits, genWits); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/concept/sigma/Signature.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.concept.sigma; 20 | 21 | import java.io.BufferedReader; 22 | import java.io.DataInputStream; 23 | import java.io.File; 24 | import java.io.FileInputStream; 25 | import java.io.IOException; 26 | import java.io.InputStreamReader; 27 | import java.util.HashSet; 28 | import java.util.Set; 29 | 30 | import org.semanticweb.owlapi.apibinding.OWLManager; 31 | import org.semanticweb.owlapi.model.IRI; 32 | import org.semanticweb.owlapi.model.OWLClass; 33 | import org.semanticweb.owlapi.model.OWLDataFactory; 34 | import org.semanticweb.owlapi.model.OWLEntity; 35 | import org.semanticweb.owlapi.model.OWLObjectProperty; 36 | import org.semanticweb.owlapi.model.OWLOntology; 37 | 38 | /** 39 | * @author Rafael S. Goncalves
40 | * Information Management Group (IMG)
41 | * School of Computer Science
42 | * University of Manchester
43 | */ 44 | public class Signature { 45 | 46 | /** 47 | * Constructor 48 | */ 49 | public Signature() {} 50 | 51 | 52 | /** 53 | * Get signature from specified file 54 | * @param f Signature (text) file 55 | * @return Set of concepts in the file 56 | */ 57 | public Set getSignatureFromFile(File f) { 58 | OWLDataFactory df = OWLManager.createOWLOntologyManager().getOWLDataFactory(); 59 | Set sig = new HashSet(); 60 | try { 61 | FileInputStream fstream = new FileInputStream(f); 62 | DataInputStream in = new DataInputStream(fstream); 63 | BufferedReader br = new BufferedReader(new InputStreamReader(in)); 64 | 65 | String strLine; 66 | while ((strLine = br.readLine()) != null) { 67 | OWLClass c = df.getOWLClass(IRI.create(strLine)); 68 | sig.add(c); 69 | } 70 | 71 | in.close(); 72 | } catch (IOException e) { 73 | e.printStackTrace(); 74 | } 75 | return sig; 76 | } 77 | 78 | 79 | /** 80 | * Get union of both ontologies signatures 81 | * @param ont1 Ontology 1 82 | * @param ont2 Ontology 2 83 | * @return Set of terms in the signature union 84 | */ 85 | public Set getUnionSignature(OWLOntology ont1, OWLOntology ont2) { 86 | Set sig = new HashSet(); 87 | Set ont1sig = ont1.getSignature(); 88 | Set ont2sig = ont2.getSignature(); 89 | sig.addAll(ont1sig); sig.addAll(ont2sig); 90 | return sig; 91 | } 92 | 93 | 94 | /** 95 | * Get all concept names in signature union 96 | * @param ont1 Ontology 1 97 | * @param ont2 Ontology 2 98 | * @return Set of concept names in the signature union 99 | */ 100 | public Set getUnionConceptNames(OWLOntology ont1, OWLOntology ont2) { 101 | Set sig = new HashSet(); 102 | Set ont1sig = ont1.getClassesInSignature(); 103 | Set ont2sig = ont2.getClassesInSignature(); 104 | sig.addAll(ont1sig); sig.addAll(ont2sig); 105 | return sig; 106 | } 107 | 108 | 109 | /** 110 | * Get all object properties in signature union 111 | * @param ont1 Ontology 1 112 | * @param ont2 Ontology 2 113 | * @return Set of roles in the signature union 114 | */ 115 | public Set getUnionRoles(OWLOntology ont1, OWLOntology ont2) { 116 | Set set = new HashSet(); 117 | set.addAll(ont1.getObjectPropertiesInSignature()); 118 | set.addAll(ont2.getObjectPropertiesInSignature()); 119 | return set; 120 | } 121 | 122 | 123 | /** 124 | * Get intersection of both ontologies signatures 125 | * @param ont1 Ontology 1 126 | * @param ont2 Ontology 2 127 | * @return Set of terms in the signature intersection 128 | */ 129 | public Set getSharedSignature(OWLOntology ont1, OWLOntology ont2) { 130 | Set sig = new HashSet(); 131 | Set ont1sig = ont1.getSignature(); 132 | Set ont2sig = ont2.getSignature(); 133 | for(OWLEntity e : ont1sig) { 134 | if (ont2sig.contains(e)) 135 | sig.add(e); 136 | } 137 | return sig; 138 | } 139 | 140 | 141 | /** 142 | * Get shared concept names between given ontologies 143 | * @param ont1 Ontology 1 144 | * @param ont2 Ontology 2 145 | * @return Set of concept names in the signature intersection 146 | */ 147 | public Set getSharedConceptNames(OWLOntology ont1, OWLOntology ont2) { 148 | Set sig = new HashSet(); 149 | Set ont1sig = ont1.getClassesInSignature(); 150 | Set ont2sig = ont2.getClassesInSignature(); 151 | for(OWLClass c : ont1sig) { 152 | if(ont2sig.contains(c)) 153 | sig.add(c); 154 | } 155 | return sig; 156 | } 157 | 158 | 159 | /** 160 | * Get shared roles between given ontologies 161 | * @param ont1 Ontology 1 162 | * @param ont2 Ontology 2 163 | * @return Set of roles in the signature intersection 164 | */ 165 | public Set getSharedRoles(OWLOntology ont1, OWLOntology ont2) { 166 | Set sig = new HashSet(); 167 | Set ont1sig = ont1.getObjectPropertiesInSignature(); 168 | Set ont2sig = ont2.getObjectPropertiesInSignature(); 169 | for(OWLObjectProperty c : ont1sig) { 170 | if(ont2sig.contains(c)) 171 | sig.add(c); 172 | } 173 | return sig; 174 | } 175 | } 176 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/concept/witnesses/WitnessAxioms.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.concept.witnesses; 20 | 21 | import java.util.Set; 22 | 23 | import org.semanticweb.owlapi.model.OWLAxiom; 24 | 25 | /** 26 | * @author Rafael S. Goncalves
27 | * Information Management Group (IMG)
28 | * School of Computer Science
29 | * University of Manchester
30 | */ 31 | public class WitnessAxioms { 32 | private Set direct, indirect; 33 | 34 | /** 35 | * Constructor 36 | * @param direct Set of direct witness axioms 37 | * @param indirect Set of indirect witness axioms 38 | */ 39 | public WitnessAxioms(Set direct, Set indirect) { 40 | this.direct = direct; 41 | this.indirect = indirect; 42 | } 43 | 44 | 45 | /** 46 | * Get the set of direct witness axioms 47 | * @return Set of direct witness axioms 48 | */ 49 | public Set getDirectWitnesses() { 50 | return direct; 51 | } 52 | 53 | 54 | /** 55 | * Get the set of indirect witness axioms 56 | * @return Set of indirect witness axioms 57 | */ 58 | public Set getIndirectWitnesses() { 59 | return indirect; 60 | } 61 | 62 | 63 | /** 64 | * Check if there are any witness axioms (direct or otherwise) 65 | * @return true if this contains any witness axioms 66 | */ 67 | public boolean isEmpty() { 68 | if((direct == null || direct.isEmpty()) && (indirect == null || indirect.isEmpty())) 69 | return true; 70 | else 71 | return false; 72 | } 73 | } -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/concept/witnesses/WitnessConcepts.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.concept.witnesses; 20 | 21 | import java.util.Set; 22 | 23 | import org.semanticweb.owlapi.model.OWLClassExpression; 24 | 25 | /** 26 | * @author Rafael S. Goncalves
27 | * Information Management Group (IMG)
28 | * School of Computer Science
29 | * University of Manchester
30 | */ 31 | public class WitnessConcepts { 32 | private Set lhsWit, rhsWit; 33 | 34 | /** 35 | * Constructor 36 | * @param lhsWit Ontology 1 (LHS) witnesses 37 | * @param rhsWit Ontology 2 (RHS) witnesses 38 | */ 39 | public WitnessConcepts(Set lhsWit, Set rhsWit) { 40 | this.lhsWit = lhsWit; 41 | this.rhsWit = rhsWit; 42 | } 43 | 44 | 45 | /** 46 | * Get ontology 1 (LHS) witnesses 47 | * @return Ontology 1 witnesses 48 | */ 49 | public Set getLHSWitnesses() { 50 | return lhsWit; 51 | } 52 | 53 | 54 | /** 55 | * Get ontology 2 (RHS) witnesses 56 | * @return Ontology 2 witnesses 57 | */ 58 | public Set getRHSWitnesses() { 59 | return rhsWit; 60 | } 61 | 62 | 63 | /** 64 | * Check if there are any concept witnesses, either LHS or RHS 65 | * @return true if there any witnesses, false otherwise 66 | */ 67 | public boolean isEmpty() { 68 | if(lhsWit.isEmpty() && rhsWit.isEmpty()) 69 | return true; 70 | else 71 | return false; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/concept/witnesses/WitnessGroup.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.concept.witnesses; 20 | 21 | import java.util.HashSet; 22 | import java.util.Map; 23 | import java.util.Set; 24 | 25 | import org.semanticweb.owlapi.model.OWLAxiom; 26 | import org.semanticweb.owlapi.model.OWLClass; 27 | 28 | /** 29 | * @author Rafael S. Goncalves
30 | * Information Management Group (IMG)
31 | * School of Computer Science
32 | * University of Manchester
33 | */ 34 | public class WitnessGroup { 35 | private Map> direct, indirect; 36 | 37 | /** 38 | * Constructor 39 | * @param direct Map of concepts to their direct change witnesses 40 | * @param indirect Map of concepts to their indirect change witnesses 41 | */ 42 | public WitnessGroup(Map> direct, Map> indirect) { 43 | this.direct = direct; 44 | this.indirect = indirect; 45 | } 46 | 47 | 48 | /** 49 | * Get the map of concepts to their direct change witnesses 50 | * @return Map of concepts to their direct change witnesses 51 | */ 52 | public Map> getDirectWitnesses() { 53 | return direct; 54 | } 55 | 56 | 57 | /** 58 | * Get the map of concepts to their indirect change witnesses 59 | * @return Map of concepts to their indirect change witnesses 60 | */ 61 | public Map> getIndirectWitnesses() { 62 | return indirect; 63 | } 64 | 65 | 66 | /** 67 | * Get the set of direct witness axioms to the change of a given concept 68 | * @param c Concept 69 | * @return Set of direct witness axioms 70 | */ 71 | public Set getDirectWitnesses(OWLClass c) { 72 | Set out = new HashSet(); 73 | if(direct.get(c) != null) 74 | out.addAll(direct.get(c)); 75 | return out; 76 | } 77 | 78 | 79 | /** 80 | * Get the set of indirect witness axioms to the change of a given concept 81 | * @param c Concept 82 | * @return Set of indirect witness axioms 83 | */ 84 | public Set getIndirectWitnesses(OWLClass c) { 85 | Set out = new HashSet(); 86 | if(indirect.get(c) != null) 87 | out.addAll(indirect.get(c)); 88 | return out; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/exception/DuplicateArgumentException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.exception; 2 | 3 | 4 | public class DuplicateArgumentException extends RuntimeException { 5 | private static final long serialVersionUID = 1L; 6 | 7 | 8 | /** 9 | * Constructor 10 | * @see RuntimeException#RuntimeException() 11 | */ 12 | public DuplicateArgumentException() { 13 | super(); 14 | } 15 | 16 | 17 | /** 18 | * Constructor 19 | * @param s Message 20 | * @see RuntimeException#RuntimeException(String s) 21 | */ 22 | public DuplicateArgumentException(String s) { 23 | super(s); 24 | } 25 | 26 | 27 | /** 28 | * Constructor 29 | * @param s Message 30 | * @param throwable Throwable 31 | * @see RuntimeException#RuntimeException(String s, Throwable throwable) 32 | */ 33 | public DuplicateArgumentException(String s, Throwable throwable) { 34 | super(s, throwable); 35 | } 36 | 37 | 38 | /** 39 | * Constructor 40 | * @param throwable Throwable 41 | * @see RuntimeException#RuntimeException(Throwable throwable) 42 | */ 43 | public DuplicateArgumentException(Throwable throwable) { 44 | super(throwable); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/exception/InconsistentOntologyException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.exception; 2 | 3 | 4 | public class InconsistentOntologyException extends RuntimeException { 5 | private static final long serialVersionUID = 1L; 6 | 7 | 8 | /** 9 | * Constructor 10 | * @see RuntimeException#RuntimeException() 11 | */ 12 | public InconsistentOntologyException() { 13 | super(); 14 | } 15 | 16 | 17 | /** 18 | * Constructor 19 | * @param s Message 20 | * @see RuntimeException#RuntimeException(String s) 21 | */ 22 | public InconsistentOntologyException(String s) { 23 | super(s); 24 | } 25 | 26 | 27 | /** 28 | * Constructor 29 | * @param s Message 30 | * @param throwable Throwable 31 | * @see RuntimeException#RuntimeException(String s, Throwable throwable) 32 | */ 33 | public InconsistentOntologyException(String s, Throwable throwable) { 34 | super(s, throwable); 35 | } 36 | 37 | 38 | /** 39 | * Constructor 40 | * @param throwable Throwable 41 | * @see RuntimeException#RuntimeException(Throwable throwable) 42 | */ 43 | public InconsistentOntologyException(Throwable throwable) { 44 | super(throwable); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/exception/InsufficientArgumentsException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.exception; 2 | 3 | 4 | public class InsufficientArgumentsException extends RuntimeException { 5 | private static final long serialVersionUID = 1L; 6 | 7 | 8 | /** 9 | * Constructor 10 | * @see RuntimeException#RuntimeException() 11 | */ 12 | public InsufficientArgumentsException() { 13 | super(); 14 | } 15 | 16 | 17 | /** 18 | * Constructor 19 | * @param s Message 20 | * @see RuntimeException#RuntimeException(String s) 21 | */ 22 | public InsufficientArgumentsException(String s) { 23 | super(s); 24 | } 25 | 26 | 27 | /** 28 | * Constructor 29 | * @param s Message 30 | * @param throwable Throwable 31 | * @see RuntimeException#RuntimeException(String s, Throwable throwable) 32 | */ 33 | public InsufficientArgumentsException(String s, Throwable throwable) { 34 | super(s, throwable); 35 | } 36 | 37 | 38 | /** 39 | * Constructor 40 | * @param throwable Throwable 41 | * @see RuntimeException#RuntimeException(Throwable throwable) 42 | */ 43 | public InsufficientArgumentsException(Throwable throwable) { 44 | super(throwable); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/exception/MissingArgumentException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.exception; 2 | 3 | 4 | public class MissingArgumentException extends RuntimeException { 5 | private static final long serialVersionUID = 1L; 6 | 7 | 8 | /** 9 | * Constructor 10 | * @see RuntimeException#RuntimeException() 11 | */ 12 | public MissingArgumentException() { 13 | super(); 14 | } 15 | 16 | 17 | /** 18 | * Constructor 19 | * @param s Message 20 | * @see RuntimeException#RuntimeException(String s) 21 | */ 22 | public MissingArgumentException(String s) { 23 | super(s); 24 | } 25 | 26 | 27 | /** 28 | * Constructor 29 | * @param s Message 30 | * @param throwable Throwable 31 | * @see RuntimeException#RuntimeException(String s, Throwable throwable) 32 | */ 33 | public MissingArgumentException(String s, Throwable throwable) { 34 | super(s, throwable); 35 | } 36 | 37 | 38 | /** 39 | * Constructor 40 | * @param throwable Throwable 41 | * @see RuntimeException#RuntimeException(Throwable throwable) 42 | */ 43 | public MissingArgumentException(Throwable throwable) { 44 | super(throwable); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/exception/NotImplementedException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.exception; 2 | 3 | 4 | public class NotImplementedException extends RuntimeException { 5 | private static final long serialVersionUID = 1L; 6 | 7 | 8 | /** 9 | * Constructor 10 | * @see RuntimeException#RuntimeException() 11 | */ 12 | public NotImplementedException() { 13 | super(); 14 | } 15 | 16 | 17 | /** 18 | * Constructor 19 | * @param s Message 20 | * @see RuntimeException#RuntimeException(String s) 21 | */ 22 | public NotImplementedException(String s) { 23 | super(s); 24 | } 25 | 26 | 27 | /** 28 | * Constructor 29 | * @param s Message 30 | * @param throwable Throwable 31 | * @see RuntimeException#RuntimeException(String s, Throwable throwable) 32 | */ 33 | public NotImplementedException(String s, Throwable throwable) { 34 | super(s, throwable); 35 | } 36 | 37 | 38 | /** 39 | * Constructor 40 | * @param throwable Throwable 41 | * @see RuntimeException#RuntimeException(Throwable throwable) 42 | */ 43 | public NotImplementedException(Throwable throwable) { 44 | super(throwable); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/exception/UnrecognizedArgumentException.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.exception; 2 | 3 | 4 | public class UnrecognizedArgumentException extends RuntimeException { 5 | private static final long serialVersionUID = 1L; 6 | 7 | 8 | /** 9 | * Constructor 10 | * @see RuntimeException#RuntimeException() 11 | */ 12 | public UnrecognizedArgumentException() { 13 | super(); 14 | } 15 | 16 | 17 | /** 18 | * Constructor 19 | * @param s Message 20 | * @see RuntimeException#RuntimeException(String s) 21 | */ 22 | public UnrecognizedArgumentException(String s) { 23 | super(s); 24 | } 25 | 26 | 27 | /** 28 | * Constructor 29 | * @param s Message 30 | * @param throwable Throwable 31 | * @see RuntimeException#RuntimeException(String s, Throwable throwable) 32 | */ 33 | public UnrecognizedArgumentException(String s, Throwable throwable) { 34 | super(s, throwable); 35 | } 36 | 37 | 38 | /** 39 | * Constructor 40 | * @param throwable Throwable 41 | * @see RuntimeException#RuntimeException(Throwable throwable) 42 | */ 43 | public UnrecognizedArgumentException(Throwable throwable) { 44 | super(throwable); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/justifications/LaconicJustificationFinder.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.justifications; 20 | 21 | import java.util.HashSet; 22 | import java.util.Set; 23 | import java.util.Timer; 24 | import java.util.TimerTask; 25 | 26 | import org.semanticweb.owl.explanation.api.Explanation; 27 | import org.semanticweb.owl.explanation.api.ExplanationGenerator; 28 | import org.semanticweb.owl.explanation.api.ExplanationGeneratorFactory; 29 | import org.semanticweb.owl.explanation.api.ExplanationManager; 30 | import org.semanticweb.owl.explanation.impl.laconic.LaconicExplanationGeneratorFactory; 31 | import org.semanticweb.owlapi.apibinding.OWLManager; 32 | import org.semanticweb.owlapi.io.IRIDocumentSource; 33 | import org.semanticweb.owlapi.model.IRI; 34 | import org.semanticweb.owlapi.model.OWLAxiom; 35 | import org.semanticweb.owlapi.model.OWLLogicalAxiom; 36 | import org.semanticweb.owlapi.model.OWLOntology; 37 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; 38 | import org.semanticweb.owlapi.model.OWLOntologyManager; 39 | import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; 40 | 41 | /** 42 | * @author Rafael S. Goncalves
43 | * Information Management Group (IMG)
44 | * School of Computer Science
45 | * University of Manchester
46 | */ 47 | public class LaconicJustificationFinder { 48 | private OWLReasonerFactory rf; 49 | private ExplanationGeneratorFactory regFac, lacFac; 50 | private OWLOntology ent, just; 51 | private final long timeout = 1000; // milliseconds 52 | 53 | /** 54 | * Constructor 55 | * @param ent Entailment 56 | * @param just Justification 57 | */ 58 | public LaconicJustificationFinder(OWLOntology ent, OWLOntology just) { 59 | this.ent = ent; 60 | this.just = just; 61 | rf = new org.semanticweb.HermiT.Reasoner.ReasonerFactory(); 62 | regFac = ExplanationManager.createExplanationGeneratorFactory(rf); 63 | lacFac = new LaconicExplanationGeneratorFactory(regFac); 64 | } 65 | 66 | 67 | /** 68 | * Get laconic justification 69 | * @return Justification 70 | */ 71 | public Explanation getLaconicJustification() { 72 | // Set timeout 73 | Timer t = new Timer(true); 74 | t.schedule(interrupt, timeout); 75 | 76 | // Find laconic justs 77 | ExplanationGenerator lacGen = lacFac.createExplanationGenerator(just.getAxioms()); 78 | Set> results = new HashSet>(); 79 | Set axs = ent.getLogicalAxioms(); 80 | for(OWLLogicalAxiom ax : axs) { 81 | try { 82 | results.addAll(lacGen.getExplanations(ax, 1)); 83 | } /* Do nothing */ 84 | catch(OutOfMemoryError e) {} 85 | catch(IllegalArgumentException e) {} 86 | } 87 | return results.iterator().next(); 88 | } 89 | 90 | 91 | /** 92 | * Get laconic justification as an ontology string 93 | * @return Laconic justification as an ontology string 94 | */ 95 | public String getLaconicJustificationAsString() { 96 | return getOntologyAsString(getLaconicJustification().getAxioms()); 97 | } 98 | 99 | 100 | /** 101 | * Get set of axioms as an ontology string 102 | * @param axioms Set of axioms 103 | * @return String representing an ontology containing the specified axioms 104 | */ 105 | private String getOntologyAsString(Set axioms) { 106 | String out = "Ontology("; 107 | for(OWLAxiom ax : axioms) 108 | out += ax.toString() + "\n"; 109 | out += ")"; 110 | return out; 111 | } 112 | 113 | 114 | /** 115 | * Interrupt trigger 116 | */ 117 | private TimerTask interrupt = new TimerTask() { 118 | @Override 119 | public void run() { 120 | System.exit(0); 121 | } 122 | }; 123 | 124 | 125 | /** 126 | * Main 127 | * @param args Arguments 128 | */ 129 | public static void main(String[] args) { 130 | String entailment = args[0]; 131 | String justification = args[1]; 132 | OWLOntologyManager man = OWLManager.createOWLOntologyManager(); 133 | OWLOntology ent = null, just = null; 134 | try { 135 | ent = man.loadOntologyFromOntologyDocument(new IRIDocumentSource(IRI.create("file:" + entailment))); 136 | just = man.loadOntologyFromOntologyDocument(new IRIDocumentSource(IRI.create("file:" + justification))); 137 | } catch (OWLOntologyCreationException e) { 138 | e.printStackTrace(); 139 | } 140 | if(ent != null && just != null) { 141 | LaconicJustificationFinder finder = new LaconicJustificationFinder(ent, just); 142 | String out = finder.getLaconicJustificationAsString(); 143 | System.out.println(out); 144 | } 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/output/GenSymShortFormProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.output; 20 | 21 | import java.util.HashMap; 22 | 23 | import org.semanticweb.owlapi.model.OWLEntity; 24 | import org.semanticweb.owlapi.util.ShortFormProvider; 25 | import org.semanticweb.owlapi.util.SimpleShortFormProvider; 26 | 27 | /** 28 | * @author Rafael S. Goncalves
29 | * Information Management Group (IMG)
30 | * School of Computer Science
31 | * University of Manchester
32 | */ 33 | public class GenSymShortFormProvider implements ShortFormProvider { 34 | private HashMap map; 35 | 36 | public GenSymShortFormProvider(HashMap map) { 37 | this.map = map; 38 | } 39 | 40 | @Override 41 | public void dispose() { 42 | // Do nothing 43 | } 44 | 45 | @Override 46 | public String getShortForm(OWLEntity arg0) { 47 | String output = ""; 48 | SimpleShortFormProvider fp = new SimpleShortFormProvider(); 49 | if(map.get(arg0) != null) 50 | output = map.get(arg0); 51 | else 52 | output = fp.getShortForm(arg0); 53 | return output; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/output/LabelShortFormProvider.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.output; 20 | 21 | import java.util.HashMap; 22 | 23 | import org.semanticweb.owlapi.model.OWLEntity; 24 | import org.semanticweb.owlapi.util.ShortFormProvider; 25 | import org.semanticweb.owlapi.util.SimpleShortFormProvider; 26 | 27 | /** 28 | * @author Rafael S. Goncalves
29 | * Information Management Group (IMG)
30 | * School of Computer Science
31 | * University of Manchester
32 | */ 33 | public class LabelShortFormProvider implements ShortFormProvider { 34 | private HashMap map; 35 | private SimpleShortFormProvider fp; 36 | 37 | /** 38 | * Constructor 39 | * @param map Map of entities to labels 40 | */ 41 | public LabelShortFormProvider(HashMap map) { 42 | this.map = map; 43 | fp = new SimpleShortFormProvider(); 44 | } 45 | 46 | @Override 47 | public void dispose() { 48 | // Do nothing 49 | } 50 | 51 | @Override 52 | public String getShortForm(OWLEntity arg0) { 53 | String output = ""; 54 | if(map.get(arg0) != null) 55 | output = map.get(arg0); 56 | else 57 | output = fp.getShortForm(arg0); 58 | return output; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/output/OutputHandler.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.output; 2 | 3 | import java.io.File; 4 | import java.io.FileWriter; 5 | import java.io.IOException; 6 | import java.net.URL; 7 | import java.text.SimpleDateFormat; 8 | import java.util.Calendar; 9 | import java.util.Enumeration; 10 | 11 | import javax.xml.transform.TransformerException; 12 | 13 | import org.apache.commons.io.FileUtils; 14 | import org.w3c.dom.Document; 15 | 16 | import uk.ac.manchester.cs.diff.EccoSettings; 17 | import uk.ac.manchester.cs.diff.exception.NotImplementedException; 18 | import uk.ac.manchester.cs.diff.output.xml.XMLDiffReport; 19 | 20 | /** 21 | * @author Rafael S. Goncalves
22 | * Stanford Center for Biomedical Informatics Research (BMIR)
23 | * School of Medicine, Stanford University
24 | */ 25 | public class OutputHandler { 26 | private EccoSettings settings; 27 | private String outputDir, jarName = "ecco.jar!", classes = "classes", xsltPath; 28 | 29 | 30 | /** 31 | * Constructor 32 | * @param settings ecco settings 33 | */ 34 | public OutputHandler(EccoSettings settings) { 35 | this.settings = settings; 36 | outputDir = settings.getOutputDirectory(); 37 | xsltPath = setXSLTFilePath(); 38 | } 39 | 40 | 41 | /** 42 | * Set the path to the XSLT file 43 | */ 44 | private String setXSLTFilePath() { 45 | if(settings.getXSLTFilePath() != null) return settings.getXSLTFilePath(); 46 | 47 | String xsltFileName = ""; 48 | switch(settings.getTransformType()) { 49 | case AXIOM: 50 | xsltFileName = "xslt_client.xsl"; break; 51 | case CONCEPT: 52 | // TODO: not implemented 53 | throw new NotImplementedException("not implemented".toUpperCase()); 54 | case UNITY: 55 | xsltFileName = "xslt_full_client.xsl"; break; 56 | default: break; 57 | } 58 | getClass().getClassLoader(); 59 | String path = ClassLoader.getSystemResource("xslt" + File.separator + xsltFileName).getPath(); 60 | if(path.contains(jarName)) 61 | path = path.replace(jarName, "classes"); 62 | settings.setXSLTFilePath(path); 63 | return path; 64 | } 65 | 66 | 67 | /** 68 | * Get the XSLT file path defined here 69 | * @return XSLT file path as a string 70 | */ 71 | public String getXSLTFilePath() { 72 | return xsltPath; 73 | } 74 | 75 | 76 | /** 77 | * Process local output by saving XML change sets, CSV log, and, if applicable, the HTML transformation 78 | * @param report XML report instance 79 | * @param includeTimestamp true if timestamp should be included in file name(s), false otherwise 80 | */ 81 | public void saveXMLDocuments(XMLDiffReport report, boolean includeTimestamp) { 82 | String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmmss").format(Calendar.getInstance().getTime()); 83 | saveDocumentToFile(report, report.getXMLDocumentUsingTermNames(), outputDir, 84 | (includeTimestamp ? "_names_" + timeStamp : "_names")); // term name based document 85 | saveDocumentToFile(report, report.getXMLDocumentUsingLabels(), outputDir, 86 | (includeTimestamp ? "_labels_" + timeStamp : "_labels")); // label based document 87 | saveDocumentToFile(report, report.getXMLDocumentUsingGenSyms(), outputDir, 88 | (includeTimestamp ? "_gensyms_" + timeStamp : "_gensyms")); // gensym based document 89 | } 90 | 91 | 92 | /** 93 | * Serialize the given XML file and, if applicable, transform it to HTML and serialize the file 94 | * @param report XMLReport instance 95 | * @param doc XML document 96 | * @param outputDir Output directory 97 | * @param suffix Suffix for the different variants of the XML report 98 | * @throws TransformerException Transformer exception 99 | */ 100 | private void saveDocumentToFile(XMLDiffReport report, Document doc, String outputDir, String suffix) { 101 | String docString = report.getReportAsString(doc); 102 | saveStringToFile(outputDir, "eccoChangeSet" + suffix + ".xml", docString); 103 | if(settings.isTransformingToHTML()) { 104 | String html = report.getReportAsHTML(doc, settings.getXSLTFilePath()); 105 | saveStringToFile(outputDir, "index" + suffix + ".html", html); 106 | } 107 | } 108 | 109 | 110 | /** 111 | * Serialize a given string to the specified path 112 | * @param outputDir Output directory 113 | * @param filename File name 114 | * @param content String to output 115 | */ 116 | public void saveStringToFile(String outputDir, String filename, String content) { 117 | try { 118 | new File(outputDir).mkdirs(); 119 | FileWriter fw = new FileWriter(outputDir + File.separator + filename, false); 120 | fw.write(content); 121 | fw.close(); 122 | } catch (IOException e) { 123 | e.printStackTrace(); 124 | } 125 | } 126 | 127 | 128 | /** 129 | * Copy supporting resources: CSS, JavaScript, and image files 130 | */ 131 | public void copySupportingDocuments() { 132 | try { 133 | copySupportingDocuments("css"); 134 | copySupportingDocuments("js"); 135 | copySupportingDocuments("images"); 136 | } catch (IOException e) { 137 | e.printStackTrace(); 138 | } 139 | } 140 | 141 | 142 | /** 143 | * Copy supporting documents in the specified folder that are necessary to browse the output 144 | * @param folderName Type of file 145 | * @throws IOException IO exception 146 | */ 147 | private void copySupportingDocuments(String folderName) throws IOException { 148 | Enumeration e = ClassLoader.getSystemResources(folderName); 149 | while (e.hasMoreElements()) { 150 | String path = e.nextElement().getPath(); 151 | if(path.contains(jarName)) { 152 | path = path.replace(jarName, classes); 153 | if(path.startsWith("file:")) 154 | path = path.replace("file:", ""); 155 | } 156 | File f = new File(path); 157 | FileUtils.copyDirectory(f, new File(outputDir + f.getName())); 158 | } 159 | } 160 | } -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/output/csv/CSVAxiomDiffReport.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.output.csv; 20 | 21 | import uk.ac.manchester.cs.diff.axiom.changeset.AxiomChangeSet; 22 | import uk.ac.manchester.cs.diff.axiom.changeset.CategorisedChangeSet; 23 | import uk.ac.manchester.cs.diff.axiom.changeset.LogicalChangeSet; 24 | import uk.ac.manchester.cs.diff.axiom.changeset.StructuralChangeSet; 25 | 26 | /** 27 | * @author Rafael S. Goncalves
28 | * Information Management Group (IMG)
29 | * School of Computer Science
30 | * University of Manchester
31 | */ 32 | public class CSVAxiomDiffReport { 33 | private String header, row; 34 | 35 | /** 36 | * Constructor 37 | */ 38 | public CSVAxiomDiffReport() { 39 | header = "\n"; row = ""; 40 | } 41 | 42 | 43 | /** 44 | * Get a CSV-formatted change report 45 | * @param changeSet Change set 46 | * @return Change report as a CSV-formatted string 47 | */ 48 | public String getReport(AxiomChangeSet changeSet) { 49 | String report = null; 50 | if(changeSet instanceof StructuralChangeSet) 51 | report = getStructuralChangeSetReport((StructuralChangeSet)changeSet); 52 | else if(changeSet instanceof LogicalChangeSet) { 53 | LogicalChangeSet logicalChangeSet = (LogicalChangeSet)changeSet; 54 | getStructuralChangeSetReport(logicalChangeSet.getStructuralChangeSet()); 55 | report = getLogicalChangeSetReport(logicalChangeSet); 56 | } 57 | else if(changeSet instanceof CategorisedChangeSet) { 58 | CategorisedChangeSet categorisedChangeSet = (CategorisedChangeSet)changeSet; 59 | getStructuralChangeSetReport(categorisedChangeSet.getStructuralChangeSet()); 60 | getLogicalChangeSetReport(categorisedChangeSet.getLogicalChangeSet()); 61 | report = getCategorisedChangeSetReport(categorisedChangeSet); 62 | } 63 | return report; 64 | } 65 | 66 | 67 | /** 68 | * Get a CSV report of a structural change set 69 | * @param stChangeSet Structural change set 70 | * @return CSV structural change set report 71 | */ 72 | private String getStructuralChangeSetReport(StructuralChangeSet stChangeSet) { 73 | header += "Ontology 1,Ontology 2,Structurally Equivalent,Structural Additions,Structural Removals,Shared Axioms,Structural Diff Time"; 74 | row += stChangeSet.getOntology1FileName() + ","; 75 | row += stChangeSet.getOntology2FileName() + ","; 76 | row += (stChangeSet.isEmpty() ? "true" : "false") + ","; 77 | row += stChangeSet.getAddedAxioms().size() + ","; 78 | row += stChangeSet.getRemovedAxioms().size() + ","; 79 | row += stChangeSet.getShared().size() + ","; 80 | row += stChangeSet.getOperationTime(); 81 | return header + "\n" + row; 82 | } 83 | 84 | 85 | /** 86 | * Get a CSV report of a logical change set 87 | * @param logChangeSet Logical change set 88 | * @return CSV logical change set report 89 | */ 90 | private String getLogicalChangeSetReport(LogicalChangeSet logChangeSet) { 91 | header += ",Effectual Additions,Ineffectual Additions,Effectual Removals,Ineffectual Removals,Logical Diff Time"; 92 | row += "," + logChangeSet.getEffectualAdditionAxioms().size(); 93 | row += "," + logChangeSet.getIneffectualAdditionAxioms().size(); 94 | row += "," + logChangeSet.getEffectualRemovalAxioms().size(); 95 | row += "," + logChangeSet.getIneffectualRemovalAxioms().size(); 96 | row += "," + logChangeSet.getOperationTime(); 97 | return header + "\n" + row; 98 | } 99 | 100 | 101 | /** 102 | * Get a CSV report of a categorised change set 103 | * @param catChangeSet Categorised change set 104 | * @return CSV categorised change set report 105 | */ 106 | private String getCategorisedChangeSetReport(CategorisedChangeSet catChangeSet) { 107 | header += ",Strengthening,Strengthening NT,Extended Definition,Extended Definition NT,Pure Addition,Pure Addition NT,New Description,EAC Time," + 108 | "Added Rewrite,Added Standing Redundancy,Added Prospective Redundancy,Added Reshuffle,New,IAC Time,Just Find Time," + 109 | "Lac Just Time,Weakening,Weakening RT,Reduced Definition,Reduced Definition RT,Pure Removal,Pure Removal RT,Retired Description,ERC Time," + 110 | "Removed Rewrite,Removed Standing Redundancy,Removed Prospective Redundancy,Removed Reshuffle,New,IRC Time,Just Find Time," + 111 | "Lac Just Time,Total Time"; 112 | // Effectual additions 113 | row += "," + catChangeSet.getStrengthenings().size(); 114 | row += "," + catChangeSet.getStrengtheningsWithNewTerms().size(); 115 | row += "," + catChangeSet.getAddedModifiedDefinitions().size(); 116 | row += "," + catChangeSet.getAddedModifiedDefinitionsWithNewTerms().size(); 117 | row += "," + catChangeSet.getPureAdditions().size(); 118 | row += "," + catChangeSet.getPureAdditionsWithNewTerms().size(); 119 | row += "," + catChangeSet.getNewDescriptions().size(); 120 | row += "," + catChangeSet.getEffectualAdditionCategorisationTime(); 121 | // Ineffectual additions 122 | row += "," + catChangeSet.getAddedRewrites().size(); 123 | row += "," + catChangeSet.getAddedRedundancies().size(); 124 | row += "," + catChangeSet.getAddedProspectiveRedundancies().size(); 125 | row += "," + catChangeSet.getAddedReshuffleRedundancies().size(); 126 | row += "," + catChangeSet.getAddedProspectiveNewRedundancies().size(); 127 | // row += "," + catChangeSet.getAddedNovelRedundancies().size(); 128 | // row += "," + catChangeSet.getAddedPseudoNovelRedundancies().size(); 129 | row += "," + catChangeSet.getIneffectualAdditionCategorisationTime(); 130 | row += "," + catChangeSet.getIneffectualAdditionJustificationFindingTime(); 131 | row += "," + catChangeSet.getIneffectualAdditionLaconicJustificationFindingTime(); 132 | // Effectual removals 133 | row += "," + catChangeSet.getWeakenings().size(); 134 | row += "," + catChangeSet.getWeakeningsWithRetiredTerms().size(); 135 | row += "," + catChangeSet.getRemovedModifiedDefinitions().size(); 136 | row += "," + catChangeSet.getRemovedModifiedDefinitionsWithRetiredTerms().size(); 137 | row += "," + catChangeSet.getPureRemovals().size(); 138 | row += "," + catChangeSet.getPureRemovalsWithRetiredTerms().size(); 139 | row += "," + catChangeSet.getRetiredDescriptions().size(); 140 | row += "," + catChangeSet.getEffectualRemovalCategorisationTime(); 141 | // Ineffectual removals 142 | row += "," + catChangeSet.getRemovedRewrites().size(); 143 | row += "," + catChangeSet.getRemovedRedundancies().size(); 144 | row += "," + catChangeSet.getRemovedProspectiveRedundancies().size(); 145 | row += "," + catChangeSet.getRemovedReshuffleRedundancies().size(); 146 | row += "," + catChangeSet.getRemovedProspectiveNewRedundancies().size(); 147 | // row += "," + catChangeSet.getRemovedNovelRedundancies().size(); 148 | // row += "," + catChangeSet.getRemovedPseudoNovelRedundancies().size(); 149 | row += "," + catChangeSet.getIneffectualRemovalCategorisationTime(); 150 | row += "," + catChangeSet.getIneffectualRemovalJustificationFindingTime(); 151 | row += "," + catChangeSet.getIneffectualRemovalLaconicJustificationFindingTime(); 152 | 153 | row += "," + catChangeSet.getOperationTime(); 154 | return header + "\n" + row; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/output/csv/CSVConceptDiffReport.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.output.csv; 20 | 21 | import uk.ac.manchester.cs.diff.concept.changeset.ConceptChangeSet; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class CSVConceptDiffReport { 30 | private String header, row; 31 | 32 | /** 33 | * Constructor 34 | */ 35 | public CSVConceptDiffReport() { 36 | header = "\n"; row = ""; 37 | } 38 | 39 | 40 | /** 41 | * Get a CSV-formatted change report 42 | * @param changeSet Concept change set 43 | * @return Change report as a CSV-formatted string 44 | */ 45 | public String getReport(ConceptChangeSet changeSet) { 46 | header += "\nOntology 1,Ontology 2,Specialised,Generalised,Affected,Entailment diff time,Specialisations,,,,,Generalisations,,,,,Partitioning time\n"; 47 | header += ",,,,,,Direct,Indirect,Mix,Purely Direct,Purely Indirect,Direct,Indirect,Mix,Purely Direct,Purely Indirect"; 48 | 49 | row += "ont1,ont2" + 50 | "," + changeSet.getAllSpecialisedConcepts().size() + 51 | "," + changeSet.getAllGeneralisedConcepts().size() + 52 | "," + changeSet.getAllAffectedConcepts().size() + 53 | "," + changeSet.getEntailmentDiffTime() + 54 | "," + changeSet.getAllDirectlySpecialised().size() + 55 | "," + changeSet.getAllIndirectlySpecialised().size() + 56 | "," + changeSet.getAllMixedSpecialised().size() + 57 | "," + changeSet.getAllPurelyDirectlySpecialised().size() + 58 | "," + changeSet.getAllPurelyIndirectlySpecialised().size() + 59 | "," + changeSet.getAllDirectlyGeneralised().size() + 60 | "," + changeSet.getAllIndirectlyGeneralised().size() + 61 | "," + changeSet.getAllMixedGeneralised().size() + 62 | "," + changeSet.getAllPurelyDirectlyGeneralised().size() + 63 | "," + changeSet.getAllPurelyIndirectlyGeneralised().size() + 64 | "," + changeSet.getPartitioningTime(); 65 | 66 | return header + "\n" + row; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/output/csv/CSVDiffReport.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.output.csv; 2 | 3 | import uk.ac.manchester.cs.diff.axiom.changeset.AxiomChangeSet; 4 | import uk.ac.manchester.cs.diff.concept.changeset.ConceptChangeSet; 5 | import uk.ac.manchester.cs.diff.exception.NotImplementedException; 6 | import uk.ac.manchester.cs.diff.output.xml.XMLAxiomDiffReport; 7 | import uk.ac.manchester.cs.diff.output.xml.XMLConceptDiffReport; 8 | import uk.ac.manchester.cs.diff.output.xml.XMLDiffReport; 9 | import uk.ac.manchester.cs.diff.output.xml.XMLUnifiedDiffReport; 10 | import uk.ac.manchester.cs.diff.unity.changeset.ChangeSet; 11 | 12 | /** 13 | * @author Rafael S. Goncalves
14 | * Stanford Center for Biomedical Informatics Research (BMIR)
15 | * School of Medicine, Stanford University
16 | */ 17 | public class CSVDiffReport { 18 | private XMLDiffReport report; 19 | 20 | 21 | public CSVDiffReport(XMLDiffReport report) { 22 | this.report = report; 23 | } 24 | 25 | 26 | public String getCSV() { 27 | ChangeSet changeSet = report.getChangeSet(); 28 | if(report instanceof XMLAxiomDiffReport) 29 | return new CSVAxiomDiffReport().getReport((AxiomChangeSet)changeSet); 30 | else if(report instanceof XMLConceptDiffReport) 31 | return new CSVConceptDiffReport().getReport((ConceptChangeSet)changeSet); 32 | else if(report instanceof XMLUnifiedDiffReport) 33 | // TODO: not implemented 34 | throw new NotImplementedException("not implemented".toUpperCase()); 35 | else 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/output/xml/XMLDiffReport.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.output.xml; 20 | 21 | import org.w3c.dom.Document; 22 | 23 | import uk.ac.manchester.cs.diff.unity.changeset.ChangeSet; 24 | 25 | /** 26 | * @author Rafael S. Goncalves
27 | * Information Management Group (IMG)
28 | * School of Computer Science
29 | * University of Manchester
30 | */ 31 | public interface XMLDiffReport { 32 | 33 | /** 34 | * Get XML document using term names 35 | * @return Term name based XML document 36 | */ 37 | public Document getXMLDocumentUsingTermNames(); 38 | 39 | 40 | /** 41 | * Get XML document using term labels 42 | * @return Label based XML document 43 | */ 44 | public Document getXMLDocumentUsingLabels(); 45 | 46 | 47 | /** 48 | * Get XML document using automatically generated symbols 49 | * @return Gensym based XML document 50 | */ 51 | public Document getXMLDocumentUsingGenSyms(); 52 | 53 | 54 | /** 55 | * Get a specified XML document as a string 56 | * @param doc XML document 57 | * @return String containing the given XML document 58 | */ 59 | public String getReportAsString(Document doc); 60 | 61 | 62 | /** 63 | * Get a transformation of the given document, according to the specified XSLT file, into HTML 64 | * @param doc XML document 65 | * @param xsltPath File path to XSLT file 66 | * @return String containing the HTML code resulting from the transformation 67 | */ 68 | public String getReportAsHTML(Document doc, String xsltPath); 69 | 70 | 71 | /** 72 | * Get the change set associated with this report 73 | * @return Change set 74 | */ 75 | public ChangeSet getChangeSet(); 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/test/DiffResult.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.test; 2 | 3 | import uk.ac.manchester.cs.diff.concept.witnesses.WitnessGroup; 4 | 5 | public class DiffResult { 6 | private WitnessGroup lhs, rhs; 7 | 8 | /** 9 | * Constructor 10 | * @param lhs Ontology 1 witness pack 11 | * @param rhs Ontology 2 witness pack 12 | */ 13 | public DiffResult(WitnessGroup lhs, WitnessGroup rhs) { 14 | this.lhs = lhs; 15 | this.rhs = rhs; 16 | } 17 | 18 | 19 | /** 20 | * Get the witness pack for ontology 1 21 | * @return Witness pack for ontology 1 22 | */ 23 | public WitnessGroup getLHSWitnessPack() { 24 | return lhs; 25 | } 26 | 27 | 28 | /** 29 | * Get the witness pack for ontology 2 30 | * @return Witness pack for ontology 2 31 | */ 32 | public WitnessGroup getRHSWitnessPack() { 33 | return rhs; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/unity/ChangeAligner.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.unity; 20 | 21 | import java.util.HashMap; 22 | import java.util.HashSet; 23 | import java.util.Map; 24 | import java.util.Set; 25 | 26 | import org.semanticweb.owl.explanation.api.Explanation; 27 | import org.semanticweb.owlapi.model.OWLAxiom; 28 | 29 | import uk.ac.manchester.cs.diff.concept.change.ConceptChange; 30 | 31 | /** 32 | * @author Rafael S. Goncalves
33 | * Information Management Group (IMG)
34 | * School of Computer Science
35 | * University of Manchester
36 | */ 37 | public class ChangeAligner { 38 | private Map>> justsMap; 39 | private Set changes; 40 | private Set effChanges; 41 | private boolean spec, direct; 42 | 43 | /** 44 | * Constructor 45 | * @param changes Set of concept changes 46 | * @param effChanges Effectual changes 47 | * @param justsMap Map of justifications to entailments 48 | * @param spec true if checking specialisations, false if generalisations 49 | * @param direct true if checking direct changes, false if indirect 50 | */ 51 | public ChangeAligner(Set changes, Set effChanges, Map>> justsMap, 52 | boolean spec, boolean direct) { 53 | this.changes = changes; 54 | this.effChanges = effChanges; 55 | this.spec = spec; 56 | this.direct = direct; 57 | this.justsMap = justsMap; 58 | } 59 | 60 | 61 | /** 62 | * Align each concept change with the asserted axiom that gives rise to that, by 63 | * analysing justifications for witness axioms of each concept change 64 | * @return Map of asserted axioms to the concepts they affect 65 | */ 66 | public Map> alignChangeWitnesses() { 67 | Map> map = new HashMap>(); 68 | for(ConceptChange c : changes) { 69 | Set wits = null; 70 | if(spec) { 71 | if(direct) wits = c.getDirectSpecialisationWitnesses(); 72 | else wits = c.getIndirectSpecialisationWitnesses(); 73 | } 74 | else { 75 | if(direct) wits = c.getDirectGeneralisationWitnesses(); 76 | else wits = c.getIndirectGeneralisationWitnesses(); 77 | } 78 | 79 | for(OWLAxiom ax : wits) { 80 | Set> exps = justsMap.get(ax); 81 | for(Explanation e : exps) { 82 | for(OWLAxiom just_ax : e.getAxioms()) { 83 | if(effChanges.contains(just_ax)) { 84 | if(map.containsKey(just_ax)) { 85 | @SuppressWarnings("unchecked") 86 | Set mappings = (Set) map.get(just_ax); 87 | mappings.add(c); 88 | map.put(just_ax, mappings); 89 | } 90 | else { 91 | Set mappings = new HashSet(); 92 | mappings.add(c); 93 | map.put(just_ax, mappings); 94 | } 95 | if(spec && direct) c.addDirectSpecialisationWitnessForAxiom(just_ax, ax); 96 | if(!spec && direct) c.addDirectGeneralisationWitnessForAxiom(just_ax, ax); 97 | if(spec && !direct) c.addIndirectSpecialisationWitnessForAxiom(just_ax, ax); 98 | if(!spec && !direct) c.addIndirectGeneralisationWitnessForAxiom(just_ax, ax); 99 | } 100 | } 101 | } 102 | } 103 | } 104 | return map; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/unity/ChangeAlignerExperimental.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.unity; 20 | 21 | import java.util.HashMap; 22 | import java.util.HashSet; 23 | import java.util.Map; 24 | import java.util.Set; 25 | import java.util.concurrent.RecursiveTask; 26 | 27 | import org.semanticweb.owl.explanation.api.Explanation; 28 | import org.semanticweb.owlapi.model.OWLAxiom; 29 | import org.semanticweb.owlapi.model.OWLOntology; 30 | 31 | import uk.ac.manchester.cs.diff.concept.change.ConceptChange; 32 | import uk.ac.manchester.cs.diff.justifications.JustificationFinder; 33 | 34 | /** 35 | * @author Rafael S. Goncalves
36 | * Information Management Group (IMG)
37 | * School of Computer Science
38 | * University of Manchester
39 | */ 40 | public class ChangeAlignerExperimental extends RecursiveTask>> { 41 | private static final long serialVersionUID = 6310419390814641451L; 42 | private Set changes; 43 | private Set effChanges; 44 | private OWLOntology ont; 45 | private boolean spec, direct; 46 | private int justLimit; 47 | private int MAX_SEQ = 5; 48 | 49 | /** 50 | * Constructor 51 | * @param ont Ontology to extract justification from 52 | * @param changes Set of concept changes 53 | * @param effChanges Effectual changes 54 | * @param justLimit Number of desired justifications per axiom 55 | * @param spec true if checking specialisations, false if generalisations 56 | * @param direct true if checking direct changes, false if indirect 57 | */ 58 | public ChangeAlignerExperimental(OWLOntology ont, Set changes, Set effChanges, int justLimit, 59 | boolean spec, boolean direct) { 60 | this.ont = ont; 61 | this.changes = changes; 62 | this.effChanges = effChanges; 63 | this.justLimit = justLimit; 64 | this.spec = spec; 65 | this.direct = direct; 66 | } 67 | 68 | 69 | @SuppressWarnings("unchecked") 70 | public Map> computeDirectly() { 71 | Map> map = new HashMap>(); 72 | for(ConceptChange c : changes) { 73 | Set wits = null; 74 | if(spec) { 75 | if(direct) wits = c.getDirectSpecialisationWitnesses(); 76 | else wits = c.getIndirectSpecialisationWitnesses(); 77 | } 78 | else { 79 | if(direct) wits = c.getDirectGeneralisationWitnesses(); 80 | else wits = c.getIndirectGeneralisationWitnesses(); 81 | } 82 | 83 | for(OWLAxiom ax : wits) { 84 | Set> exps = new JustificationFinder(ont, justLimit).getJustifications(ax); 85 | for(Explanation e : exps) { 86 | for(OWLAxiom just_ax : e.getAxioms()) { 87 | if(effChanges.contains(just_ax)) { 88 | if(map.containsKey(just_ax)) { 89 | Set mappings = (Set) map.get(just_ax); 90 | mappings.add(c); 91 | map.put(just_ax, mappings); 92 | } 93 | else { 94 | Set mappings = new HashSet(); 95 | mappings.add(c); 96 | map.put(just_ax, mappings); 97 | } 98 | if(spec && direct) c.addDirectSpecialisationWitnessForAxiom(just_ax, ax); 99 | if(!spec && direct) c.addDirectGeneralisationWitnessForAxiom(just_ax, ax); 100 | if(spec && !direct) c.addIndirectSpecialisationWitnessForAxiom(just_ax, ax); 101 | if(!spec && !direct) c.addIndirectGeneralisationWitnessForAxiom(just_ax, ax); 102 | } 103 | } 104 | } 105 | } 106 | } 107 | return map; 108 | } 109 | 110 | @Override 111 | protected Map> compute() { 112 | Map> result = new HashMap>(); 113 | if(changes.size() > MAX_SEQ) { 114 | int mid = changes.size()/2; 115 | ConceptChange[] changeArr = changes.toArray(new ConceptChange[changes.size()]); 116 | 117 | Set firstHalf = new HashSet(); 118 | Set secondHalf = new HashSet(); 119 | for(int i = 0; i < mid; i++) 120 | firstHalf.add(changeArr[i]); 121 | for(int i = mid; i < changeArr.length; i++) 122 | secondHalf.add(changeArr[i]); 123 | 124 | ChangeAlignerExperimental cat1 = new ChangeAlignerExperimental(ont, firstHalf, effChanges, justLimit, spec, direct); 125 | cat1.fork(); 126 | ChangeAlignerExperimental cat2 = new ChangeAlignerExperimental(ont, secondHalf, effChanges, justLimit, spec, direct); 127 | result.putAll(cat2.invoke()); 128 | result.putAll(cat1.join()); 129 | } 130 | else result.putAll(computeDirectly()); 131 | return result; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/unity/WitnessJustifier.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.unity; 20 | 21 | import java.util.HashSet; 22 | import java.util.Map; 23 | import java.util.Set; 24 | 25 | import org.semanticweb.owl.explanation.api.Explanation; 26 | import org.semanticweb.owlapi.model.OWLAxiom; 27 | import org.semanticweb.owlapi.model.OWLOntology; 28 | 29 | import uk.ac.manchester.cs.diff.concept.change.ConceptChange; 30 | import uk.ac.manchester.cs.diff.concept.changeset.ConceptChangeSet; 31 | import uk.ac.manchester.cs.diff.justifications.JustificationFinder; 32 | 33 | /** 34 | * @author Rafael S. Goncalves
35 | * Information Management Group (IMG)
36 | * School of Computer Science
37 | * University of Manchester
38 | */ 39 | public class WitnessJustifier { 40 | private OWLOntology ont; 41 | private ConceptChangeSet conceptChangeSet; 42 | private String side; 43 | private int nrJusts; 44 | 45 | /** 46 | * Constructor 47 | * @param ont Ontology 48 | * @param conceptChangeSet Concept changes 49 | * @param nrJusts Number of justifications to extract per witness axiom 50 | * @param side Extract justifications for witness axioms to changes in ontology 1 (lhs) or ontology 2 (rhs) 51 | */ 52 | public WitnessJustifier(OWLOntology ont, ConceptChangeSet conceptChangeSet, int nrJusts, String side) { 53 | this.ont = ont; 54 | this.conceptChangeSet = conceptChangeSet; 55 | this.nrJusts = nrJusts; 56 | this.side = side; 57 | } 58 | 59 | 60 | /** 61 | * Get justifications for each witness axiom 62 | * @return Map of witness axioms to their corresponding justifications in the given ontology 63 | */ 64 | public Map>> getJustifications() { 65 | Set axioms = new HashSet(); 66 | Set changes = null; 67 | if(side.equals("lhs")) 68 | changes = conceptChangeSet.getLHSConceptChanges(); 69 | else if(side.equals("rhs")) 70 | changes = conceptChangeSet.getRHSConceptChanges(); 71 | 72 | for(ConceptChange c : changes) 73 | axioms.addAll(c.getAllWitnesses()); 74 | 75 | JustificationFinder justFinder = new JustificationFinder(ont, nrJusts); 76 | return justFinder.getJustifications(axioms); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/unity/changeset/AlignedChangeSet.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.unity.changeset; 2 | 3 | import uk.ac.manchester.cs.diff.exception.NotImplementedException; 4 | 5 | /** 6 | * @author Rafael S. Goncalves
7 | * Stanford Center for Biomedical Informatics Research (BMIR)
8 | * School of Medicine, Stanford University
9 | */ 10 | public class AlignedChangeSet implements AlignedChangeSetInt { 11 | private AlignedDirectChangeSet directChangeSet; 12 | private AlignedIndirectChangeSet indirectChangeSet; 13 | 14 | 15 | /** 16 | * Constructor 17 | * @param directChangeSet Direct change set 18 | * @param indirectChangeSet Indirect change set 19 | */ 20 | public AlignedChangeSet(AlignedDirectChangeSet directChangeSet, AlignedIndirectChangeSet indirectChangeSet) { 21 | this.directChangeSet = directChangeSet; 22 | this.indirectChangeSet = indirectChangeSet; 23 | } 24 | 25 | 26 | @Override 27 | public AlignedDirectChangeSet getDirectChangeSet() { 28 | return directChangeSet; 29 | } 30 | 31 | 32 | @Override 33 | public AlignedIndirectChangeSet getIndirectChangeSet() { 34 | return indirectChangeSet; 35 | } 36 | 37 | 38 | @Override 39 | public boolean isEmpty() { 40 | if(directChangeSet.isEmpty() && indirectChangeSet.isEmpty()) 41 | return true; 42 | else 43 | return false; 44 | } 45 | 46 | 47 | @Override 48 | public double getOperationTime() { 49 | // TODO: not implemented 50 | throw new NotImplementedException("not implemented".toUpperCase()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/unity/changeset/AlignedChangeSetInt.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.unity.changeset; 2 | 3 | /** 4 | * @author Rafael S. Goncalves
5 | * Stanford Center for Biomedical Informatics Research (BMIR)
6 | * School of Medicine, Stanford University
7 | */ 8 | public interface AlignedChangeSetInt extends ChangeSet { 9 | 10 | /** 11 | * Get direct change set 12 | * @return Direct change set 13 | */ 14 | public AlignedDirectChangeSet getDirectChangeSet(); 15 | 16 | 17 | /** 18 | * Get indirect change set 19 | * @return Indirect change set 20 | */ 21 | public AlignedIndirectChangeSet getIndirectChangeSet(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/unity/changeset/AlignedDirectChangeSet.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.unity.changeset; 20 | 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | import java.util.Set; 24 | 25 | import org.semanticweb.owl.explanation.api.Explanation; 26 | import org.semanticweb.owlapi.model.OWLAxiom; 27 | 28 | import uk.ac.manchester.cs.diff.axiom.changeset.CategorisedChangeSet; 29 | import uk.ac.manchester.cs.diff.concept.change.ConceptChange; 30 | import uk.ac.manchester.cs.diff.concept.changeset.ConceptChangeSet; 31 | import uk.ac.manchester.cs.diff.exception.NotImplementedException; 32 | import uk.ac.manchester.cs.diff.unity.ChangeAligner; 33 | 34 | /** 35 | * @author Rafael S. Goncalves
36 | * Information Management Group (IMG)
37 | * School of Computer Science
38 | * University of Manchester
39 | */ 40 | public class AlignedDirectChangeSet { 41 | private ConceptChangeSet conceptChangeSet; 42 | private Set eff_adds, eff_rems; 43 | private Map> ont1map_spec, ont1map_gen, ont2map_spec, ont2map_gen; 44 | Map>> justsMap1, justsMap2; 45 | 46 | /** 47 | * Constructor 48 | * @param axiomChangeSet Axiom change set 49 | * @param conceptChangeSet Concept change set 50 | * @param justsMap1 Map of ontology1 witness axioms to their justifications in ontology 1 51 | * @param justsMap2 Map of ontology2 witness axioms to their justifications in ontology 2 52 | */ 53 | public AlignedDirectChangeSet(CategorisedChangeSet axiomChangeSet, ConceptChangeSet conceptChangeSet, 54 | Map>> justsMap1, Map>> justsMap2) { 55 | this.conceptChangeSet = conceptChangeSet; 56 | this.justsMap1 = justsMap1; 57 | this.justsMap2 = justsMap2; 58 | eff_adds = axiomChangeSet.getEffectualAdditionAxioms(); 59 | eff_rems = axiomChangeSet.getEffectualRemovalAxioms(); 60 | init(); 61 | } 62 | 63 | 64 | /** 65 | * Initialise data structures and execute change alignment 66 | */ 67 | private void init() { 68 | ont1map_spec = new HashMap>(); 69 | ont1map_gen = new HashMap>(); 70 | ont2map_spec = new HashMap>(); 71 | ont2map_gen = new HashMap>(); 72 | alignChanges(); 73 | } 74 | 75 | 76 | /** 77 | * Align all concept and axiom changes 78 | */ 79 | public void alignChanges() { 80 | ont1map_spec = 81 | new ChangeAligner(conceptChangeSet.getLHSDirectlySpecialised(),eff_rems,justsMap1,true,true).alignChangeWitnesses(); 82 | ont1map_gen = 83 | new ChangeAligner(conceptChangeSet.getLHSDirectlyGeneralised(),eff_rems,justsMap1,false,true).alignChangeWitnesses(); 84 | ont2map_spec = 85 | new ChangeAligner(conceptChangeSet.getRHSDirectlySpecialised(),eff_adds,justsMap2,true,true).alignChangeWitnesses(); 86 | ont2map_gen = 87 | new ChangeAligner(conceptChangeSet.getRHSDirectlyGeneralised(),eff_adds,justsMap2,false,true).alignChangeWitnesses(); 88 | } 89 | 90 | 91 | /** 92 | * Get the map of axioms to concepts they specialise in ontology 1 93 | * @return Map of axioms to concepts they specialise in ontology 1 94 | */ 95 | public Map> getOnt1SpecialisationsMap() { 96 | return ont1map_spec; 97 | } 98 | 99 | 100 | /** 101 | * Get the map of axioms to concepts they generalise in ontology 1 102 | * @return Map of axioms to concepts they generalise in ontology 1 103 | */ 104 | public Map> getOnt1GeneralisationsMap() { 105 | return ont1map_gen; 106 | } 107 | 108 | 109 | /** 110 | * Get the map of axioms to concepts they specialise in ontology 2 111 | * @return Map of axioms to concepts they specialise in ontology 2 112 | */ 113 | public Map> getOnt2SpecialisationsMap() { 114 | return ont2map_spec; 115 | } 116 | 117 | 118 | /** 119 | * Get the map of axioms to concepts they generalise in ontology 2 120 | * @return Map of axioms to concepts they generalise in ontology 2 121 | */ 122 | public Map> getOnt2GeneralisationsMap() { 123 | return ont2map_gen; 124 | } 125 | 126 | 127 | /** 128 | * Check whether this change set is empty 129 | * @return true if change set is empty, false otherwise 130 | */ 131 | public boolean isEmpty() { 132 | // TODO: not implemented 133 | throw new NotImplementedException("not implemented".toUpperCase()); 134 | } 135 | } -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/unity/changeset/AlignedIndirectChangeSet.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.unity.changeset; 20 | 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | import java.util.Set; 24 | 25 | import org.semanticweb.owl.explanation.api.Explanation; 26 | import org.semanticweb.owlapi.model.OWLAxiom; 27 | 28 | import uk.ac.manchester.cs.diff.axiom.changeset.CategorisedChangeSet; 29 | import uk.ac.manchester.cs.diff.concept.change.ConceptChange; 30 | import uk.ac.manchester.cs.diff.concept.changeset.ConceptChangeSet; 31 | import uk.ac.manchester.cs.diff.exception.NotImplementedException; 32 | import uk.ac.manchester.cs.diff.unity.ChangeAligner; 33 | 34 | /** 35 | * @author Rafael S. Goncalves
36 | * Information Management Group (IMG)
37 | * School of Computer Science
38 | * University of Manchester
39 | */ 40 | public class AlignedIndirectChangeSet { 41 | private ConceptChangeSet conceptChangeSet; 42 | private Set eff_adds, eff_rems; 43 | private Map> ont1map_spec, ont1map_gen, ont2map_spec, ont2map_gen; 44 | private Map>> justsMap1, justsMap2; 45 | 46 | /** 47 | * Constructor 48 | * @param axiomChangeSet Axiom change set 49 | * @param conceptChangeSet Concept change set 50 | * @param justsMap1 Map of ontology1 witness axioms to their justifications in ontology 1 51 | * @param justsMap2 Map of ontology2 witness axioms to their justifications in ontology 2 52 | */ 53 | public AlignedIndirectChangeSet(CategorisedChangeSet axiomChangeSet, ConceptChangeSet conceptChangeSet, 54 | Map>> justsMap1, Map>> justsMap2) { 55 | this.conceptChangeSet = conceptChangeSet; 56 | this.justsMap1 = justsMap1; 57 | this.justsMap2 = justsMap2; 58 | eff_adds = axiomChangeSet.getEffectualAdditionAxioms(); 59 | eff_rems = axiomChangeSet.getEffectualRemovalAxioms(); 60 | init(); 61 | } 62 | 63 | 64 | /** 65 | * Initialise data structures and execute change alignment 66 | */ 67 | private void init() { 68 | ont1map_spec = new HashMap>(); 69 | ont1map_gen = new HashMap>(); 70 | ont2map_spec = new HashMap>(); 71 | ont2map_gen = new HashMap>(); 72 | alignChanges(); 73 | } 74 | 75 | 76 | /** 77 | * Align all concept and axiom changes 78 | */ 79 | public void alignChanges() { 80 | ont1map_spec = 81 | new ChangeAligner(conceptChangeSet.getLHSIndirectlySpecialised(),eff_rems,justsMap1,true,false).alignChangeWitnesses(); 82 | ont1map_gen = 83 | new ChangeAligner(conceptChangeSet.getLHSIndirectlyGeneralised(),eff_rems,justsMap1,false,false).alignChangeWitnesses(); 84 | ont2map_spec = 85 | new ChangeAligner(conceptChangeSet.getRHSIndirectlySpecialised(),eff_adds,justsMap2,true,false).alignChangeWitnesses(); 86 | ont2map_gen = 87 | new ChangeAligner(conceptChangeSet.getRHSIndirectlyGeneralised(),eff_adds,justsMap2,false,false).alignChangeWitnesses(); 88 | } 89 | 90 | 91 | /** 92 | * Get the map of axioms to concepts they specialise in ontology 1 93 | * @return Map of axioms to concepts they specialise in ontology 1 94 | */ 95 | public Map> getOnt1SpecialisationsMap() { 96 | return ont1map_spec; 97 | } 98 | 99 | 100 | /** 101 | * Get the map of axioms to concepts they generalise in ontology 1 102 | * @return Map of axioms to concepts they generalise in ontology 1 103 | */ 104 | public Map> getOnt1GeneralisationsMap() { 105 | return ont1map_gen; 106 | } 107 | 108 | 109 | /** 110 | * Get the map of axioms to concepts they specialise in ontology 2 111 | * @return Map of axioms to concepts they specialise in ontology 2 112 | */ 113 | public Map> getOnt2SpecialisationsMap() { 114 | return ont2map_spec; 115 | } 116 | 117 | 118 | /** 119 | * Get the map of axioms to concepts they generalise in ontology 2 120 | * @return Map of axioms to concepts they generalise in ontology 2 121 | */ 122 | public Map> getOnt2GeneralisationsMap() { 123 | return ont2map_gen; 124 | } 125 | 126 | 127 | /** 128 | * Check whether this change set is empty 129 | * @return true if change set is empty, false otherwise 130 | */ 131 | public boolean isEmpty() { 132 | // TODO: not implemented 133 | throw new NotImplementedException("NOT IMPLEMENTED"); 134 | } 135 | } -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/unity/changeset/ChangeSet.java: -------------------------------------------------------------------------------- 1 | package uk.ac.manchester.cs.diff.unity.changeset; 2 | 3 | /** 4 | * @author Rafael S. Goncalves
5 | * Stanford Center for Biomedical Informatics Research (BMIR)
6 | * School of Medicine, Stanford University
7 | */ 8 | public interface ChangeSet { 9 | 10 | /** 11 | * Check if change set is empty 12 | * @return true if change set is empty, false otherwise 13 | */ 14 | public boolean isEmpty(); 15 | 16 | 17 | /** 18 | * Get the operation time 19 | * @return Operation time 20 | */ 21 | public double getOperationTime(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/utils/ConceptDiffRunner.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.utils; 20 | 21 | import java.io.BufferedWriter; 22 | import java.io.File; 23 | import java.io.FileWriter; 24 | import java.io.IOException; 25 | import java.io.Writer; 26 | import java.text.SimpleDateFormat; 27 | import java.util.Calendar; 28 | import java.util.Set; 29 | 30 | import javax.xml.transform.TransformerException; 31 | 32 | import org.semanticweb.owlapi.apibinding.OWLManager; 33 | import org.semanticweb.owlapi.model.OWLEntity; 34 | import org.semanticweb.owlapi.model.OWLOntology; 35 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; 36 | import org.semanticweb.owlapi.model.OWLOntologyManager; 37 | 38 | import uk.ac.manchester.cs.diff.concept.ConceptDiff; 39 | import uk.ac.manchester.cs.diff.concept.ContentCVSDiff; 40 | import uk.ac.manchester.cs.diff.concept.GrammarDiff; 41 | import uk.ac.manchester.cs.diff.concept.SubconceptDiff; 42 | import uk.ac.manchester.cs.diff.concept.changeset.ConceptChangeSet; 43 | import uk.ac.manchester.cs.diff.output.xml.XMLConceptDiffReport; 44 | 45 | /** 46 | * @author Rafael S. Goncalves
47 | * Information Management Group (IMG)
48 | * School of Computer Science
49 | * University of Manchester
50 | */ 51 | public class ConceptDiffRunner { 52 | 53 | /** 54 | * Serialize signature sample as a text file 55 | * @param sampleSet Set of entities in the sample 56 | * @param outputDir Output directory 57 | */ 58 | public static void serializeSample(Set sampleSet, String outputDir) { 59 | String sigList = ""; 60 | for(OWLEntity c : sampleSet) sigList += c.getIRI() + "\n"; 61 | try { 62 | new File(outputDir).mkdirs(); 63 | File file = new File(outputDir + "randomSample.txt"); 64 | Writer output = new BufferedWriter(new FileWriter(file, false)); 65 | System.out.println("Saved random sample at: " + file.getAbsolutePath()); 66 | output.write(sigList); 67 | output.close(); 68 | } catch (IOException e) { 69 | e.printStackTrace(); 70 | } 71 | } 72 | 73 | 74 | /** 75 | * Serialize string to file 76 | * @param s String to serialize 77 | * @param outputDir Output directory 78 | * @param filename File name 79 | */ 80 | public static void serializeString(String s, String outputDir, String filename) { 81 | try { 82 | new File(outputDir).mkdirs(); 83 | FileWriter fw = new FileWriter(new File(outputDir + filename), true); 84 | fw.append(s); 85 | fw.close(); 86 | } catch (IOException e) { 87 | e.printStackTrace(); 88 | } 89 | } 90 | 91 | 92 | /** 93 | * Tester class 94 | * @param args Arguments, as below: 95 | * param 0: ontology1 96 | * param 1: ontology2 97 | * param 2: output directory 98 | * param 3: diff type 99 | * param 4: signature file 100 | * @throws OWLOntologyCreationException Ontology creation exception 101 | * @throws InterruptedException Interruption exception 102 | * @throws TransformerException Transformer exception 103 | */ 104 | public static void main(String[] args) throws OWLOntologyCreationException, InterruptedException, TransformerException { 105 | boolean verbose = true; 106 | File f1 = new File(args[0]), f2 = new File(args[1]); 107 | OWLOntologyManager man1 = OWLManager.createOWLOntologyManager(), man2 = OWLManager.createOWLOntologyManager(); 108 | 109 | OWLOntology ont1 = man1.loadOntologyFromOntologyDocument(f1); 110 | System.out.println("Loaded ontology 1: " + f1.getAbsolutePath()); 111 | 112 | OWLOntology ont2 = man2.loadOntologyFromOntologyDocument(f2); 113 | System.out.println("Loaded ontology 2: " + f2.getAbsolutePath()); 114 | 115 | String outputDir = args[2]; 116 | if(!outputDir.endsWith(File.separator)) outputDir += File.separator; 117 | 118 | // Remove abox for NCIt 119 | man1.removeAxioms(ont1, ont1.getABoxAxioms(true)); 120 | man2.removeAxioms(ont2, ont2.getABoxAxioms(true)); 121 | 122 | String cdiff = args[3]; 123 | 124 | // get diff 125 | ConceptDiff diff = null; 126 | if(cdiff.equals("at")) { 127 | diff = new SubconceptDiff(ont1, ont2, verbose); 128 | ((SubconceptDiff)diff).setAtomicConceptDiff(true); 129 | } 130 | else if(cdiff.equals("sub")) 131 | diff = new SubconceptDiff(ont1, ont2, verbose); 132 | else if(cdiff.equals("gr")) 133 | diff = new GrammarDiff(ont1, ont2, verbose); 134 | else if(cdiff.equals("cvs")) 135 | diff = new ContentCVSDiff(ont1, ont2, verbose); 136 | 137 | ConceptChangeSet cs = diff.getDiff(); 138 | XMLConceptDiffReport rep = diff.getXMLReport(); 139 | 140 | String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmmss").format(Calendar.getInstance().getTime()); 141 | if(cs != null) { 142 | String report = diff.getCSVChangeReport(); 143 | serializeString(report, outputDir, "diffLog.csv"); 144 | serializeString(rep.getReportAsString(rep.getReport()), outputDir, "diffChangeSet_" + timeStamp + ".xml"); 145 | } 146 | } 147 | } -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/utils/OntologyLoader.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.utils; 20 | 21 | import java.io.File; 22 | import java.util.HashSet; 23 | import java.util.Set; 24 | import java.util.concurrent.RecursiveTask; 25 | 26 | import org.semanticweb.owlapi.io.IRIDocumentSource; 27 | import org.semanticweb.owlapi.model.AxiomType; 28 | import org.semanticweb.owlapi.model.IRI; 29 | import org.semanticweb.owlapi.model.OWLAxiom; 30 | import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; 31 | import org.semanticweb.owlapi.model.OWLImportsDeclaration; 32 | import org.semanticweb.owlapi.model.OWLOntology; 33 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; 34 | import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration; 35 | import org.semanticweb.owlapi.model.OWLOntologyManager; 36 | 37 | /** 38 | * @author Rafael S. Goncalves
39 | * Information Management Group (IMG)
40 | * School of Computer Science
41 | * University of Manchester
42 | */ 43 | public class OntologyLoader extends RecursiveTask { 44 | private static final long serialVersionUID = -5909585243181647744L; 45 | private OWLOntologyManager man; 46 | private OWLOntologyLoaderConfiguration config; 47 | private boolean processImports, ignoreAbox, localFile; 48 | private int ontNr; 49 | private String filepath; 50 | 51 | 52 | public OntologyLoader(OWLOntologyManager man, OWLOntologyLoaderConfiguration config, 53 | int ontNr, String filepath, boolean processImports, boolean ignoreAbox, boolean localFile) { 54 | this.man = man; 55 | this.config = config; 56 | this.ontNr = ontNr; 57 | this.filepath = filepath; 58 | this.processImports = processImports; 59 | this.ignoreAbox = ignoreAbox; 60 | this.localFile = localFile; 61 | } 62 | 63 | @Override 64 | protected OWLOntology compute() { 65 | String sep = null; 66 | if(localFile) sep = System.getProperty("file.separator"); 67 | else sep = "/"; 68 | 69 | String filename = filepath.substring(filepath.lastIndexOf(sep)+1, filepath.length()); 70 | System.out.println("Input " + ontNr + ": " + filename + " (" + filepath + ")"); 71 | 72 | // Load ontology 73 | OWLOntology ont = null; 74 | try { 75 | if(localFile) ont = man.loadOntologyFromOntologyDocument(new IRIDocumentSource(IRI.create("file:" + new File(filepath))), config); 76 | else ont = man.loadOntologyFromOntologyDocument(new IRIDocumentSource(IRI.create(filepath))); 77 | } catch (OWLOntologyCreationException e) { 78 | System.out.println("[Invalid IRI]\tUnable to load ontology " + ontNr + ".\n\tInput: " + filepath); 79 | } 80 | 81 | Set result = null; 82 | if(ont != null) { 83 | if(ignoreAbox) removeAbox(ont); 84 | result = ont.getAxioms(); 85 | System.out.println("\tLoaded ontology " + ontNr + " (" + ont.getLogicalAxiomCount() + " logical axioms)"); 86 | 87 | // Process imports 88 | if(processImports) { 89 | if(!ont.getImportsDeclarations().isEmpty()) { 90 | for(OWLImportsDeclaration d : ont.getImportsDeclarations()) { 91 | try { 92 | OWLOntology imported = man.loadOntology(d.getIRI()); 93 | result.addAll(imported.getLogicalAxioms()); 94 | man.removeOntology(imported); 95 | } catch (OWLOntologyCreationException e) { 96 | System.out.println("[Invalid IRI]\tUnable to load the imported ontology: " + d.getIRI()); 97 | } 98 | } 99 | } 100 | } 101 | normalize(result); 102 | man.removeOntology(ont); 103 | } 104 | OWLOntology out = null; 105 | if(result != null) { 106 | try { 107 | out = man.createOntology(result); 108 | } catch (OWLOntologyCreationException e) { 109 | e.printStackTrace(); 110 | } 111 | } 112 | return out; 113 | } 114 | 115 | 116 | /** 117 | * Given a set of axioms, remove unary disjointness axioms 118 | * @param set Set of axioms to analyse 119 | * @return Set of axioms without unary disjointness axioms 120 | */ 121 | private Set normalize(Set set) { 122 | Set toRemove = new HashSet(); 123 | for(OWLAxiom ax : set) { 124 | if(ax.isOfType(AxiomType.DISJOINT_CLASSES)) { 125 | OWLDisjointClassesAxiom dis = (OWLDisjointClassesAxiom)ax; 126 | if(dis.getClassesInSignature().size() < 2) 127 | toRemove.add(ax); 128 | } 129 | } 130 | set.removeAll(toRemove); 131 | return set; 132 | } 133 | 134 | 135 | /** 136 | * Remove Abox axioms from given ontology 137 | * @param ont Ontology to remove axioms from 138 | */ 139 | private void removeAbox(OWLOntology ont) { 140 | Set aboxAxs = ont.getABoxAxioms(true); 141 | ont.getOWLOntologyManager().removeAxioms(ont, aboxAxs); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/utils/ProgressMonitor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.utils; 20 | 21 | import java.util.Set; 22 | 23 | /** 24 | * @author Rafael S. Goncalves
25 | * Information Management Group (IMG)
26 | * School of Computer Science
27 | * University of Manchester
28 | */ 29 | public class ProgressMonitor { 30 | private Integer total; 31 | private Double done; 32 | 33 | /** 34 | * Constructor 35 | * @param set Set of objects 36 | */ 37 | public ProgressMonitor(Set set) { 38 | total = set.size(); 39 | } 40 | 41 | 42 | /** 43 | * Increment the number of processed objects by 1 44 | * @return Percentage of objects processed 45 | */ 46 | public Integer incrementProgress() { 47 | if(done == null) 48 | done = 1.0; 49 | else 50 | done++; 51 | return getPercentDone(); 52 | } 53 | 54 | 55 | /** 56 | * Increment the number of processed objects by the specified amount 57 | * @param increment Amount to increment 58 | * @return Percentage of objects processed 59 | */ 60 | public Integer incrementProgress(int increment) { 61 | if(done == null) 62 | done = increment + 0.0; 63 | else 64 | done += increment; 65 | return getPercentDone(); 66 | } 67 | 68 | 69 | /** 70 | * Get the percentage of objects processed 71 | * @return Percentage of objects processed 72 | */ 73 | public Integer getPercentDone() { 74 | return (int) ((done/total)*100.0); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/utils/ReasonerLoader.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.utils; 20 | 21 | import org.semanticweb.HermiT.Configuration; 22 | import org.semanticweb.HermiT.Reasoner; 23 | import org.semanticweb.owlapi.model.OWLOntology; 24 | import org.semanticweb.owlapi.reasoner.BufferingMode; 25 | import org.semanticweb.owlapi.reasoner.ConsoleProgressMonitor; 26 | import org.semanticweb.owlapi.reasoner.FreshEntityPolicy; 27 | import org.semanticweb.owlapi.reasoner.IndividualNodeSetPolicy; 28 | import org.semanticweb.owlapi.reasoner.OWLReasoner; 29 | import org.semanticweb.owlapi.reasoner.SimpleConfiguration; 30 | 31 | import uk.ac.manchester.cs.jfact.JFactReasoner; 32 | 33 | /** 34 | * @author Rafael S. Goncalves
35 | * Information Management Group (IMG)
36 | * School of Computer Science
37 | * University of Manchester
38 | */ 39 | public class ReasonerLoader { 40 | private OWLOntology ont; 41 | private boolean verbose = false; 42 | 43 | /** 44 | * Constructor 45 | * @param ont OWL Ontology 46 | */ 47 | public ReasonerLoader(OWLOntology ont) { 48 | this.ont = ont; 49 | } 50 | 51 | 52 | /** 53 | * Constructor 54 | * @param ont OWL Ontology 55 | * @param verbose Verbose mode 56 | */ 57 | public ReasonerLoader(OWLOntology ont, boolean verbose) { 58 | this.ont = ont; 59 | this.verbose = verbose; 60 | } 61 | 62 | 63 | /** 64 | * Create a HermiT reasoner instance 65 | * @param useProgressMonitor true if a progress monitor should be used, false otherwise 66 | * @return Reasoner instance 67 | */ 68 | public OWLReasoner createReasoner(boolean useProgressMonitor) { 69 | Configuration config = new Configuration(); 70 | config.freshEntityPolicy = FreshEntityPolicy.ALLOW; 71 | 72 | if(verbose) System.out.print(" Creating reasoner... "); 73 | long start = System.currentTimeMillis(); 74 | 75 | OWLReasoner reasoner = new Reasoner(config, ont); 76 | 77 | long end = System.currentTimeMillis(); 78 | if(verbose) System.out.println("done (" + (end-start)/1000.0 + " secs)"); 79 | return reasoner; 80 | } 81 | 82 | 83 | /** 84 | * Create a FaCT++ reasoner instance 85 | * @return Reasoner instance 86 | */ 87 | // public OWLReasoner createFactReasoner(boolean useProgressMonitor) { 88 | // SimpleConfiguration config; 89 | // if(useProgressMonitor) 90 | // config = new SimpleConfiguration( 91 | // new ConsoleProgressMonitor(), FreshEntityPolicy.ALLOW, Long.MAX_VALUE, IndividualNodeSetPolicy.BY_NAME); 92 | // else 93 | // config = new SimpleConfiguration(FreshEntityPolicy.ALLOW, Long.MAX_VALUE); 94 | // 95 | // OWLReasonerFactory fac = new FaCTPlusPlusReasonerFactory(); 96 | // 97 | // if(verbose) System.out.print(" Creating reasoner... "); 98 | // long start = System.currentTimeMillis(); 99 | // 100 | // OWLReasoner reasoner = fac.createReasoner(ont, config); 101 | // 102 | // long end = System.currentTimeMillis(); 103 | // if(verbose) System.out.println("done (" + (end-start)/1000.0 + " secs)"); 104 | // return reasoner; 105 | // } 106 | 107 | 108 | /** 109 | * Create a JFact reasoner instance 110 | * @param useProgressMonitor true if a progress monitor should be used, false otherwise 111 | * @return Reasoner instance 112 | */ 113 | public OWLReasoner createHermitReasoner(boolean useProgressMonitor) { 114 | SimpleConfiguration config; 115 | if(useProgressMonitor) 116 | config = new SimpleConfiguration(new ConsoleProgressMonitor(), FreshEntityPolicy.ALLOW, Long.MAX_VALUE, IndividualNodeSetPolicy.BY_NAME); 117 | else 118 | config = new SimpleConfiguration(FreshEntityPolicy.ALLOW, Long.MAX_VALUE); 119 | 120 | if(verbose) System.out.print(" Creating reasoner... "); 121 | long start = System.currentTimeMillis(); 122 | 123 | OWLReasoner reasoner = new JFactReasoner(ont, config, BufferingMode.NON_BUFFERING); 124 | 125 | long end = System.currentTimeMillis(); 126 | if(verbose) System.out.println("done (" + (end-start)/1000.0 + " secs)"); 127 | return reasoner; 128 | } 129 | 130 | 131 | /** 132 | * Get ontology used to instatiate the reasoner 133 | * @return OWL ontology 134 | */ 135 | public OWLOntology getOntology() { 136 | return ont; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/utils/SignatureSampler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.utils; 20 | 21 | import java.io.BufferedWriter; 22 | import java.io.File; 23 | import java.io.FileWriter; 24 | import java.io.IOException; 25 | import java.io.Writer; 26 | import java.util.HashSet; 27 | import java.util.Random; 28 | import java.util.Set; 29 | 30 | import org.semanticweb.owlapi.apibinding.OWLManager; 31 | import org.semanticweb.owlapi.model.OWLClass; 32 | import org.semanticweb.owlapi.model.OWLOntology; 33 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; 34 | import org.semanticweb.owlapi.model.OWLOntologyManager; 35 | 36 | import uk.ac.manchester.cs.diff.concept.sigma.Signature; 37 | 38 | /** 39 | * @author Rafael S. Goncalves
40 | * Information Management Group (IMG)
41 | * School of Computer Science
42 | * University of Manchester
43 | */ 44 | public class SignatureSampler { 45 | private OWLOntology ont1, ont2; 46 | 47 | /** 48 | * Single ontology constructor 49 | * @param ont1 Ontology 1 50 | */ 51 | public SignatureSampler(OWLOntology ont1) { 52 | this.ont1 = ont1; 53 | } 54 | 55 | 56 | /** 57 | * Constructor for two ontologies 58 | * @param ont1 Ontology 1 59 | * @param ont2 Ontology 2 60 | */ 61 | public SignatureSampler(OWLOntology ont1, OWLOntology ont2) { 62 | this.ont1 = ont1; 63 | this.ont2 = ont2; 64 | } 65 | 66 | 67 | /** 68 | * Get concept sample of the specified size 69 | * @param sampleSize Sample size 70 | * @return Set of concept names in the sample 71 | */ 72 | public Set getSample(int sampleSize) { 73 | System.out.print("Fetching signature sample... "); 74 | Set sample = new HashSet(); 75 | Object[] arr = null; 76 | if(ont2 != null) 77 | arr = new Signature().getSharedConceptNames(ont1, ont2).toArray(); 78 | else 79 | arr = ont1.getClassesInSignature().toArray(); 80 | 81 | if(sampleSize > arr.length) sampleSize = arr.length; 82 | 83 | Random rand = new Random(); 84 | while(sample.size() < sampleSize) { 85 | int random = rand.nextInt(arr.length); 86 | OWLClass c = (OWLClass)arr[random]; 87 | sample.add(c); 88 | } 89 | 90 | System.out.println("done (sample size: " + sample.size() + " named concepts)"); 91 | return sample; 92 | } 93 | 94 | 95 | /** 96 | * main 97 | * @param args Arguments 98 | */ 99 | public static void main(String[] args) { 100 | int sampleSize = Integer.parseInt(args[0]); 101 | for(int i = 1; i < args.length; i++) { 102 | OWLOntologyManager man = OWLManager.createOWLOntologyManager(); 103 | File f = new File(args[i]); 104 | String path = f.getParentFile().getAbsolutePath(); 105 | if(!path.endsWith(File.separator)) path += File.separator; 106 | 107 | OWLOntology ont = null; 108 | try { 109 | ont = man.loadOntologyFromOntologyDocument(f); 110 | } catch (OWLOntologyCreationException e) { 111 | e.printStackTrace(); 112 | } 113 | System.out.println("Loaded Ontology"); 114 | 115 | SignatureSampler sampler = new SignatureSampler(ont); 116 | Set sampleSet = sampler.getSample(sampleSize); 117 | 118 | String sigList = ""; 119 | for(OWLClass c : sampleSet) sigList += c.getIRI() + "\n"; 120 | 121 | try { 122 | File file = new File(path + File.separator + "randomSample.txt"); 123 | Writer output = new BufferedWriter(new FileWriter(file)); 124 | System.out.println("Saved random sample at: " + file.getAbsolutePath()); 125 | output.write(sigList); 126 | output.close(); 127 | } catch (IOException e) { 128 | e.printStackTrace(); 129 | } 130 | man.removeOntology(ont); 131 | } 132 | } 133 | } -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/utils/SilentChangeBroadcastStrategy.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.utils; 20 | 21 | import java.util.List; 22 | 23 | import org.semanticweb.owlapi.model.OWLException; 24 | import org.semanticweb.owlapi.model.OWLOntologyChange; 25 | import org.semanticweb.owlapi.model.OWLOntologyChangeBroadcastStrategy; 26 | import org.semanticweb.owlapi.model.OWLOntologyChangeListener; 27 | 28 | /** 29 | * @author Rafael S. Goncalves
30 | * Information Management Group (IMG)
31 | * School of Computer Science
32 | * University of Manchester
33 | */ 34 | public class SilentChangeBroadcastStrategy implements OWLOntologyChangeBroadcastStrategy { 35 | private static final long serialVersionUID = 8035434562859540956L; 36 | 37 | /* (non-Javadoc) 38 | * @see org.semanticweb.owlapi.model.OWLOntologyChangeBroadcastStrategy#broadcastChanges(org.semanticweb.owlapi.model.OWLOntologyChangeListener, java.util.List) 39 | */ 40 | @Override 41 | public void broadcastChanges(OWLOntologyChangeListener arg0, List arg1) throws OWLException { 42 | // shush just do nothing 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/uk/ac/manchester/cs/diff/utils/XMLTransformer.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | package uk.ac.manchester.cs.diff.utils; 20 | 21 | import java.io.File; 22 | import java.io.FileWriter; 23 | import java.io.IOException; 24 | import java.io.StringWriter; 25 | 26 | import javax.xml.parsers.DocumentBuilder; 27 | import javax.xml.parsers.DocumentBuilderFactory; 28 | import javax.xml.parsers.ParserConfigurationException; 29 | import javax.xml.transform.OutputKeys; 30 | import javax.xml.transform.Transformer; 31 | import javax.xml.transform.TransformerException; 32 | import javax.xml.transform.TransformerFactory; 33 | import javax.xml.transform.dom.DOMSource; 34 | import javax.xml.transform.stream.StreamResult; 35 | 36 | import org.w3c.dom.Document; 37 | import org.xml.sax.SAXException; 38 | 39 | /** 40 | * @author Rafael S. Goncalves
41 | * Information Management Group (IMG)
42 | * School of Computer Science
43 | * University of Manchester
44 | */ 45 | public class XMLTransformer { 46 | private String xsltPath; 47 | private DocumentBuilder builder; 48 | 49 | /** 50 | * Constructor 51 | * @param xsltPath XSLT file path 52 | * @param builder Document builder 53 | */ 54 | public XMLTransformer(String xsltPath, DocumentBuilder builder) { 55 | this.xsltPath = xsltPath; 56 | this.builder = builder; 57 | } 58 | 59 | 60 | /** 61 | * Process given XML file 62 | * @param f XML file 63 | * @param directory Directory where XML resides 64 | * @throws TransformerException Transformer exception 65 | */ 66 | public void processFile(File f, File directory) throws TransformerException { 67 | System.out.println(" Processing file: " + f.getName()); 68 | Document doc = null; 69 | try { 70 | doc = builder.parse(f); 71 | } catch(SAXException e) { 72 | e.printStackTrace(); 73 | } catch(IOException e) { 74 | e.printStackTrace(); 75 | } 76 | if(doc != null) { 77 | String name = f.getName(); 78 | String suffix = name.substring(name.lastIndexOf("_"), name.lastIndexOf(".")); 79 | String html = getReportAsHTML(doc); 80 | saveStringToFile(directory.getAbsolutePath(), "index"+suffix+".html", html); 81 | } 82 | } 83 | 84 | 85 | /** 86 | * Get XML document transformed into HTML as a string 87 | * @param doc XML document 88 | * @return String containing the HTML transformation 89 | * @throws TransformerException Transformer exception 90 | */ 91 | public String getReportAsHTML(Document doc) throws TransformerException { 92 | TransformerFactory transfac = TransformerFactory.newInstance(); 93 | Transformer trans = transfac.newTransformer(new javax.xml.transform.stream.StreamSource(xsltPath)); 94 | trans.setOutputProperty(OutputKeys.INDENT, "yes"); 95 | 96 | // Create string from XML tree 97 | StringWriter sw = new StringWriter(); 98 | StreamResult result = new StreamResult(sw); 99 | DOMSource source = new DOMSource(doc); 100 | 101 | trans.transform(source, result); 102 | return sw.toString(); 103 | } 104 | 105 | 106 | /** 107 | * Serialize a given string to the specified path 108 | * @param outputDir Output directory 109 | * @param filename File name 110 | * @param content String to output 111 | */ 112 | private void saveStringToFile(String outputDir, String filename, String content) { 113 | try { 114 | new File(outputDir).mkdirs(); 115 | FileWriter fw = new FileWriter(outputDir + File.separator + filename); 116 | fw.write(content); 117 | fw.close(); 118 | } catch (IOException e) { 119 | e.printStackTrace(); 120 | } 121 | } 122 | 123 | 124 | /** 125 | * Main 126 | * @param args Arguments 127 | * @throws ParserConfigurationException Parser configuration exception 128 | * @throws TransformerException Transformer exception 129 | */ 130 | public static void main(String[] args) throws ParserConfigurationException, TransformerException { 131 | String xsltPath = args[0]; 132 | String rootExampleFolder = args[1]; 133 | 134 | DocumentBuilderFactory fac = DocumentBuilderFactory.newInstance(); 135 | DocumentBuilder builder = fac.newDocumentBuilder(); 136 | XMLTransformer trans = new XMLTransformer(xsltPath, builder); 137 | 138 | File rootFolder = new File(rootExampleFolder); 139 | System.out.println("Checking XML files under: " + rootFolder.getName()); 140 | File[] dirs = rootFolder.listFiles(); 141 | for(File dir : dirs) { 142 | if(dir.isDirectory()) { 143 | System.out.println(" Checking directory: " + dir.getName()); 144 | for(File f : dir.listFiles()) { 145 | if(f.getName().endsWith(".xml")) 146 | trans.processFile(f, dir); 147 | } 148 | } 149 | else if(dir.getName().endsWith(".xml")) 150 | trans.processFile(dir, rootFolder); 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/main/resources/css/reveal.css: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------- 2 | Reveal Modals 3 | -------------------------------------------------- */ 4 | 5 | .reveal-modal-bg { 6 | position: fixed; 7 | height: 100%; 8 | width: 100%; 9 | background: #000; 10 | background: rgba(0,0,0,.8); 11 | z-index: 100; 12 | display: none; 13 | top: 0; 14 | left: 0; 15 | } 16 | 17 | .reveal-modal { 18 | visibility: hidden; 19 | top: 50px; 20 | left: 50%; 21 | margin-left: -300px; 22 | width: 450px; 23 | background: #eee url(../images/modal-gloss.png) no-repeat -200px -80px; 24 | position: absolute; 25 | z-index: 101; 26 | padding: 30px 40px 34px; 27 | -moz-border-radius: 5px; 28 | -webkit-border-radius: 5px; 29 | border-radius: 5px; 30 | -moz-box-shadow: 0 0 10px rgba(0,0,0,.4); 31 | -webkit-box-shadow: 0 0 10px rgba(0,0,0,.4); 32 | -box-shadow: 0 0 10px rgba(0,0,0,.4); 33 | } 34 | 35 | .reveal-modal.small { width: 200px; margin-left: -140px;} 36 | .reveal-modal.medium { width: 400px; margin-left: -240px;} 37 | .reveal-modal.large { width: 600px; margin-left: -340px;} 38 | .reveal-modal.xlarge { width: 800px; margin-left: -440px;} 39 | 40 | .reveal-modal .close-reveal-modal { 41 | font-size: 22px; 42 | line-height: .5; 43 | position: absolute; 44 | top: 8px; 45 | right: 11px; 46 | color: #aaa; 47 | /*text-shadow: 0 -1px 1px rbga(0,0,0,.6);*/ 48 | font-weight: bold; 49 | cursor: pointer; 50 | } 51 | /* 52 | 53 | NOTES 54 | 55 | Close button entity is × 56 | 57 | Example markup 58 | 59 |
60 |

Awesome. I have it.

61 |

Your couch. I it's mine.

62 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ultrices aliquet placerat. Duis pulvinar orci et nisi euismod vitae tempus lorem consectetur. Duis at magna quis turpis mattis venenatis eget id diam.

63 | × 64 |
65 | 66 | */ 67 | -------------------------------------------------------------------------------- /src/main/resources/images/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/blank.png -------------------------------------------------------------------------------- /src/main/resources/images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/favicon.png -------------------------------------------------------------------------------- /src/main/resources/images/info_bubble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/info_bubble.png -------------------------------------------------------------------------------- /src/main/resources/images/logomanchester.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/logomanchester.png -------------------------------------------------------------------------------- /src/main/resources/images/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/minus.png -------------------------------------------------------------------------------- /src/main/resources/images/modal-gloss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/modal-gloss.png -------------------------------------------------------------------------------- /src/main/resources/images/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/plus.png -------------------------------------------------------------------------------- /src/main/resources/images/tt_bottom.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/tt_bottom.gif -------------------------------------------------------------------------------- /src/main/resources/images/tt_left.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/tt_left.gif -------------------------------------------------------------------------------- /src/main/resources/images/tt_top.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/tt_top.gif -------------------------------------------------------------------------------- /src/main/resources/images/x_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rsgoncalves/ecco/3a50dba8eb6680f5d30c83f0032627465e822f97/src/main/resources/images/x_icon.gif -------------------------------------------------------------------------------- /src/main/resources/js/jquery.reveal.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery Reveal Plugin 1.0 3 | * www.ZURB.com 4 | * Copyright 2010, ZURB 5 | * Free to use under the MIT license. 6 | * http://www.opensource.org/licenses/mit-license.php 7 | */ 8 | 9 | 10 | (function($) { 11 | 12 | /*--------------------------- 13 | Defaults for Reveal 14 | ----------------------------*/ 15 | 16 | /*--------------------------- 17 | Listener for data-reveal-id attributes 18 | ----------------------------*/ 19 | 20 | $('a[data-reveal-id]').live('click', function(e) { 21 | e.preventDefault(); 22 | var modalLocation = $(this).attr('data-reveal-id'); 23 | $('#'+modalLocation).reveal($(this).data()); 24 | }); 25 | 26 | /*--------------------------- 27 | Extend and Execute 28 | ----------------------------*/ 29 | 30 | $.fn.reveal = function(options) { 31 | 32 | 33 | var defaults = { 34 | animation: 'fadeAndPop', //fade, fadeAndPop, none 35 | animationspeed: 300, //how fast animtions are 36 | closeonbackgroundclick: true, //if you click background will modal close? 37 | dismissmodalclass: 'close-reveal-modal' //the class of a button or element that will close an open modal 38 | }; 39 | 40 | //Extend dem' options 41 | var options = $.extend({}, defaults, options); 42 | 43 | return this.each(function() { 44 | 45 | /*--------------------------- 46 | Global Variables 47 | ----------------------------*/ 48 | var modal = $(this), 49 | topMeasure = parseInt(modal.css('top')), 50 | topOffset = modal.height() + topMeasure, 51 | locked = false, 52 | modalBG = $('.reveal-modal-bg'); 53 | 54 | /*--------------------------- 55 | Create Modal BG 56 | ----------------------------*/ 57 | if(modalBG.length == 0) { 58 | modalBG = $('
').insertAfter(modal); 59 | } 60 | 61 | /*--------------------------- 62 | Open & Close Animations 63 | ----------------------------*/ 64 | //Entrance Animations 65 | modal.bind('reveal:open', function () { 66 | modalBG.unbind('click.modalEvent'); 67 | $('.' + options.dismissmodalclass).unbind('click.modalEvent'); 68 | if(!locked) { 69 | lockModal(); 70 | if(options.animation == "fadeAndPop") { 71 | modal.css({'top': $(document).scrollTop()-topOffset, 'opacity' : 0, 'visibility' : 'visible'}); 72 | modalBG.fadeIn(options.animationspeed/2); 73 | modal.delay(options.animationspeed/2).animate({ 74 | "top": $(document).scrollTop()+topMeasure + 'px', 75 | "opacity" : 1 76 | }, options.animationspeed,unlockModal()); 77 | } 78 | if(options.animation == "fade") { 79 | modal.css({'opacity' : 0, 'visibility' : 'visible', 'top': $(document).scrollTop()+topMeasure}); 80 | modalBG.fadeIn(options.animationspeed/2); 81 | modal.delay(options.animationspeed/2).animate({ 82 | "opacity" : 1 83 | }, options.animationspeed,unlockModal()); 84 | } 85 | if(options.animation == "none") { 86 | modal.css({'visibility' : 'visible', 'top':$(document).scrollTop()+topMeasure}); 87 | modalBG.css({"display":"block"}); 88 | unlockModal() 89 | } 90 | } 91 | modal.unbind('reveal:open'); 92 | }); 93 | 94 | //Closing Animation 95 | modal.bind('reveal:close', function () { 96 | if(!locked) { 97 | lockModal(); 98 | if(options.animation == "fadeAndPop") { 99 | modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); 100 | modal.animate({ 101 | "top": $(document).scrollTop()-topOffset + 'px', 102 | "opacity" : 0 103 | }, options.animationspeed/2, function() { 104 | modal.css({'top':topMeasure, 'opacity' : 1, 'visibility' : 'hidden'}); 105 | unlockModal(); 106 | }); 107 | } 108 | if(options.animation == "fade") { 109 | modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); 110 | modal.animate({ 111 | "opacity" : 0 112 | }, options.animationspeed, function() { 113 | modal.css({'opacity' : 1, 'visibility' : 'hidden', 'top' : topMeasure}); 114 | unlockModal(); 115 | }); 116 | } 117 | if(options.animation == "none") { 118 | modal.css({'visibility' : 'hidden', 'top' : topMeasure}); 119 | modalBG.css({'display' : 'none'}); 120 | } 121 | } 122 | modal.unbind('reveal:close'); 123 | }); 124 | 125 | /*--------------------------- 126 | Open and add Closing Listeners 127 | ----------------------------*/ 128 | //Open Modal Immediately 129 | modal.trigger('reveal:open') 130 | 131 | //Close Modal Listeners 132 | var closeButton = $('.' + options.dismissmodalclass).bind('click.modalEvent', function () { 133 | modal.trigger('reveal:close') 134 | }); 135 | 136 | if(options.closeonbackgroundclick) { 137 | modalBG.css({"cursor":"pointer"}) 138 | modalBG.bind('click.modalEvent', function () { 139 | modal.trigger('reveal:close') 140 | }); 141 | } 142 | $('body').keyup(function(e) { 143 | if(e.which===27){ modal.trigger('reveal:close'); } // 27 is the keycode for the Escape key 144 | }); 145 | 146 | 147 | /*--------------------------- 148 | Animations Locks 149 | ----------------------------*/ 150 | function unlockModal() { 151 | locked = false; 152 | } 153 | function lockModal() { 154 | locked = true; 155 | } 156 | 157 | });//each call 158 | }//orbit plugin call 159 | })(jQuery); 160 | 161 | -------------------------------------------------------------------------------- /src/main/resources/js/jscript.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * This file is part of ecco. 3 | * 4 | * ecco is distributed under the terms of the GNU Lesser General Public License (LGPL), Version 3.0. 5 | * 6 | * Copyright 2011-2014, The University of Manchester 7 | * 8 | * ecco is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser 9 | * General Public License as published by the Free Software Foundation, either version 3 of the 10 | * License, or (at your option) any later version. 11 | * 12 | * ecco is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 13 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 | * General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License along with ecco. 17 | * If not, see http://www.gnu.org/licenses/. 18 | ******************************************************************************/ 19 | 20 | $(document).ready(function() { 21 | $('#tree1').checkboxTree({ 22 | initializeChecked: 'expanded', 23 | initializeUnchecked: 'collapsed', 24 | collapseDuration: 50, 25 | expandDuration: 100, 26 | collapseImage: 'images/minus.png', 27 | expandImage: 'images/plus.png', 28 | onCheck: { 29 | node: 'expand', 30 | ancestors: 'checkIfFull', 31 | descendants: 'check' }, 32 | onUncheck: { 33 | node: 'collapse', 34 | ancestors: 'uncheck' } 35 | }); 36 | $('#tree2').checkboxTree({ 37 | initializeChecked: 'expanded', 38 | initializeUnchecked: 'collapsed', 39 | collapseDuration: 50, 40 | expandDuration: 100, 41 | collapseImage: 'images/minus.png', 42 | expandImage: 'images/plus.png', 43 | onCheck: { 44 | node: 'expand', 45 | ancestors: 'checkIfFull', 46 | descendants: 'check' }, 47 | onUncheck: { 48 | node: 'collapse', 49 | ancestors: 'uncheck' } 50 | }); 51 | $('#tree1-expandAll').click(function(){ 52 | $('#tree1').checkboxTree('expandAll'); 53 | }); 54 | $('#tree1-collapseAll').click(function(){ 55 | $('#tree1').checkboxTree('collapseAll'); 56 | }); 57 | $('#tree2-expandAll').click(function(){ 58 | $('#tree2').checkboxTree('expandAll'); 59 | }); 60 | $('#tree2-collapseAll').click(function(){ 61 | $('#tree2').checkboxTree('collapseAll'); 62 | }); 63 | $('#genViewPerml').click(function(e) { 64 | e.preventDefault(); 65 | $('#view-plink-modal').reveal({ 66 | animation: 'none', 67 | animationspeed: 100, 68 | closeonbackgroundclick: true, 69 | dismissmodalclass: 'close-reveal-modal' 70 | }); 71 | }); 72 | }); --------------------------------------------------------------------------------