edu.illinois.cs.cogcomp.core.io.IOUtils.getFileName()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(123)

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

IOUtils.getFileName介绍

[英]Returns the file name from a full path.
[中]从完整路径返回文件名。

代码示例

代码示例来源:origin: CogComp/cogcomp-nlp

public static String getFileStem(String path) {
  return stripFileExtension(getFileName(path));
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities

public static String getFileStem(String path) {
  return stripFileExtension(getFileName(path));
}

代码示例来源:origin: CogComp/cogcomp-nlp

/**
 * A workaround for the unit tests in Maven that move the relative path of the root directory in
 * {@link ESRLConfigurator} to the directory of each module. <b>NB:</b> This code assumes the
 * default data directory to be <i>$ROOT_DIR/data/</i>.
 *
 * @param file The file/directory to be used
 * @return The same file/directory moved to the root dir of the main project
 */
protected String getCorrectPath(String file) {
  if (file.contains("data") && !IOUtils.exists(new File(file).getParent())) {
    int dataIndex = file.indexOf("data") - 1;
    int prevSlashIndex = file.lastIndexOf(File.separator, dataIndex - 1);
    String fileWithParentDir =
        file.substring(0, prevSlashIndex) + file.substring(dataIndex, file.length());
    logger.warn("{} doesn't exist, trying parent directory: {}.",
        IOUtils.getFileName(file), fileWithParentDir);
    file = fileWithParentDir;
  }
  return file;
}

代码示例来源:origin: CogComp/cogcomp-nlp

public void readFile(String fileName) {
  try {
    List<String> lines = LineIO.read(fileName);
    for (int i = 0; i < lines.size(); i++) {
      String line = lines.get(i);
      String sentId = IOUtils.getFileName(fileName) + ":" + i;
      textAnnotations.add(createTextAnnotation(line, sentId));
    }
  } catch (FileNotFoundException e) {
    logger.error("Could not read {}; unable to continue.", fileName);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-corpusreaders

public void readFile(String fileName) {
  try {
    List<String> lines = LineIO.read(fileName);
    for (int i = 0; i < lines.size(); i++) {
      String line = lines.get(i);
      String sentId = IOUtils.getFileName(fileName) + ":" + i;
      textAnnotations.add(createTextAnnotation(line, sentId));
    }
  } catch (FileNotFoundException e) {
    logger.error("Could not read {}; unable to continue.", fileName);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/esrl-core

/**
 * A workaround for the unit tests in Maven that move the relative path of the root directory
 * in {@link ESRLConfigurator} to the directory of each module. <b>NB:</b> This code assumes
 * the default data directory to be <i>$ROOT_DIR/data/</i>.
 *
 * @param file The file/directory to be used
 * @return The same file/directory moved to the root dir of the main project
 */
protected String getCorrectPath(String file) {
  if (file.contains("data") && !IOUtils.exists(new File(file).getParent())) {
    int dataIndex = file.indexOf("data") - 1;
    int prevSlashIndex = file.lastIndexOf(File.separator, dataIndex - 1);
    String fileWithParentDir = file.substring(0, prevSlashIndex) + file.substring(dataIndex, file.length());
    logger.warn("{} doesn't exist, trying parent directory: {}.", IOUtils.getFileName(file), fileWithParentDir);
    file = fileWithParentDir;
  }
  return file;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-quantifier

/**
 * A workaround for the unit tests in Maven that move the relative path of the root directory in
 * {@link ESRLConfigurator} to the directory of each module. <b>NB:</b> This code assumes the
 * default data directory to be <i>$ROOT_DIR/data/</i>.
 *
 * @param file The file/directory to be used
 * @return The same file/directory moved to the root dir of the main project
 */
protected String getCorrectPath(String file) {
  if (file.contains("data") && !IOUtils.exists(new File(file).getParent())) {
    int dataIndex = file.indexOf("data") - 1;
    int prevSlashIndex = file.lastIndexOf(File.separator, dataIndex - 1);
    String fileWithParentDir =
        file.substring(0, prevSlashIndex) + file.substring(dataIndex, file.length());
    logger.warn("{} doesn't exist, trying parent directory: {}.",
        IOUtils.getFileName(file), fileWithParentDir);
    file = fileWithParentDir;
  }
  return file;
}

代码示例来源:origin: CogComp/cogcomp-nlp

String file = IOUtils.getFileName(url.getPath());

代码示例来源:origin: CogComp/cogcomp-nlp

public List<TextAnnotation> readData() {
  String corpusId = IOUtils.getFileName(file);
  List<String> lines;
  try {

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

String file = IOUtils.getFileName(url.getPath());

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-quantifier

public List<TextAnnotation> readData() {
  String corpusId = IOUtils.getFileName(file);
  List<String> lines;
  try {

代码示例来源:origin: edu.illinois.cs.cogcomp/saul-examples

throw new RuntimeException("Couldn't read " + dataFile);
String corpusId = IOUtils.getFileName(dataFile);
List<String> labels = new ArrayList<>();
List<String> tokens = new ArrayList<>();

代码示例来源:origin: edu.illinois.cs.cogcomp/esrl-core

(files.length + failed.size()), failed.size());
for (String file : files) {
  String taHashStr = IOUtils.stripFileExtension(IOUtils.getFileName(file));

代码示例来源:origin: CogComp/cogcomp-nlp

gaz.readDictionary(IOUtils.getFileName(file.getPath()), "", is);
} catch (IOException e) {
  throw new RuntimeException(e);
  gazIC.readDictionary(IOUtils.getFileName(file.getPath()), "(IC)", is);
} catch (IOException e) {
  throw new RuntimeException(e);

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison

gaz.readDictionary(IOUtils.getFileName(file.getPath()), "", is);
} catch (IOException e) {
  throw new RuntimeException(e);
  gazIC.readDictionary(IOUtils.getFileName(file.getPath()), "(IC)", is);
} catch (IOException e) {
  throw new RuntimeException(e);

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-corpusreaders

String filenameonly = IOUtils.getFileName(filename);
List<String[]> tokenizedSentences = Collections.singletonList(text.toString().split(" "));
TextAnnotation ta =

代码示例来源:origin: CogComp/cogcomp-nlp

String filenameonly = IOUtils.getFileName(filename);
List<String[]> tokenizedSentences = Collections.singletonList(text.toString().split(" "));
TextAnnotation ta =

代码示例来源:origin: CogComp/talen

String filenameonly = IOUtils.getFileName(filename);
List<String[]> tokenizedSentences = Collections.singletonList(text.toString().split(" "));
TextAnnotation ta =

相关文章