/** Uses a DiskTreebank with a CHTBTokenizer and a BobChrisTreeNormalizer. */ @Override public DiskTreebank diskTreebank() { String encoding = inputEncoding; if (!java.nio.charset.Charset.isSupported(encoding)) { printlnErr("Warning: desired encoding " + encoding + " not accepted. "); printlnErr("Using UTF-8 to construct DiskTreebank"); encoding = "UTF-8"; } return new DiskTreebank(treeReaderFactory(), encoding); }
/** Uses a MemoryTreebank with a CHTBTokenizer and a BobChrisTreeNormalizer */ @Override public MemoryTreebank memoryTreebank() { String encoding = inputEncoding; if (!java.nio.charset.Charset.isSupported(encoding)) { System.out.println("Warning: desired encoding " + encoding + " not accepted. "); System.out.println("Using UTF-8 to construct MemoryTreebank"); encoding = "UTF-8"; } return new MemoryTreebank(treeReaderFactory(), encoding); }
/** * The PrintWriter used to print output. It's the responsibility of pw to deal properly with * character encodings for the relevant treebank. */ public PrintWriter pw(OutputStream o) { String encoding = outputEncoding; if (!java.nio.charset.Charset.isSupported(encoding)) { System.out.println("Warning: desired encoding " + encoding + " not accepted. "); System.out.println("Using UTF-8 to construct PrintWriter"); encoding = "UTF-8"; } try { return new PrintWriter(new OutputStreamWriter(o, encoding), true); } catch (UnsupportedEncodingException e) { System.out.println("Warning: desired encoding " + outputEncoding + " not accepted. " + e); try { return new PrintWriter(new OutputStreamWriter(o, "UTF-8"), true); } catch (UnsupportedEncodingException e1) { System.out.println( "Something is really wrong. Your system doesn't even support UTF-8!" + e1); return new PrintWriter(o, true); } } }