Skip to content

Commit 959bf9c

Browse files
authored
MITRE prototype added.
1 parent 5462c5d commit 959bf9c

File tree

9 files changed

+5564
-0
lines changed

9 files changed

+5564
-0
lines changed

LICENSE

Lines changed: 401 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
### Ontology-Verifier
2+
A RDF Ontology verifier and ontology trouble shooter for CASE/UCO.
3+
4+
### What it does
5+
Ontology-Verifier takes output of a tool (JSON/JSON-LD/XML/etc...)
6+
and attempts to verify it aligns with a RDF based ontology (OWL/N3/ttl).
7+
Any entry in the tool's output that is NOT in the Ontology (specified via CLI)
8+
will display an error. CLI arugments can be added to cause a debugger to start
9+
so you may explore the graph to view where things went wrong.
10+
11+
12+
### How it works
13+
Verifier.py will read in an RDF vocabulary defined via ``` -g``` (glossary) to
14+
check a custom tool's output against via ```-i```. The Python library rdflib
15+
is used to turn the RDF schema into tripples which are then broken into three lists;
16+
subject, predicate and object. Finally, each element of the tools ouput within
17+
the tool's subject and predicate are checked againast the glossary's subject
18+
and predicate to confirm the existence of these RDF elements. If an element is
19+
found or not found it is displayed to the user. BNodes are skipped as they
20+
have no appropriate label in RDF and should not be used to verify an ontology.
21+
22+
23+
#### Why not SPARQL?
24+
In order to facilitate a broad range of ontologies and custom tool outputs,
25+
SPARQL queries are not used for verification. CASE/UCO allow for robust
26+
flexibility and this tool aims to compliment this approach.
27+
28+
29+
### Installation
30+
```
31+
sudo pip install -r requirements.txt
32+
```
33+
34+
### Unit Tests
35+
The ontology verifier is heavily reliant on 3rd pary libraries, primarily RDFlib.
36+
RDFLib is under heavy development. To ensure compatability with new releases
37+
unit tests have been written to check for consistency.
38+
39+
#### Run Unit Tests
40+
```
41+
cd tests;
42+
python test_verifier.py;
43+
```
44+
45+
### Usage
46+
47+
#### CLI Usage
48+
* ``` -g ```: Define the RDF schema (aka glossary) in use for your ontology.
49+
* ``` -gf ```: Define the format the schema is in. By default verifier
50+
will try to auto-guess based on extension. However, if additional plugins are
51+
installed it is best practice to manually specify it.
52+
53+
* ``` -i ```: The external tool's output you want to verify the ontology
54+
against.
55+
56+
* ```-if```: Define RDF schema for tool data that's being injested.
57+
* ```--debug```: Break on errors that occur within ```--verify```.
58+
* ```-tg```: Print subject, predicate, object for each graph within tool schema.
59+
* ```-gg```: Print subject, predicate, object for each graph within glossary schema.
60+
61+
62+
#### CLI Example
63+
64+
65+
* Check for inconsistencies between graphs:
66+
67+
```
68+
verify.py -g case.ttl -gf turtle -i output.json-ld -if json-ld --verify=1
69+
```
70+
71+
* Check for inconsistencies between graphs with color output:
72+
```
73+
verify.py -g case.ttl -gf turtle -i output.json-ld -if json-ld --verify=1 --color=1
74+
```
75+
76+
* Enter debug mode. This will cause a PDB session to open when an inconsistency is met. This can be useful for manually navigating the RDF graph in Python.:
77+
```
78+
verify.py -g case.ttl -gf turtle -i output.json-ld -if json-ld --verify=1 --debug=1
79+
80+
```
81+
82+
* Print all graphs for tool's schema.
83+
84+
```
85+
verify.py -g case.ttl -gf turtle -i output.json-ld -if json-ld -tg=1
86+
87+
```
88+
89+
* Print all graphs for ontology's schema.
90+
91+
```
92+
verify.py -g case.ttl -gf turtle -i output.json-ld -if json-ld -gg=1
93+
94+
```
95+
96+
### Submitting an Issue
97+
If/when you run into an issue with a given RDF schema format or the verifier.py script, please open an issue with the error
98+
and as much technical detail as you can provide.

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
rdflib
2+
rdflib-jsonld
3+
owl
4+
colorama

src/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# 'Approved for Public Release; Distribution Unlimited. Case Number 18-0399'.
2+
3+
# NOTICE
4+
#
5+
# This software was produced for the U.S. Government under
6+
# contract SB-1341-14-CQ-0010, and is subject to the Rights
7+
# in Data-General Clause 52.227-14, Alt. IV (DEC 2007)
8+
#
9+
# (c) 2018 The MITRE Corporation. All Rights Reserved.
10+
11+
12+
all = ['ontology']

0 commit comments

Comments
 (0)