private static String getPOS(final AnalyzedTokenReadings atr) { final StringBuilder sb = new StringBuilder(); final int readNum = atr.getReadingsLength(); for (int i = 0; i < readNum; i++) { if (!atr.isWhitespace()) { sb.append(atr.getAnalyzedToken(i).getPOSTag()); if (i != readNum - 1) { sb.append('+'); } } } return sb.toString(); }
private static void runOnStdIn(final JLanguageTool lt) throws IOException { final int MAX_FILE_SIZE = 64_000; InputStreamReader isr = null; BufferedReader br = null; StringBuilder sb = new StringBuilder(); try { isr = new InputStreamReader(new BufferedInputStream(System.in)); br = new BufferedReader(isr); String line; while ((line = br.readLine()) != null) { sb.append(line); sb.append('\n'); if (lt.getLanguage().getSentenceTokenizer().singleLineBreaksMarksPara()) { tagText(sb.toString(), lt); sb = new StringBuilder(); } else { if ("".equals(line) || sb.length() >= MAX_FILE_SIZE) { tagText(sb.toString(), lt); sb = new StringBuilder(); } } } } finally { if (sb.length() > 0) { tagText(sb.toString(), lt); } } br.close(); isr.close(); }
private static String getSentence(final AnalyzedSentence sent) { final StringBuilder sb = new StringBuilder(); sb.append("<S>"); for (final AnalyzedTokenReadings atr : sent.getTokensWithoutWhitespace()) { sb.append(getPOS(atr)); sb.append(' '); } sb.append("</S>"); return sb.toString(); }