aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
diff options
context:
space:
mode:
authorFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-09 12:30:20 +0100
committerFederico Igne <federico.igne@cs.ox.ac.uk>2022-05-09 12:30:20 +0100
commit98312cd3c355a2b036edf5236dfcba755da9a17a (patch)
tree02ee6d77e0eec89610d4ad310557bc1bb6c2394f /src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
parent155f04db8138d62b3abc2eb777b8453560bbb594 (diff)
downloadRSAComb-98312cd3c355a2b036edf5236dfcba755da9a17a.tar.gz
RSAComb-98312cd3c355a2b036edf5236dfcba755da9a17a.zip
Refactor code
Diffstat (limited to 'src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala')
-rw-r--r--src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala43
1 files changed, 16 insertions, 27 deletions
diff --git a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
index 2daa634..21b4cd2 100644
--- a/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
+++ b/src/main/scala/uk/ac/ox/cs/rsacomb/Main.scala
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2020, 2021 KRR Oxford 2 * Copyright 2020-2022 KRR Oxford
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
@@ -16,42 +16,31 @@
16 16
17package uk.ac.ox.cs.rsacomb 17package uk.ac.ox.cs.rsacomb
18 18
19import java.io.{File, PrintWriter} 19import approximation.{Lowerbound,Upperbound}
20import java.nio.file.{Path, Paths, InvalidPathException} 20import converter.Normalizer
21import java.util.HashMap 21import ontology.Ontology
22import scala.collection.JavaConverters._
23import tech.oxfordsemantic.jrdfox.client.UpdateType
24import tech.oxfordsemantic.jrdfox.logic.expression.{IRI, Term}
25import tech.oxfordsemantic.jrdfox.logic.sparql.statement.SelectQuery
26
27import util.{Logger, RDFoxUtil, RSA} 22import util.{Logger, RDFoxUtil, RSA}
28import sparql.ConjunctiveQuery
29
30import uk.ac.ox.cs.rsacomb.ontology.Ontology
31import uk.ac.ox.cs.rsacomb.converter.Normalizer
32import uk.ac.ox.cs.rsacomb.approximation.Approximation
33 23
34/** Main entry point to the program */
35object RSAComb extends App { 24object RSAComb extends App {
36
37 /* Command-line options */
38 val config = RSAConfig.parse(args.toList) 25 val config = RSAConfig.parse(args.toList)
26 RSAConfig describe config
39 27
40 /* Set logger level */ 28 /* Configure logger */
41 if (config.contains('logger)) 29 if (config.contains('logger))
42 Logger.level = config('logger).get[Logger.Level] 30 Logger.level = config('logger).get[Logger.Level]
43
44 /* Set answers output file */
45 if (config.contains('answers)) 31 if (config.contains('answers))
46 Logger.answers = config('answers).get[os.Path] 32 Logger.answers = config('answers).get[os.Path]
47 33
48 /* Load original ontology and normalize it */ 34 /* Load original ontology and normalize it */
49 val ontopath = config('ontology).get[os.Path] 35 val ontopath = config('ontology).get[os.Path]
50 val data = config('data).get[List[os.Path]] 36 val datapath = config('data).get[List[os.Path]]
51 val ontology = Ontology(ontopath, data).normalize(new Normalizer) 37 val ontology = Ontology(ontopath, datapath).normalize(new Normalizer)
52 38
53 /* Approximate the ontology to RSA */ 39 /* Approximate the ontology if necessary */
54 val toRSA = config('approximation).get[Approximation[RSAOntology]] 40 val toRSA = config('approximation).get[Symbol] match {
41 case 'lowerbound => new Lowerbound
42 case 'upperbound => new Upperbound
43 }
55 val rsa = ontology approximate toRSA 44 val rsa = ontology approximate toRSA
56 45
57 if (config contains 'queries) { 46 if (config contains 'queries) {
@@ -61,11 +50,11 @@ object RSAComb extends App {
61 RSA.Prefixes 50 RSA.Prefixes
62 ) 51 )
63 52
53 /* Perform query answering */
64 val answers = rsa ask queries 54 val answers = rsa ask queries
65 55
66 /* Write answers to output file */ 56 /* Perform logging */
67 Logger write answers 57 Logger write answers
68 /* Generate simulation script */ 58 Logger.generateSimulationScripts(datapath, queries)
69 Logger.generateSimulationScripts(data, queries)
70 } 59 }
71} 60}