@Test public void testNormalizerCharFilter() throws Exception { String query = "한국어를 처리하는 예시입니닼ㅋ. 오픈코리안텍스틓ㅎㅎㅎㅎㅎㅎㅎ"; String expected = "한국어를 처리하는 예시입니다ㅋ. 오픈코리안텍스트ㅎㅎㅎ"; CharFilter inputReader = new OpenKoreanTextNormalizer(new StringReader(query)); char[] tempBuff = new char[10]; StringBuilder actual = new StringBuilder(); while (true) { int length = inputReader.read(tempBuff); if (length == -1) break; actual.append(tempBuff, 0, length); } Assert.assertEquals(expected, actual.toString()); }
@Override public int read(char[] cbuf, int off, int len) throws IOException { if (off < 0) throw new IllegalArgumentException("off < 0"); if (off >= cbuf.length) throw new IllegalArgumentException("off >= cbuf.length"); if (len <= 0) throw new IllegalArgumentException("len <= 0"); if (!this.preparedToRead) { prepareToRead(); } int copyLen = this.inputText.length - cursor; if(copyLen < 1){ initAttributes(); return -1; } copyLen = copyLen > len ? len : copyLen; System.arraycopy(inputText, cursor, cbuf, off, copyLen); cursor += copyLen; return copyLen; }
OpenKoreanTextNormalizer extends BaseCharFilter { @Override public int read(char[] cbuf, int off, int len) throws IOException { if (off < 0) throw new IllegalArgumentException("off < 0"); if (off >= cbuf.length) throw new IllegalArgumentException("off >= cbuf.length"); if (len <= 0) throw new IllegalArgumentException("len <= 0"); if (!this.preparedToRead) { prepareToRead(); } int copyLen = this.inputText.length - cursor; if(copyLen < 1){ initAttributes(); return -1; } copyLen = copyLen > len ? len : copyLen; System.arraycopy(inputText, cursor, cbuf, off, copyLen); cursor += copyLen; return copyLen; } }
OpenKoreanTextNormalizer extends BaseCharFilter { @Override public int read(char[] cbuf, int off, int len) throws IOException { if (off < 0) throw new IllegalArgumentException("off < 0"); if (off >= cbuf.length) throw new IllegalArgumentException("off >= cbuf.length"); if (len <= 0) throw new IllegalArgumentException("len <= 0"); if (!this.preparedToRead) { prepareToRead(); } int copyLen = this.inputText.length - cursor; if(copyLen < 1){ initAttributes(); return -1; } copyLen = copyLen > len ? len : copyLen; System.arraycopy(inputText, cursor, cbuf, off, copyLen); cursor += copyLen; return copyLen; } OpenKoreanTextNormalizer(Reader in); }
OpenKoreanTextNormalizer extends BaseCharFilter { @Override public int read(char[] cbuf, int off, int len) throws IOException { if (off < 0) throw new IllegalArgumentException("off < 0"); if (off >= cbuf.length) throw new IllegalArgumentException("off >= cbuf.length"); if (len <= 0) throw new IllegalArgumentException("len <= 0"); if (!this.preparedToRead) { prepareToRead(); } int copyLen = this.inputText.length - cursor; if(copyLen < 1){ initAttributes(); return -1; } copyLen = copyLen > len ? len : copyLen; System.arraycopy(inputText, cursor, cbuf, off, copyLen); cursor += copyLen; return copyLen; } OpenKoreanTextNormalizer(Reader in); @Override int read(char[] cbuf, int off, int len); }
OpenKoreanTextNormalizer extends BaseCharFilter { @Override public int read(char[] cbuf, int off, int len) throws IOException { if (off < 0) throw new IllegalArgumentException("off < 0"); if (off >= cbuf.length) throw new IllegalArgumentException("off >= cbuf.length"); if (len <= 0) throw new IllegalArgumentException("len <= 0"); if (!this.preparedToRead) { prepareToRead(); } int copyLen = this.inputText.length - cursor; if(copyLen < 1){ initAttributes(); return -1; } copyLen = copyLen > len ? len : copyLen; System.arraycopy(inputText, cursor, cbuf, off, copyLen); cursor += copyLen; return copyLen; } OpenKoreanTextNormalizer(Reader in); @Override int read(char[] cbuf, int off, int len);  }