|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.ling.Sentence
public class Sentence
Sentence holds a couple utility methods for lists. Those include a method that nicely prints a list and methods that construct lists of words from lists of strings.
Method Summary | ||
---|---|---|
static
|
extractNgram(List<T> list,
int start,
int end)
Returns the substring of the sentence from start (inclusive) to end (exclusive). |
|
static
|
listToString(List<T> list)
Returns the sentence as a string with a space between words. |
|
static
|
listToString(List<T> list,
boolean justValue)
Returns the sentence as a string with a space between words. |
|
static
|
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(String... words)
|
|
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(List<String> lex)
|
|
static List<HasWord> |
toWordList(String... words)
|
|
static
|
wordToString(T o,
boolean justValue)
|
|
static
|
wordToString(T o,
boolean justValue,
String separator)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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 tags
public 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 words
public static List<HasWord> toWordList(List<String> lex)
public static ArrayList<Word> toUntaggedList(String... words)
Word
objects from
an array of String objects.
words
- The words to make it from
public static List<HasWord> toWordList(String... words)
public static List<CoreLabel> toCoreLabelList(String... words)
public 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)
public static <T> String wordToString(T o, boolean justValue, String separator)
public static <T> String extractNgram(List<T> list, int start, int end)
start
- Leftmost index of the substringend
- Rightmost index of the ngram
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |