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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations