Ejemplo n.º 1
0
  /**
   * Initialises the FeatureExtractor from a set of parameters, for example sent as command-line
   * arguments
   *
   * @param args The list of arguments
   */
  public AbstractFeatureExtractor(String[] args) {
    setWorkDir(System.getProperty("user.dir"));
    new Logger("log.txt");
    parseArguments(args);

    setInput(workDir + File.separator + resourceManager.getString("input"));
    setOutput(output = workDir + File.separator + resourceManager.getString("output"));
  }
Ejemplo n.º 2
0
  private void setupHomeDir(String homeString) {
    if (homeString == null) {
      homeString = sysProps.getProperty("swingri.home");
    }

    if (homeString != null) {
      dataDir = new File(homeString);
    } else {
      userHome = new File(sysProps.getProperty("user.home"));
      String dataDirStr = props.getString("application.datadir", DEFAULT_HOME_DIR);
      dataDir = new File(userHome, dataDirStr);
    }

    if (!dataDir.isDirectory()) {
      String path = dataDir.getAbsolutePath();
      boolean create;
      if (props.hasUserRejectedCreatingLocalDataDir()) {
        create = false;
      } else if (getBoolean("application.showLocalStorageDialogs", true)) {
        create =
            Resources.showConfirmDialog(
                null,
                messageBundle,
                "fontManager.properties.title",
                "manager.properties.createNewDirectory",
                path);
        if (!create) props.setUserRejectedCreatingLocalDataDir();
      } else {
        // Always create local-storage directory if show user prompt dialog setting is false.
        create = true;
      }

      if (!create) {
        dataDir = null;
      } else {
        dataDir.mkdirs();
        if (!dataDir.isDirectory()) {
          // check to make sure that dialog should be shown on the error.
          if (getBoolean("application.showLocalStorageDialogs", true)) {
            Resources.showMessageDialog(
                null,
                JOptionPane.ERROR_MESSAGE,
                messageBundle,
                "fontManager.properties.title",
                "manager.properties.failedCreation",
                dataDir.getAbsolutePath());
          }
          dataDir = null;
        }
      }
    }
  }
Ejemplo n.º 3
0
 private Boolean getBooleanImpl(String propertyName) {
   String value = props.getString(propertyName);
   if (value != null) {
     Boolean result = Parse.parseBoolean(value, messageBundle);
     if (result != null) {
       return result;
     }
     props.remove(propertyName);
   }
   value = props.getString(propertyName);
   if (value != null) {
     Boolean result = Parse.parseBoolean(value, null);
     if (result != null) {
       return result;
     }
     throwBrokenDefault(propertyName, value);
   }
   return null;
 }
Ejemplo n.º 4
0
  /**
   * constructs the folders required by the application. These are, typically: <br>
   *
   * <ul>
   *   <li>/input and subfolders
   *       <ul>
   *         <li>/input/<i>sourceLang</i>, /input/<i>targetLang</i> (for storing the results of
   *             processing the input files with various tools, such as pos tagger, transliterator,
   *             morphological analyser),<br>
   *         <li>/input/systems/<i>systemName</i> (for storing system specific resources - for
   *             example, the compiled and processed word lattices in the case of the IBM system
   *       </ul>
   *   <li>/output (for storing the resulting feature files),
   * </ul>
   *
   * Subclasses can override this method to construct, for example, subfolders of the systems folder
   * for each available MT system, or temporary folders
   */
  public void constructFolders() {

    File f = new File(input);
    if (!f.exists()) {
      f.mkdir();
      System.out.println("folder created " + f.getPath());
    }

    f = new File(input + File.separator + sourceLang);
    if (!f.exists()) {
      f.mkdir();
      System.out.println("folder created " + f.getPath());
    }
    f = new File(input + File.separator + targetLang);
    if (!f.exists()) {
      f.mkdir();
      System.out.println("folder created " + f.getPath());
    }
    f = new File(input + File.separator + targetLang + File.separator + "temp");
    if (!f.exists()) {
      f.mkdir();
      System.out.println("folder created " + f.getPath());
    }

    f = new File(input + File.separator + "systems");
    if (!f.exists()) {
      f.mkdir();
      System.out.println("folder created " + f.getPath());
    }

    String output = resourceManager.getString("output");
    f = new File(output);
    if (!f.exists()) {
      f.mkdir();
      System.out.println("folder created " + f.getPath());
    }
  }