public N[] toNodeArray(List<Token> tokens) { return toNodeArray(tokens, t -> create(t)); }
public void decode(InputStream in, OutputStream out, String format) { try { switch (format) { case FORMAT_RAW : decodeRaw (in, out); break; case FORMAT_LINE: decodeLine(in, out); break; case FORMAT_TSV : decodeTSV (createTSVReader(), in, out); break; } } catch (Exception e) {e.printStackTrace();} }
public N[] decode(String sentence) { List<Token> tokens = tokenizer.tokenize(sentence); return decode(toNodeArray(tokens)); }
public void decodeRaw(InputStream in, OutputStream out) throws IOException { PrintStream fout = IOUtils.createBufferedPrintStream(out); N[] nodes; for (List<Token> tokens : tokenizer.segmentize(in)) { nodes = toNodeArray(tokens); decode(nodes); fout.println(toString(nodes)+"\n"); } in.close(); fout.close(); }
public void decodeLine(InputStream in, OutputStream out) throws IOException { BufferedReader reader = IOUtils.createBufferedReader(in); PrintStream fout = IOUtils.createBufferedPrintStream(out); N[] nodes; String line; while ((line = reader.readLine()) != null) { nodes = decode(line); fout.println(toString(nodes)+"\n"); } reader.close(); fout.close(); }
setTokenizer(edu.emory.mathcs.nlp.common.util.NLPUtils.createTokenizer(language)); setComponents(components);
@Override protected N create() {return AbstractNLPDecoder.this.create();} };
public AbstractNLPDecoder(DecodeConfig config) { init(config); }
public String decode(String s, String format) { return new String(decodeByteArray(s, format), StandardCharsets.UTF_8); }
public byte[] decodeByteArray(String s, String format) { InputStream bin = new ByteArrayInputStream(s.getBytes()); ByteArrayOutputStream bout = new ByteArrayOutputStream(); decode(bin, bout, format); try { bin .close(); bout.close(); } catch (IOException e) {e.printStackTrace();} return bout.toByteArray(); }
public List<N[]> decodeDocument(String s) throws IOException { return decodeDocument(new ByteArrayInputStream(s.getBytes())); }
public void decodeRaw(String s, OutputStream out) throws IOException { decodeRaw(new ByteArrayInputStream(s.getBytes()), out); }
public void decodeRaw(InputStream in, OutputStream out) throws IOException { PrintStream fout = IOUtils.createBufferedPrintStream(out); N[] nodes; for (List<Token> tokens : tokenizer.segmentize(in)) { nodes = toNodeArray(tokens); decode(nodes); fout.println(toString(nodes)+"\n"); } in.close(); fout.close(); }
public void decodeLine(InputStream in, OutputStream out) throws IOException { BufferedReader reader = IOUtils.createBufferedReader(in); PrintStream fout = IOUtils.createBufferedPrintStream(out); N[] nodes; String line; while ((line = reader.readLine()) != null) { nodes = decode(line); fout.println(toString(nodes)+"\n"); } reader.close(); fout.close(); }
setTokenizer(NLPUtils.createTokenizer(language)); setComponents(components); BinUtils.LOG.info("\n");
@Override protected N create() {return AbstractNLPDecoder.this.create();} };
public AbstractNLPDecoder(DecodeConfig config) { init(config); }
public String decode(String s, String format) { return new String(decodeByteArray(s, format)); }
public byte[] decodeByteArray(String s, String format) { InputStream bin = new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8)); ByteArrayOutputStream bout = new ByteArrayOutputStream(); decode(bin, bout, format); try { bin .close(); bout.close(); } catch (IOException e) {e.printStackTrace();} return bout.toByteArray(); }
public List<N[]> decodeDocument(String s) throws IOException { return decodeDocument(new ByteArrayInputStream(s.getBytes())); }