コード例 #1
0
ファイル: GrobidMain.java プロジェクト: BigBoss21X/grobid
 /** Initialize the batch. */
 protected static void initProcess() {
   try {
     MockContext.setInitialContext(gbdArgs.getPath2grobidHome(), gbdArgs.getPath2grobidProperty());
   } catch (final Exception exp) {
     System.err.println("Grobid initialisation failed: " + exp);
   }
   GrobidProperties.getInstance();
 }
コード例 #2
0
ファイル: GrobidMain.java プロジェクト: BigBoss21X/grobid
 /** Infer some parameters not given in arguments. */
 protected static void inferParamsNotSet() {
   String tmpFilePath;
   if (gbdArgs.getPath2grobidHome() == null) {
     tmpFilePath = new File("grobid-home").getAbsolutePath();
     System.out.println("No path set for grobid-home. Using: " + tmpFilePath);
     gbdArgs.setPath2grobidHome(tmpFilePath);
     gbdArgs.setPath2grobidProperty(new File("grobid.properties").getAbsolutePath());
   }
 }
コード例 #3
0
ファイル: GrobidMain.java プロジェクト: BigBoss21X/grobid
 /**
  * Process batch given the args.
  *
  * @param pArgs The arguments given to the batch.
  */
 protected static boolean processArgs(final String[] pArgs) {
   boolean result = true;
   if (pArgs.length == 0) {
     System.out.println(getHelp());
     result = false;
   } else {
     String currArg;
     for (int i = 0; i < pArgs.length; i++) {
       currArg = pArgs[i];
       if (currArg.equals("-h")) {
         System.out.println(getHelp());
         result = false;
         break;
       }
       if (currArg.equals("-gH")) {
         gbdArgs.setPath2grobidHome(pArgs[i + 1]);
         if (pArgs[i + 1] != null) {
           gbdArgs.setPath2grobidProperty(getPath2GbdProperties(pArgs[i + 1]));
         }
         i++;
         continue;
       }
       if (currArg.equals("-dIn")) {
         gbdArgs.setPath2Input(pArgs[i + 1]);
         gbdArgs.setPdf(true);
         i++;
         continue;
       }
       if (currArg.equals("-s")) {
         gbdArgs.setInput(pArgs[i + 1]);
         gbdArgs.setPdf(false);
         i++;
         continue;
       }
       if (currArg.equals("-dOut")) {
         gbdArgs.setPath2Output(pArgs[i + 1]);
         i++;
         continue;
       }
       if (currArg.equals("-exe")) {
         final String command = pArgs[i + 1];
         if (availableCommands.contains(command)) {
           gbdArgs.setProcessMethodName(command);
           i++;
           continue;
         } else {
           System.err.println(
               "-exe value should be one value from this list: " + availableCommands);
           result = false;
           break;
         }
       }
     }
   }
   return result;
 }
コード例 #4
0
ファイル: GrobidMain.java プロジェクト: BigBoss21X/grobid
  /**
   * Starts Grobid from command line using the following parameters:
   *
   * @param args The arguments
   */
  public static void main(final String[] args) throws Exception {
    gbdArgs = new GrobidMainArgs();
    availableCommands = ProcessEngine.getUsableMethods();

    if (processArgs(args)) {
      inferParamsNotSet();
      initProcess();
      ProcessEngine processEngine = new ProcessEngine();
      Utilities.launchMethod(processEngine, new Object[] {gbdArgs}, gbdArgs.getProcessMethodName());
    }
  }