aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/pagoda/tester/PagodaTester.java
blob: 7d9b49c33273b6b5de871c7e876dad1bcf26473e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package uk.ac.ox.cs.pagoda.tester;

import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner;
import uk.ac.ox.cs.pagoda.util.Properties;
import uk.ac.ox.cs.pagoda.util.Timer;
import uk.ac.ox.cs.pagoda.util.Utility;

// TODO clean it, or code another one
public class PagodaTester {

	public static void main(String... args) {
//		Properties properties = new Properties(PagodaTester.class.
//				getClassLoader().getResource("uobm.properties").getPath());
		Properties properties = new Properties();

		int index = 0; 
		if (args.length > index) properties.setOntologyPath(args[index++]);   
		if (args.length > index && (args[index].endsWith(".ttl") || args[index].endsWith(".nt"))) properties.setDataPath(args[index++]);   
		if (args.length > index && args[index].endsWith(".sparql")) properties.setQueryPath(args[index++]);   
		if (args.length > index && !args[index].startsWith("-")) properties.setAnswerPath(args[index++]);   
		if (args.length > index) properties.setToClassify(Boolean.parseBoolean(args[index++].substring(1)));   
		if (args.length > index) properties.setToCallHermiT(Boolean.parseBoolean(args[index++].substring(1)));   
	
		Utility.logInfo("Ontology file: " + properties.getOntologyPath());
		Utility.logInfo("Data files: " + properties.getDataPath());
		Utility.logInfo("Query files: " + properties.getQueryPath());
		Utility.logInfo("Answer file: " + properties.getAnswerPath());
		
		QueryReasoner pagoda = null; 
		
		try {
			Timer t = new Timer();
			pagoda = QueryReasoner.getInstance(properties); 
			if (pagoda == null) return;
			
			Utility.logInfo("Preprocessing Done in " + t.duration()	+ " seconds.");
			
			if (properties.getQueryPath() != null)
				for (String queryFile: properties.getQueryPath().split(";"))
					pagoda.evaluate(pagoda.getQueryManager().collectQueryRecords(queryFile));
 		} finally {
			if (pagoda != null) pagoda.dispose();
		}
	}

}