Skip to content

Commit

Permalink
Merge pull request #121 from dice-group/owlapy_serve_example
Browse files Browse the repository at this point in the history
owlapy_serve usage in examples folder
  • Loading branch information
Demirrr authored Dec 2, 2024
2 parents e4f59b7 + 2f6c417 commit f6d98b5
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions examples/owlapy_serve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# To start the FastAPI server with the 'family-benchmark_rich_background.owl' ontology,
# run the following command in your terminal:
# $ owlapy-serve --path_kb KGs/Family/family-benchmark_rich_background.owl --reasoner HermiT

# Optionally, you provide custom host and port for the FastAPI server:
# $ owlapy-serve --path_kb KGs/Family/family-benchmark_rich_background.owl --reasoner HermiT --host 0.0.0.0 --port 8000
import requests

# Base URL where your FastAPI server is running
BASE_URL = 'http://localhost:8000'

# 1. Get Classes in the Ontology
print("1. Get Classes:")
response = requests.get(f'{BASE_URL}/classes')
print('Classes:', response.json())

# 2. Get Object Properties in the Ontology
print("\n2. Get Object Properties:")
response = requests.get(f'{BASE_URL}/object_properties')
print('Object Properties:', response.json())

# 3. Get Data Properties in the Ontology
print("\n3. Get Data Properties:")
response = requests.get(f'{BASE_URL}/data_properties')
print('Data Properties:', response.json())

# 4. Get Individuals in the Ontology
print("\n4. Get Individuals:")
response = requests.get(f'{BASE_URL}/individuals')
print('Individuals:', response.json())

# 5. Get ABox Axioms (Assertions about individuals)
print("\n5. Get ABox Axioms:")
response = requests.get(f'{BASE_URL}/abox')
print('ABox Axioms:', response.json())

# 6. Get TBox Axioms (Class and property definitions)
print("\n6. Get TBox Axioms:")
response = requests.get(f'{BASE_URL}/tbox')
print('TBox Axioms:', response.json())

# 7. Get Instances of a Specific Class
print("\n7. Get Instances of a Class:")
class_iri_request = {
"class_iri": "http://www.example.org/family#Person"
}
response = requests.post(f'{BASE_URL}/instances', json=class_iri_request)
print('Instances of Class:', response.json())

# 8. Infer Axioms of a Specific Type
print("\n8. Infer Subclass Axioms:")
inference_request = {
"inference_type": "InferredSubClassAxiomGenerator"
}
response = requests.post(f'{BASE_URL}/infer_axioms', json=inference_request)
print('Inferred Subclass Axioms:', response.json())

# 9. Infer All Types of Axioms
print("\n9. Infer All Axioms:")
inference_request = {
"inference_type": "all"
}
response = requests.post(f'{BASE_URL}/infer_axioms', json=inference_request)
print('All Inferred Axioms:', response.json())

0 comments on commit f6d98b5

Please sign in to comment.