Package org.languagetool
Class AnalyzedSentence
- java.lang.Object
-
- org.languagetool.AnalyzedSentence
-
public final class AnalyzedSentence extends Object
A sentence that has been tokenized and analyzed.- Author:
- Daniel Naber
-
-
Constructor Summary
Constructors Constructor Description AnalyzedSentence(AnalyzedTokenReadings[] tokens)
Creates an AnalyzedSentence from the givenAnalyzedTokenReadings
.AnalyzedSentence(AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings[] preDisambigTokens)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnalyzedSentence
copy(AnalyzedSentence sentence)
The method copiesAnalyzedSentence
and returns the copy.boolean
equals(Object o)
String
getAnnotations()
Get disambiguator actions log.Set<String>
getLemmaSet()
Get the lowercase lemmas of this sentence in a set.int
getOriginalPosition(int nonWhPosition)
Get a position of a non-whitespace token in the original sentence with whitespace.AnalyzedTokenReadings[]
getPreDisambigTokens()
AnalyzedTokenReadings[]
getPreDisambigTokensWithoutWhitespace()
String
getText()
Return the original text.AnalyzedTokenReadings[]
getTokens()
Returns theAnalyzedTokenReadings
of the analyzed text.Set<String>
getTokenSet()
Get the lowercase tokens of this sentence in a set.AnalyzedTokenReadings[]
getTokensWithoutWhitespace()
Returns theAnalyzedTokenReadings
of the analyzed text, with whitespace tokens removed but with the artificialSENT_START
token included.int
hashCode()
boolean
hasParagraphEndMark(Language lang)
Returns true if sentences ends with a paragraph break.String
toShortString(String readingDelimiter)
Return string representation without chunk information.String
toString()
String
toString(String readingDelimiter)
Return string representation with chunk information.
-
-
-
Constructor Detail
-
AnalyzedSentence
public AnalyzedSentence(AnalyzedTokenReadings[] tokens)
Creates an AnalyzedSentence from the givenAnalyzedTokenReadings
. Whitespace is also a token.
-
AnalyzedSentence
public AnalyzedSentence(AnalyzedTokenReadings[] tokens, AnalyzedTokenReadings[] preDisambigTokens)
-
-
Method Detail
-
copy
public AnalyzedSentence copy(AnalyzedSentence sentence)
The method copiesAnalyzedSentence
and returns the copy. Useful for performing local immunization (for example).- Parameters:
sentence
-AnalyzedSentence
to be copied- Returns:
- a new object which is a copy
- Since:
- 2.5
-
getTokens
public AnalyzedTokenReadings[] getTokens()
Returns theAnalyzedTokenReadings
of the analyzed text. Whitespace is also a token.
-
getPreDisambigTokens
@Experimental public AnalyzedTokenReadings[] getPreDisambigTokens()
- Since:
- 4.5
-
getTokensWithoutWhitespace
public AnalyzedTokenReadings[] getTokensWithoutWhitespace()
Returns theAnalyzedTokenReadings
of the analyzed text, with whitespace tokens removed but with the artificialSENT_START
token included.
-
getPreDisambigTokensWithoutWhitespace
@Experimental public AnalyzedTokenReadings[] getPreDisambigTokensWithoutWhitespace()
- Since:
- 4.5
-
getOriginalPosition
public int getOriginalPosition(int nonWhPosition)
Get a position of a non-whitespace token in the original sentence with whitespace.- Parameters:
nonWhPosition
- position of a non-whitespace token- Returns:
- position in the original sentence.
-
toShortString
public String toShortString(String readingDelimiter)
Return string representation without chunk information.- Since:
- 2.3
-
getText
public String getText()
Return the original text.- Since:
- 2.7
-
toString
public String toString(String readingDelimiter)
Return string representation with chunk information.
-
getAnnotations
public String getAnnotations()
Get disambiguator actions log.
-
getTokenSet
public Set<String> getTokenSet()
Get the lowercase tokens of this sentence in a set. Used internally for performance optimization.- Since:
- 2.4
-
getLemmaSet
public Set<String> getLemmaSet()
Get the lowercase lemmas of this sentence in a set. Used internally for performance optimization.- Since:
- 2.5
-
hasParagraphEndMark
public boolean hasParagraphEndMark(Language lang)
Returns true if sentences ends with a paragraph break.- Since:
- 4.3
-
-