@Beta public class TextObject extends Object implements CharSequence, Appendable
LanguageProfile
s,
as well as to pass it in to LanguageDetector.detect(java.lang.CharSequence)
.
To get one, use a TextObjectFactory (through a TextObjectFactoryBuilder).
Example use:
//create the factory once:
TextObjectFactory textObjectFactory = new TextObjectFactoryBuilder()
.withTextFilter(UrlTextFilter.getInstance())
.build();
//then create as many text objects as you like:
TextObject inputText = textObjectFactory.create().append("deutsche Text").append(" ").append("blah blah");
All append() methods go through the textFilter
.
Equals/hashCode are not implemented as of now on purpose. You may want to call toString() and compare that.Constructor and Description |
---|
TextObject(@NotNull TextFilter textFilter,
int maxTextLength) |
Modifier and Type | Method and Description |
---|---|
Appendable |
append(char c) |
TextObject |
append(CharSequence text)
Append the target text for language detection.
|
Appendable |
append(CharSequence csq,
int start,
int end) |
TextObject |
append(Reader reader)
Append the target text for language detection.
|
char |
charAt(int index) |
int |
length() |
CharSequence |
subSequence(int start,
int end) |
@NotNull String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
chars, codePoints
public TextObject(@NotNull @NotNull TextFilter textFilter, int maxTextLength)
maxTextLength
- 0 for no limitpublic TextObject append(Reader reader) throws IOException
reader
- the input reader (BufferedReader as usual)IOException
- Can't read the reader.public TextObject append(CharSequence text)
append
in interface Appendable
text
- the target text to appendpublic Appendable append(CharSequence csq, int start, int end) throws IOException
append
in interface Appendable
IOException
public Appendable append(char c) throws IOException
append
in interface Appendable
IOException
public int length()
length
in interface CharSequence
public char charAt(int index)
charAt
in interface CharSequence
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
@NotNull public @NotNull String toString()
toString
in interface CharSequence
toString
in class Object
Copyright © 2016. All rights reserved.