public class Sentence extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> String |
extractNgram(List<T> list,
int start,
int end)
Returns the substring of the sentence from start (inclusive)
to end (exclusive).
|
static <T> String |
listToString(List<T> list)
Returns the sentence as a string with a space between words.
|
static <T> String |
listToString(List<T> list,
boolean justValue)
Returns the sentence as a string with a space between words.
|
static <T> String |
listToString(List<T> list,
boolean justValue,
String separator)
As already described, but if separator is not null, then objects
such as TaggedWord
|
static List<CoreLabel> |
toCoreLabelList(List<? extends HasWord> words)
Create a sentence as a List of
CoreLabel objects from
a List of other label objects. |
static List<CoreLabel> |
toCoreLabelList(String... words)
Create a sentence as a List of
CoreLabel objects from
an array (or varargs) of String objects. |
static ArrayList<TaggedWord> |
toTaggedList(List<String> lex,
List<String> tags)
Create an ArrayList as a list of
TaggedWord from two
lists of String, one for the words, and the second for
the tags. |
static ArrayList<Word> |
toUntaggedList(List<String> lex)
Create an ArrayList as a list of
Word from a
list of String. |
static ArrayList<Word> |
toUntaggedList(String... words)
Create a Sentence as a list of
Word objects from
an array of String objects. |
static List<HasWord> |
toWordList(String... words) |
static <T> String |
wordToString(T o,
boolean justValue) |
static <T> String |
wordToString(T o,
boolean justValue,
String separator) |
public static ArrayList<TaggedWord> toTaggedList(List<String> lex, List<String> tags)
TaggedWord from two
lists of String, one for the words, and the second for
the tags.lex - a list whose items are of type String and
are the wordstags - a list whose items are of type String and
are the tagspublic static ArrayList<Word> toUntaggedList(List<String> lex)
Word from a
list of String.lex - a list whose items are of type String and
are the wordspublic static ArrayList<Word> toUntaggedList(String... words)
Word objects from
an array of String objects.words - The words to make it frompublic static List<CoreLabel> toCoreLabelList(String... words)
CoreLabel objects from
an array (or varargs) of String objects.words - The words to make it frompublic static List<CoreLabel> toCoreLabelList(List<? extends HasWord> words)
CoreLabel objects from
a List of other label objects.words - The words to make it frompublic static <T> String listToString(List<T> list)
value() of each item -
this will give the expected answer for a shortform representation
of the "sentence" over a range of cases. It is equivalent to
calling toString(true)
TODO: Sentence used to be a subclass of ArrayList, with this
method as the toString. Therefore, there may be instances of
ArrayList being printed that expect this method to be used.public static <T> String listToString(List<T> list, boolean justValue)
justValue - If true and the elements are of type
Label, return just the
value() of the Label of each word;
otherwise,
call the toString() method on each item.public static <T> String listToString(List<T> list, boolean justValue, String separator)
separator - The string used to separate Word and Tag
in TaggedWord, etcpublic static <T> String wordToString(T o, boolean justValue)