List of usage examples for opennlp.tools.postag POSDictionary create
public static POSDictionary create(InputStream in) throws IOException
From source file:es.ehu.si.ixa.pipe.convert.Convert.java
/** * Aggregates a lemma dictionary (word lemma postag) into a * {@code POSTaggerDictionary}. It saves the resulting file with the name of * the original lemma dictionary changing the extension to .xml. * // w w w .ja v a 2 s . c o m * @param lemmaDict * the input file * @throws IOException * if io problems */ public void addLemmaToPOSDict(File lemmaDict, File posTaggerDict) throws IOException { // process one file if (lemmaDict.isFile() && posTaggerDict.isFile()) { InputStream posDictInputStream = new FileInputStream(posTaggerDict); POSDictionary posDict = POSDictionary.create(posDictInputStream); List<String> inputLines = Files.readLines(lemmaDict, Charsets.UTF_8); File outFile = new File(Files.getNameWithoutExtension(lemmaDict.getCanonicalPath()) + ".xml"); addPOSTaggerDict(inputLines, posDict); OutputStream outputStream = new FileOutputStream(outFile); posDict.serialize(outputStream); outputStream.close(); System.err.println(">> Serialized Apache OpenNLP POSDictionary format to " + outFile); } else { System.out.println("Please choose a valid files as input."); System.exit(1); } }