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

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

本文整理了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

  1. /**
  2. * Expand all supported variables and canonicalize (resolve ".." and ".")
  3. * a path. If the input path has no variables, it is returned unchanged.
  4. * rootDir and inputRootDir can be null.
  5. * @param path The path to expand
  6. * @param rootDir The directory to expand ${rootDir} into
  7. * @param inputRootDir The directory to expand ${inputRootDir} into
  8. * @return The expanded path
  9. * @throws IOException If canonicalizing fails
  10. */
  11. public static String expandPath (String path, String rootDir, String inputRootDir)
  12. throws IOException {
  13. if (!path.contains("${")) return path;
  14. path = Util.fillSystemEnvars(path);
  15. path = Util.fillRootDirectoryVariable(path, rootDir);
  16. path = Util.fillInputRootDirectoryVariable(path, inputRootDir);
  17. path = new File(path).getCanonicalPath();
  18. return path;
  19. }

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

  1. @Override
  2. protected Event handleEndBatch (Event event) {
  3. extractor.completeExtraction();
  4. String finalPath = Util.fillRootDirectoryVariable(params.getOutputPath(), rootDir);
  5. LOGGER.info("Output: {}", finalPath);
  6. LOGGER.info("Candidate terms found = {}", extractor.getTerms().size());
  7. if ( params.getAutoOpen() ) {
  8. Util.openURL((new File(finalPath)).getAbsolutePath());
  9. }
  10. return event;
  11. }

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

  1. /**
  2. * Generates the report file with the results.
  3. */
  4. private void generateReport () {
  5. // Output the report
  6. PrintWriter writer = null;
  7. try {
  8. String finalPath = Util.fillRootDirectoryVariable(params.getOutputPath(), rootDir);
  9. finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir);
  10. Util.createDirectories(finalPath);
  11. writer = new PrintWriter(finalPath, "UTF-8");
  12. for ( Entry<String, Integer> entry : terms.entrySet() ) {
  13. writer.println(String.format("%d\t%s", entry.getValue(), entry.getKey()));
  14. }
  15. }
  16. catch ( IOException e ) {
  17. throw new OkapiException("Error when writing output file.", e);
  18. }
  19. finally {
  20. if ( writer != null ) {
  21. writer.close();
  22. writer = null;
  23. }
  24. }
  25. }

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

  1. @Override
  2. protected Event handleStartBatchItem (Event event) {
  3. if(simpleTm == null){
  4. simpleTm = new Database();
  5. simpleTm.create(Util.fillRootDirectoryVariable(params.getTmPath(), rootDir),
  6. true, targetLocale);
  7. }
  8. return event;
  9. }

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

  1. private void generateReport (String text) {
  2. // Output the report
  3. PrintWriter writer = null;
  4. try {
  5. String finalPath = Util.fillRootDirectoryVariable(params.getLogPath(), rootDir);
  6. finalPath = Util.fillInputRootDirectoryVariable(finalPath, inputRootDir);
  7. Util.createDirectories(finalPath);
  8. writer = new PrintWriter(finalPath, "UTF-8");
  9. writer.println(text);
  10. }
  11. catch ( IOException e ) {
  12. throw new OkapiException("Error when writing output file.", e);
  13. }
  14. finally {
  15. if ( writer != null ) {
  16. writer.close();
  17. writer = null;
  18. }
  19. }
  20. }

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

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

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

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

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

  1. private void generateReport () {
  2. try {
  3. startWaiting("Generating report...");
  4. String rootDir = (qcsPath==null ? null : Util.getDirectoryName(qcsPath));
  5. session.generateReport(rootDir);
  6. String finalPath = Util.fillRootDirectoryVariable(session.getParameters().getOutputPath(), rootDir);
  7. if ( session.getParameters().getAutoOpen() ) {
  8. Util.openURL((new File(finalPath)).getAbsolutePath());
  9. }
  10. }
  11. catch ( Throwable e ) {
  12. Dialogs.showError(shell, "Error while generating report.\n"+e.getMessage(), null);
  13. }
  14. finally {
  15. stopWaiting();
  16. }
  17. }

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

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

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

  1. @Override
  2. public void open () {
  3. db.open(Util.fillRootDirectoryVariable(params.getDbPath(), rootDir));
  4. db.setPenalizeSourceWithDifferentCodes(params.getPenalizeSourceWithDifferentCodes());
  5. db.setPenalizeTargetWithDifferentCodes(params.getPenalizeTargetWithDifferentCodes());
  6. }

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

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

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

  1. private void initialize () {
  2. if ( params.getMakeTMX() ) {
  3. String tmxOutputPath = Util.fillRootDirectoryVariable(params.getTmxPath(), rootDir);
  4. tmxOutputPath = Util.fillInputRootDirectoryVariable(tmxOutputPath, inputRootDir);
  5. tmxOutputPath = LocaleId.replaceVariables(tmxOutputPath, srcLoc, trgLoc);
  6. String existingTMPath = Util.fillRootDirectoryVariable(params.getExistingTm(), rootDir);
  7. existingTMPath = Util.fillInputRootDirectoryVariable(existingTMPath, inputRootDir);
  8. existingTMPath = LocaleId.replaceVariables(existingTMPath, srcLoc, trgLoc);
  9. if ( params.getSegment() ) {
  10. SRXDocument srxDoc = new SRXDocument();
  11. String srxPath = Util.fillRootDirectoryVariable(params.getSrxPath(), rootDir);
  12. srxPath = Util.fillInputRootDirectoryVariable(srxPath, inputRootDir);
  13. srxPath = LocaleId.replaceVariables(srxPath, srcLoc, trgLoc);

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

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

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

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

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

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

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

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

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

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

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

  1. src = Util.fillRootDirectoryVariable(params.getSourceSrxPath(), rootDir);
  2. src = Util.fillInputRootDirectoryVariable(src, inputRootDir);
  3. srxDoc.loadRules(src);
  4. String trg = Util.fillRootDirectoryVariable(params.getTargetSrxPath(), rootDir);
  5. trg = Util.fillInputRootDirectoryVariable(trg, inputRootDir);

相关文章