All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.nlp.io.RegExFileFilter Maven / Gradle / Ivy

Go to download

Stanford CoreNLP provides a set of natural language analysis tools which can take raw English language text input and give the base forms of words, their parts of speech, whether they are names of companies, people, etc., normalize dates, times, and numeric quantities, mark up the structure of sentences in terms of phrases and word dependencies, and indicate which noun phrases refer to the same entities. It provides the foundational building blocks for higher level text understanding applications.

There is a newer version: 4.5.7
Show newest version
package edu.stanford.nlp.io;

import java.io.*;
import java.util.regex.*;
/**
 * Implements a file filter that filters based on a passed in {@link java.util.regex.Pattern}.
 * Preciesly, it will accept exactly those {@link java.io.File}s for which
 * the matches() method of the Pattern returns true on the output of the getName()
 * method of the File.
 *
 * @author Jenny Finkel
 */
public class RegExFileFilter implements FileFilter {

  private Pattern pattern = null;

  /**
   * Sets up a RegExFileFilter which checks if the file name (not the
   * entire path) matches the passed in {@link java.util.regex.Pattern}.
   */
  public RegExFileFilter(Pattern pattern) {
    this.pattern = pattern;
  }

  /**
   * Checks whether a file satisfies the selection filter.
   *
   * @param file The file
   * @return true if the file is acceptable
   */
  public boolean accept(File file) {
    Matcher m = pattern.matcher(file.getName());
    return m.matches();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy