diff options
Diffstat (limited to 'src/uk/ac/ox/cs/pagoda/Pagoda.java')
| -rw-r--r-- | src/uk/ac/ox/cs/pagoda/Pagoda.java | 64 |
1 files changed, 43 insertions, 21 deletions
diff --git a/src/uk/ac/ox/cs/pagoda/Pagoda.java b/src/uk/ac/ox/cs/pagoda/Pagoda.java index 3263c03..4ad7678 100644 --- a/src/uk/ac/ox/cs/pagoda/Pagoda.java +++ b/src/uk/ac/ox/cs/pagoda/Pagoda.java | |||
| @@ -9,7 +9,7 @@ import uk.ac.ox.cs.pagoda.util.Utility; | |||
| 9 | import java.nio.file.Path; | 9 | import java.nio.file.Path; |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| 12 | * The main class | 12 | * Executable command line user interface. |
| 13 | */ | 13 | */ |
| 14 | public class Pagoda implements Runnable { | 14 | public class Pagoda implements Runnable { |
| 15 | 15 | ||
| @@ -19,31 +19,62 @@ public class Pagoda implements Runnable { | |||
| 19 | private static final String OPTION_ANSWER = "a"; | 19 | private static final String OPTION_ANSWER = "a"; |
| 20 | private static final String OPTION_CLASSIFY = "c"; | 20 | private static final String OPTION_CLASSIFY = "c"; |
| 21 | private static final String OPTION_HERMIT = "f"; | 21 | private static final String OPTION_HERMIT = "f"; |
| 22 | private final Properties properties; | ||
| 23 | |||
| 24 | /** | ||
| 25 | * Do not use it | ||
| 26 | * */ | ||
| 27 | private Pagoda() { | ||
| 28 | properties = new Properties(); | ||
| 29 | } | ||
| 22 | 30 | ||
| 23 | public static void main(String... args) { | 31 | public static void main(String... args) { |
| 24 | 32 | ||
| 25 | Options options = new Options(); | 33 | Options options = new Options(); |
| 26 | options.addOption(Option.builder(OPTION_ONTOLOGY).argName(OPTION_ONTOLOGY).required().hasArg().desc("The ontology path").build()); | 34 | options.addOption(Option.builder(OPTION_ONTOLOGY) |
| 35 | .argName(OPTION_ONTOLOGY) | ||
| 36 | .required() | ||
| 37 | .hasArg() | ||
| 38 | .desc("The ontology path") | ||
| 39 | .build()); | ||
| 27 | options.addOption(Option.builder(OPTION_DATA).argName(OPTION_DATA).hasArg().desc("The data path").build()); | 40 | options.addOption(Option.builder(OPTION_DATA).argName(OPTION_DATA).hasArg().desc("The data path").build()); |
| 28 | options.addOption(Option.builder(OPTION_QUERY).argName(OPTION_QUERY).required().hasArg().desc("The query path").build()); | 41 | options.addOption(Option.builder(OPTION_QUERY) |
| 29 | options.addOption(Option.builder(OPTION_ANSWER).argName(OPTION_ANSWER).hasArg().desc("The answer path").build()); | 42 | .argName(OPTION_QUERY) |
| 30 | options.addOption(Option.builder(OPTION_CLASSIFY).argName(OPTION_CLASSIFY).desc("Tell whether to classify").type(Boolean.class).build()); | 43 | .required() |
| 31 | options.addOption(Option.builder(OPTION_HERMIT).argName(OPTION_HERMIT).desc("Tell whether to call Hermit").type(Boolean.class).build()); | 44 | .hasArg() |
| 45 | .desc("The query path") | ||
| 46 | .build()); | ||
| 47 | options.addOption(Option.builder(OPTION_ANSWER) | ||
| 48 | .argName(OPTION_ANSWER) | ||
| 49 | .hasArg() | ||
| 50 | .desc("The answer path") | ||
| 51 | .build()); | ||
| 52 | options.addOption(Option.builder(OPTION_CLASSIFY) | ||
| 53 | .argName(OPTION_CLASSIFY) | ||
| 54 | .desc("Tell whether to classify") | ||
| 55 | .type(Boolean.class) | ||
| 56 | .build()); | ||
| 57 | options.addOption(Option.builder(OPTION_HERMIT) | ||
| 58 | .argName(OPTION_HERMIT) | ||
| 59 | .desc("Tell whether to call Hermit") | ||
| 60 | .type(Boolean.class) | ||
| 61 | .build()); | ||
| 32 | 62 | ||
| 33 | CommandLineParser parser = new DefaultParser(); | 63 | CommandLineParser parser = new DefaultParser(); |
| 34 | try { | 64 | try { |
| 35 | CommandLine cmd = parser.parse( options, args ); | 65 | CommandLine cmd = parser.parse(options, args); |
| 36 | PagodaBuilder pagodaBuilder = Pagoda.builder() | 66 | PagodaBuilder pagodaBuilder = Pagoda.builder() |
| 37 | .ontology(cmd.getOptionValue(OPTION_ONTOLOGY)) | 67 | .ontology(cmd.getOptionValue(OPTION_ONTOLOGY)) |
| 38 | .query(cmd.getOptionValue(OPTION_QUERY)); | 68 | .query(cmd.getOptionValue(OPTION_QUERY)); |
| 39 | if(cmd.hasOption(OPTION_DATA)) pagodaBuilder.data(cmd.getOptionValue(OPTION_DATA)); | 69 | if(cmd.hasOption(OPTION_DATA)) pagodaBuilder.data(cmd.getOptionValue(OPTION_DATA)); |
| 40 | if(cmd.hasOption(OPTION_ANSWER)) pagodaBuilder.answer(cmd.getOptionValue(OPTION_ANSWER)); | 70 | if(cmd.hasOption(OPTION_ANSWER)) pagodaBuilder.answer(cmd.getOptionValue(OPTION_ANSWER)); |
| 41 | if(cmd.hasOption(OPTION_CLASSIFY)) pagodaBuilder.classify(Boolean.parseBoolean(cmd.getOptionValue(OPTION_CLASSIFY))); | 71 | if(cmd.hasOption(OPTION_CLASSIFY)) |
| 42 | if(cmd.hasOption(OPTION_HERMIT)) pagodaBuilder.hermit(Boolean.parseBoolean(cmd.getOptionValue(OPTION_HERMIT))); | 72 | pagodaBuilder.classify(Boolean.parseBoolean(cmd.getOptionValue(OPTION_CLASSIFY))); |
| 73 | if(cmd.hasOption(OPTION_HERMIT)) | ||
| 74 | pagodaBuilder.hermit(Boolean.parseBoolean(cmd.getOptionValue(OPTION_HERMIT))); | ||
| 43 | 75 | ||
| 44 | pagodaBuilder.build().run(); | 76 | pagodaBuilder.build().run(); |
| 45 | } | 77 | } catch(ParseException exp) { |
| 46 | catch( ParseException exp ) { | ||
| 47 | HelpFormatter formatter = new HelpFormatter(); | 78 | HelpFormatter formatter = new HelpFormatter(); |
| 48 | formatter.printHelp("PAGOdA", options); | 79 | formatter.printHelp("PAGOdA", options); |
| 49 | Utility.logError("Parsing failed. Reason: " + exp.getMessage()); | 80 | Utility.logError("Parsing failed. Reason: " + exp.getMessage()); |
| @@ -52,15 +83,6 @@ public class Pagoda implements Runnable { | |||
| 52 | } | 83 | } |
| 53 | 84 | ||
| 54 | /** | 85 | /** |
| 55 | * Do not use it | ||
| 56 | * */ | ||
| 57 | private Pagoda() { | ||
| 58 | properties = new Properties(); | ||
| 59 | } | ||
| 60 | |||
| 61 | private final Properties properties; | ||
| 62 | |||
| 63 | /** | ||
| 64 | * Get a builder. | 86 | * Get a builder. |
| 65 | * */ | 87 | * */ |
| 66 | public static PagodaBuilder builder() { | 88 | public static PagodaBuilder builder() { |
