Skip to content

Commit 2f62884

Browse files
committed
evol. adding -sa (--single-axiom) feature
1 parent d298d01 commit 2f62884

File tree

5 files changed

+76
-47
lines changed

5 files changed

+76
-47
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
-d (--dynamic-timeout) ANGULAR_COEFF : use a dynamic time-out for axiom
4343
testing (default: 0.0)
4444
-g (--grammar) GRAMMAR : use this file as the axiom grammar
45-
(default: /home/remicode/resources/OWL2A
45+
(default: /rdfminer/code/resources/OWL2A
4646
xiom-test.bnf)
4747
-o (--output) RESULTFILE : name of output file (without
4848
extension): the name 'results' is
@@ -52,6 +52,7 @@
5252
(default: false)
5353
-s (--subclasslist) FILE : test subClassOf axioms generated from
5454
the list of subclasses in the given file
55+
-sa (--single-axiom) AXIOM : test a single axiom given
5556
-t (--timeout) MINUTES : use this time-out (in minutes) for
5657
axiom testing (default: 0)
5758
```

code/src/main/java/com/i3s/app/rdfminer/RDFMiner.java

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -138,30 +138,27 @@ public static void main(String[] args) {
138138
// Set SPARQL Endpoit
139139
endpoint = new SparqlEndpoint(Global.SPARQL_ENDPOINT, PREFIXES);
140140

141-
// Create an empty json object which will be fill with our results
142-
JSONObject json = new JSONObject();
143-
144-
try {
145-
output = new FileWriter(Global.OUTPUT_PATH + parameters.resultFile + ".json");
146-
} catch (/* JAXBException | */IOException e) {
147-
logger.error(e.getMessage());
148-
e.printStackTrace();
149-
System.exit(1);
150-
}
151-
152141
AxiomGenerator generator = null;
153142
BufferedReader axiomFile = null;
154143

144+
// Create an empty JSON object which will be fill with our results
145+
JSONObject json = new JSONObject();
146+
155147
if (parameters.axiomFile == null) {
156-
if (parameters.useRandomAxiomGenerator) {
157-
logger.info("Initializing the random axiom generator with grammar " + parameters.grammarFile + "...");
158-
generator = new RandomAxiomGenerator(parameters.grammarFile);
159-
} else if (parameters.subclassList != null) {
160-
logger.info("Initializing the increasing TP axiom generator...");
161-
generator = new IncreasingTimePredictorAxiomGenerator(parameters.subclassList);
148+
if (parameters.axiom == null) {
149+
if (parameters.useRandomAxiomGenerator) {
150+
logger.info(
151+
"Initializing the random axiom generator with grammar " + parameters.grammarFile + "...");
152+
generator = new RandomAxiomGenerator(parameters.grammarFile);
153+
} else if (parameters.subclassList != null) {
154+
logger.info("Initializing the increasing TP axiom generator...");
155+
generator = new IncreasingTimePredictorAxiomGenerator(parameters.subclassList);
156+
} else {
157+
logger.info("Initializing the candidate axiom generator...");
158+
generator = new CandidateAxiomGenerator(parameters.grammarFile);
159+
}
162160
} else {
163-
logger.info("Initializing the candidate axiom generator...");
164-
generator = new CandidateAxiomGenerator(parameters.grammarFile);
161+
logger.info("launch test on a single axiom");
165162
}
166163
} else {
167164
logger.info("Reading axioms from file " + parameters.axiomFile + "...");
@@ -176,6 +173,19 @@ public static void main(String[] args) {
176173

177174
executor = Executors.newSingleThreadExecutor();
178175

176+
if (parameters.axiom == null) {
177+
// as the test of a single axiom is return on standard output, we don't need to
178+
// write
179+
// file of the results
180+
try {
181+
output = new FileWriter(Global.OUTPUT_PATH + parameters.resultFile + ".json");
182+
} catch (IOException e) {
183+
logger.error(e.getMessage());
184+
e.printStackTrace();
185+
System.exit(1);
186+
}
187+
}
188+
179189
while (true) {
180190

181191
Axiom a = null;
@@ -201,7 +211,14 @@ public static void main(String[] args) {
201211
}
202212
} else {
203213
try {
204-
axiomName = axiomFile.readLine();
214+
if (axiomFile == null && parameters.axiom != null) {
215+
axiomName = parameters.axiom;
216+
} else if (axiomFile != null && parameters.axiom == null) {
217+
axiomName = axiomFile.readLine();
218+
} else {
219+
logger.error("'-a' and '-sa' are used at the same time");
220+
System.exit(1);
221+
}
205222
if (axiomName == null)
206223
break;
207224
if (axiomName.isEmpty())
@@ -232,32 +249,40 @@ public static void main(String[] args) {
232249
reportJSON.confirmations = a.confirmations;
233250
if (a.numExceptions > 0 && a.numExceptions < 100)
234251
reportJSON.exceptions = a.exceptions;
252+
253+
// fill json results
254+
json.append(axiomName, reportJSON.toJSON());
235255

236256
// print useful results
237257
logger.info("Num. confirmations: " + a.numConfirmations);
238258
logger.info("Num. exceptions: " + a.numExceptions);
239-
logger.info("Possibility = " + reportJSON.possibility);
240-
logger.info("Necessity = " + reportJSON.necessity);
259+
logger.info("Possibility = " + a.possibility().doubleValue());
260+
logger.info("Necessity = " + a.necessity().doubleValue());
241261

242-
if (a instanceof SubClassOfAxiom && reportJSON.necessity > 1.0 / 3.0) {
262+
if (a instanceof SubClassOfAxiom && a.necessity().doubleValue() > 1.0 / 3.0) {
243263
SubClassOfAxiom sa = (SubClassOfAxiom) a;
244-
SubClassOfAxiom.maxTestTime.maxput(sa.timePredictor(), reportJSON.elapsedTime);
264+
SubClassOfAxiom.maxTestTime.maxput(sa.timePredictor(), t - t0);
245265
}
246266

247-
json.append(axiomName, reportJSON.toJSON());
248-
267+
if(parameters.axiom != null) {
268+
System.out.println("[RES]" + json.toString());
269+
break;
270+
}
271+
249272
} else
250273
logger.warn("Axiom type not supported yet!");
251274
logger.info("Test completed in " + (t - t0) + " ms.");
252275
}
253276
logger.info("Done testing axioms. Exiting.");
254-
try {
255-
output.write(json.toString());
256-
output.close();
257-
} catch (IOException e) {
258-
logger.error("I/O error while closing CSV writer: " + e.getMessage());
259-
e.printStackTrace();
260-
System.exit(1);
277+
if (parameters.axiom == null) {
278+
try {
279+
output.write(json.toString());
280+
output.close();
281+
} catch (IOException e) {
282+
logger.error("I/O error while closing CSV writer: " + e.getMessage());
283+
e.printStackTrace();
284+
System.exit(1);
285+
}
261286
}
262287
System.exit(0);
263288
}

code/src/main/java/com/i3s/app/rdfminer/axiom/type/SubClassOfAxiom.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ public SubClassOfAxiom(List<Symbol> subClassExpression, List<Symbol> superClassE
8484
else
8585
superClassComplement = new ComplementClassExpression(superClass);
8686

87-
System.out.println("\nsub-class = " + subClass + "; graph pattern =");
88-
System.out.println(SparqlEndpoint.prettyPrint(subClass.graphPattern));
87+
// System.out.println("\nsub-class = " + subClass + "; graph pattern =");
88+
// System.out.println(SparqlEndpoint.prettyPrint(subClass.graphPattern));
8989

90-
System.out.println("\nsuper-class = " + superClass + "; graph pattern =");
91-
System.out.println(SparqlEndpoint.prettyPrint(superClass.graphPattern));
90+
// System.out.println("\nsuper-class = " + superClass + "; graph pattern =");
91+
// System.out.println(SparqlEndpoint.prettyPrint(superClass.graphPattern));
9292

93-
System.out.println("\n~super-class = " + superClassComplement + "; graph pattern =");
94-
System.out.println(SparqlEndpoint.prettyPrint(superClassComplement.graphPattern));
93+
// System.out.println("\n~super-class = " + superClassComplement + "; graph pattern =");
94+
// System.out.println(SparqlEndpoint.prettyPrint(superClassComplement.graphPattern));
9595

9696
try {
9797
update();

code/src/main/java/com/i3s/app/rdfminer/parameters/CmdLineParameters.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ public class CmdLineParameters {
2323
@Option(name = "-a", aliases = { "--axioms" }, usage = "test axioms contained in this file", metaVar = "AXIOMFILE")
2424
public String axiomFile = null;
2525

26+
@Option(name = "-sa", aliases = { "--single-axiom" }, usage = "test a single axiom given", metaVar = "AXIOM")
27+
public String axiom = null;
28+
2629
/**
2730
* The angular coefficient to be used for dynamic time capping of axiom test.
2831
* <p>

scripts/run.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
echo $(date +"%Y-%m-%d %H:%M:%S,%3N")" [run.sh] INFO - parameters: "${@}
44
arr=("$@")
55
for index in ${!arr[@]}; do
6-
if [ ${arr[index]} == "-a" ] || \
7-
[ ${arr[index]} == "--axioms" ] || \
8-
[ ${arr[index]} == "-g" ] || \
9-
[ ${arr[index]} == "--grammar" ] || \
10-
[ ${arr[index]} == "-s" ] || \
11-
[ ${arr[index]} == "--subclasslist" ]; then
6+
if [ "${arr[index]}" == "-a" ] || \
7+
[ "${arr[index]}" == "--axioms" ] || \
8+
[ "${arr[index]}" == "-g" ] || \
9+
[ "${arr[index]}" == "--grammar" ] || \
10+
[ "${arr[index]}" == "-s" ] || \
11+
[ "${arr[index]}" == "--subclasslist" ]; then
1212
echo $(date +"%Y-%m-%d %H:%M:%S,%3N")" [run.sh] INFO - set 'x' authorization : "${arr[index + 1]}\
1313
" for "${arr[index]}" option"
1414
# Set 'x' autorization for each file used
@@ -19,4 +19,4 @@ done
1919
# cd rdfminer/in/ && ls -al && cd ..
2020
echo $(date +"%Y-%m-%d %H:%M:%S,%3N")" [run.sh] INFO - launch rdfminer.jar ..."
2121
# Execute jar file with params
22-
${JAVA_HOME}bin/java -Xmx4g -Djava.library.path=${HOME}/code/resources/. -jar ${HOME}/jar/rdfminer-${RDFMINER_VERSION}.jar ${@}
22+
${JAVA_HOME}bin/java -Xmx4g -Djava.library.path=${HOME}/code/resources/. -jar ${HOME}/jar/rdfminer-${RDFMINER_VERSION}.jar "${@}"

0 commit comments

Comments
 (0)