net.sf.okapi.common.Util.fillRootDirectoryVariable()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中net.sf.okapi.common.Util.fillRootDirectoryVariable()方法的一些代码示例,展示了Util.fillRootDirectoryVariable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.fillRootDirectoryVariable()方法的具体详情如下:
包路径:net.sf.okapi.common.Util
类名称:Util
方法名:fillRootDirectoryVariable

Util.fillRootDirectoryVariable介绍

[英]Replaces in a given original string, a potential variable ROOT_DIRECTORY_VAR by a given root directory.
[中]在给定的原始字符串中,用给定的根目录替换潜在变量ROOT_DIRECTORY_VAR。

代码示例

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Expand all supported variables and canonicalize (resolve ".." and ".")
 * a path. If the input path has no variables, it is returned unchanged.
 * rootDir and inputRootDir can be null.
 * @param path The path to expand
 * @param rootDir The directory to expand ${rootDir} into
 * @param inputRootDir The directory to expand ${inputRootDir} into
 * @return The expanded path
 * @throws IOException If canonicalizing fails
 */
public static String expandPath (String path, String rootDir, String inputRootDir)
    throws IOException {
  if (!path.contains("${")) return path;
  
  path = Util.fillSystemEnvars(path);
  path = Util.fillRootDirectoryVariable(path, rootDir);
  path = Util.fillInputRootDirectoryVariable(path, inputRootDir);
  path = new File(path).getCanonicalPath();
  return path;
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-termextraction

@Override
protected Event handleEndBatch (Event event) {
  extractor.completeExtraction();
  String finalPath = Util.fillRootDirectoryVariable(params.getOutputPath(), rootDir);
  LOGGER.info("Output: {}", finalPath);
  LOGGER.info("Candidate terms found = {}", extractor.getTerms().size());
  if ( params.getAutoOpen() ) {
    Util.openURL((new File(finalPath)).getAbsolutePath());
  }
  return event;
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-termextraction

/**
 * Generates the report file with the results.
 */
private void generateReport () {
  // Output the report
  PrintWriter writer = null;
  try {
    String finalPath = Util.fillRootDirectoryVariable(params.getOutputPath(), rootDir);
    finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir);
    Util.createDirectories(finalPath);
    writer = new PrintWriter(finalPath, "UTF-8");
    for ( Entry<String, Integer> entry : terms.entrySet() ) {
      writer.println(String.format("%d\t%s", entry.getValue(), entry.getKey()));
    }
  }
  catch ( IOException e ) {
    throw new OkapiException("Error when writing output file.", e);
  }
  finally {
    if ( writer != null ) {
      writer.close();
      writer = null;
    }
  }
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-generatesimpletm

@Override
protected Event handleStartBatchItem (Event event) {
  if(simpleTm == null){
    simpleTm = new Database();
    simpleTm.create(Util.fillRootDirectoryVariable(params.getTmPath(), rootDir),
      true, targetLocale);
  }        
  return event;
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-searchandreplace

private void generateReport (String text) {
  // Output the report
  PrintWriter writer = null;
  try {
    String finalPath = Util.fillRootDirectoryVariable(params.getLogPath(), rootDir);
    finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir);
    Util.createDirectories(finalPath);
    writer = new PrintWriter(finalPath, "UTF-8");
    writer.println(text);
  }
  catch ( IOException e ) {
    throw new OkapiException("Error when writing output file.", e);
  }
  finally {
    if ( writer != null ) {
      writer.close();
      writer = null;
    }
  }
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-msbatchtranslation

if ( propFile != null ) {
  propFile = propFile.trim();
  propFile = Util.fillRootDirectoryVariable(propFile, rootDir);
  propFile = Util.fillInputRootDirectoryVariable(propFile, inputRootDir);
  propFile = LocaleId.replaceVariables(propFile, sourceLocale, targetLocale);

代码示例来源:origin: net.sf.okapi.steps/okapi-step-searchandreplace

String finalPath = Util.fillRootDirectoryVariable(params.getReplacementsPath(), rootDir);
finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir);
replacementWords = loadList(finalPath);

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-verification-ui

private void generateReport () {
  try {
    startWaiting("Generating report...");
    String rootDir = (qcsPath==null ? null : Util.getDirectoryName(qcsPath));
    session.generateReport(rootDir);
    String finalPath = Util.fillRootDirectoryVariable(session.getParameters().getOutputPath(), rootDir);
    if ( session.getParameters().getAutoOpen() ) {
      Util.openURL((new File(finalPath)).getAbsolutePath());
    }
  }
  catch ( Throwable e ) {
    Dialogs.showError(shell, "Error while generating report.\n"+e.getMessage(), null);
  }
  finally {
    stopWaiting();
  }
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-gttbatchtranslation

String tmxOutputPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir);
tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, sourceLocale, targetLocale);
tmxWriter = new TMXWriter(tmxOutputPath);

代码示例来源:origin: net.sf.okapi.connectors/okapi-connector-simpletm

@Override
public void open () {
  db.open(Util.fillRootDirectoryVariable(params.getDbPath(), rootDir));
  db.setPenalizeSourceWithDifferentCodes(params.getPenalizeSourceWithDifferentCodes());
  db.setPenalizeTargetWithDifferentCodes(params.getPenalizeTargetWithDifferentCodes());
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-rainbowkit

origin = Util.fillRootDirectoryVariable(origin, rootDir);
origin = Util.fillInputRootDirectoryVariable(origin, inputRootDir);
origin = LocaleId.replaceVariables(origin, manifest.getSourceLocale(), manifest.getTargetLocale());

代码示例来源:origin: net.sf.okapi.steps/okapi-step-leveraging

private void initialize () {
  if ( params.getMakeTMX() ) {
    String tmxOutputPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir);
    tmxOutputPath = Util.fillInputRootDirectoryVariable(tmxOutputPath, inputRootDir);
    tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, srcLoc, trgLoc);
    String existingTMPath = Util.fillRootDirectoryVariable(params.getExistingTm(), rootDir);
    existingTMPath = Util.fillInputRootDirectoryVariable(existingTMPath, inputRootDir);
    existingTMPath = LocaleId.replaceVariables(existingTMPath, srcLoc, trgLoc);
  if ( params.getSegment() ) {
    SRXDocument srxDoc = new SRXDocument();
    String srxPath = Util.fillRootDirectoryVariable(params.getSrxPath(), rootDir);
    srxPath = Util.fillInputRootDirectoryVariable(srxPath, inputRootDir);
    srxPath = LocaleId.replaceVariables(srxPath, srcLoc, trgLoc);

代码示例来源:origin: net.sf.okapi.steps/okapi-step-rainbowkit

resolvedOutputDir = Util.fillRootDirectoryVariable(resolvedOutputDir, rootDir);
resolvedOutputDir = Util.fillInputRootDirectoryVariable(resolvedOutputDir, inputRootDir);
resolvedOutputDir = LocaleId.replaceVariables(resolvedOutputDir, srcLoc, trgLoc);

代码示例来源:origin: net.sf.okapi.steps/okapi-step-translationcomparison

String resolvedPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir);
resolvedPath = Util.fillInputRootDirectoryVariable(resolvedPath, inputRootDir);
resolvedPath = LocaleId.replaceVariables(resolvedPath, sourceLocale, targetLocale);

代码示例来源:origin: net.sf.okapi.steps/okapi-step-msbatchtranslation

tmxOutputPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir);
tmxOutputPath = Util.fillInputRootDirectoryVariable(tmxOutputPath, inputRootDir);
tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, sourceLocale, targetLocale);

代码示例来源:origin: net.sf.okapi.steps/okapi-step-leveraging

String tmDir = Util.fillRootDirectoryVariable(params.getTmDirectory(), rootDir);
tmDir = Util.fillInputRootDirectoryVariable(tmDir, inputRootDir);
tmDir = LocaleId.replaceVariables(tmDir, srcLoc, trgLoc);

代码示例来源:origin: net.sf.okapi.steps/okapi-step-leveraging

String realPath = Util.fillRootDirectoryVariable(params.getTMXPath(), rootDir);
realPath = Util.fillInputRootDirectoryVariable(realPath, inputRootDir);
realPath = LocaleId.replaceVariables(realPath, sourceLocale, targetLocale);

代码示例来源:origin: net.sf.okapi.steps/okapi-step-segmentation

src = Util.fillRootDirectoryVariable(params.getSourceSrxPath(), rootDir);
src = Util.fillInputRootDirectoryVariable(src, inputRootDir);            
srxDoc.loadRules(src);
String trg = Util.fillRootDirectoryVariable(params.getTargetSrxPath(), rootDir);
trg = Util.fillInputRootDirectoryVariable(trg, inputRootDir);

相关文章