Search in sources :

Example 66 with RuntimeIOException

use of edu.stanford.nlp.io.RuntimeIOException in project CoreNLP by stanfordnlp.

the class NERFeatureFactory method initGazette.

public void initGazette() {
    try {
        // read in gazettes
        if (flags.gazettes == null) {
            flags.gazettes = new ArrayList<>();
        }
        List<String> gazettes = flags.gazettes;
        for (String gazetteFile : gazettes) {
            BufferedReader r = IOUtils.readerFromString(gazetteFile, flags.inputEncoding);
            readGazette(r);
            r.close();
        }
    } catch (IOException e) {
        throw new RuntimeIOException(e);
    }
}
Also used : RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException) BufferedReader(java.io.BufferedReader) RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException) IOException(java.io.IOException)

Example 67 with RuntimeIOException

use of edu.stanford.nlp.io.RuntimeIOException in project CoreNLP by stanfordnlp.

the class SingletonPredictor method saveToSerialized.

/**
 * Saves the singleton predictor model to the given filename.
 * If there is an error, a RuntimeIOException is thrown.
 */
private static void saveToSerialized(LogisticClassifier<String, String> predictor, String filename) {
    try {
        log.info("Writing singleton predictor in serialized format to file " + filename + ' ');
        ObjectOutputStream out = IOUtils.writeStreamFromString(filename);
        out.writeObject(predictor);
        out.close();
        log.info("done.");
    } catch (IOException ioe) {
        throw new RuntimeIOException(ioe);
    }
}
Also used : RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException) IOException(java.io.IOException) RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException) ObjectOutputStream(java.io.ObjectOutputStream)

Example 68 with RuntimeIOException

use of edu.stanford.nlp.io.RuntimeIOException in project CoreNLP by stanfordnlp.

the class Dictionaries method loadNumberLists.

private void loadNumberLists(String pluralWordsFile, String singularWordsFile) {
    try {
        getWordsFromFile(pluralWordsFile, pluralWords, false);
        getWordsFromFile(singularWordsFile, singularWords, false);
    } catch (IOException e) {
        throw new RuntimeIOException(e);
    }
}
Also used : RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException) IOException(java.io.IOException) RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException)

Example 69 with RuntimeIOException

use of edu.stanford.nlp.io.RuntimeIOException in project CoreNLP by stanfordnlp.

the class Dictionaries method loadGenderNumber.

/**
 * Load Bergsma and Lin (2006) gender and number list.
 * <br>
 * The list is converted from raw text and numbers to a serialized
 * map, which saves quite a bit of time loading.
 * See edu.stanford.nlp.dcoref.util.ConvertGenderFile
 */
private void loadGenderNumber(String file, String neutralWordsFile) {
    try {
        getWordsFromFile(neutralWordsFile, neutralWords, false);
    } catch (IOException e) {
        throw new RuntimeIOException("Couldn't load " + neutralWordsFile);
    }
    try {
        Map<List<String>, Gender> temp = IOUtils.readObjectFromURLOrClasspathOrFileSystem(file);
        genderNumber.putAll(temp);
    } catch (IOException | ClassNotFoundException e) {
        throw new RuntimeIOException("Couldn't load " + file);
    }
}
Also used : RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException)

Example 70 with RuntimeIOException

use of edu.stanford.nlp.io.RuntimeIOException in project CoreNLP by stanfordnlp.

the class Dictionaries method loadAnimacyLists.

private void loadAnimacyLists(String animateWordsFile, String inanimateWordsFile) {
    try {
        getWordsFromFile(animateWordsFile, animateWords, false);
        getWordsFromFile(inanimateWordsFile, inanimateWords, false);
    } catch (IOException e) {
        throw new RuntimeIOException(e);
    }
}
Also used : RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException) IOException(java.io.IOException) RuntimeIOException(edu.stanford.nlp.io.RuntimeIOException)

Aggregations

RuntimeIOException (edu.stanford.nlp.io.RuntimeIOException)114 IOException (java.io.IOException)61 BufferedReader (java.io.BufferedReader)22 CoreAnnotations (edu.stanford.nlp.ling.CoreAnnotations)12 CoreLabel (edu.stanford.nlp.ling.CoreLabel)11 File (java.io.File)9 ArrayList (java.util.ArrayList)7 Tree (edu.stanford.nlp.trees.Tree)6 CoreMap (edu.stanford.nlp.util.CoreMap)5 BufferedWriter (java.io.BufferedWriter)5 Properties (java.util.Properties)5 Timing (edu.stanford.nlp.util.Timing)4 FileNotFoundException (java.io.FileNotFoundException)4 FileOutputStream (java.io.FileOutputStream)4 ObjectOutputStream (java.io.ObjectOutputStream)4 PrintWriter (java.io.PrintWriter)4 CorefCoreAnnotations (edu.stanford.nlp.coref.CorefCoreAnnotations)3 Annotation (edu.stanford.nlp.pipeline.Annotation)3 SemanticGraphCoreAnnotations (edu.stanford.nlp.semgraph.SemanticGraphCoreAnnotations)3 ClassicCounter (edu.stanford.nlp.stats.ClassicCounter)3