java.lang.Object
org.miaixz.bus.extra.nlp.provider.hanlp.HanLPWord
- All Implemented Interfaces:
Serializable,NLPWord
Wrapper class for a single word (Term) from HanLP word segmentation. This class adapts the HanLP
Term object
to the common NLPWord interface, providing a unified way to access segmented word information.- Since:
- Java 17+
- Author:
- Kimi Liu
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHanLPWord(com.hankcs.hanlp.seg.common.Term term) Constructs aHanLPWordinstance by wrapping a HanLPTerm. -
Method Summary
Modifier and TypeMethodDescriptionintRetrieves the ending character offset of this word within the original text.intRetrieves the starting character offset of this word within the original text.getText()Retrieves the text of the word from the wrapped HanLPTerm.toString()Returns the textual representation of this word, which is the same asgetText().
-
Constructor Details
-
HanLPWord
public HanLPWord(com.hankcs.hanlp.seg.common.Term term) Constructs aHanLPWordinstance by wrapping a HanLPTerm.- Parameters:
term- TheTermobject from HanLP word segmentation.
-
-
Method Details
-
getText
Retrieves the text of the word from the wrapped HanLPTerm. -
getStartOffset
public int getStartOffset()Retrieves the starting character offset of this word within the original text. This delegates to theoffsetfield of the HanLPTerm.- Specified by:
getStartOffsetin interfaceNLPWord- Returns:
- The starting position (inclusive) of the word.
-
getEndOffset
public int getEndOffset()Retrieves the ending character offset of this word within the original text. This is calculated based on the starting offset and the length of the word.- Specified by:
getEndOffsetin interfaceNLPWord- Returns:
- The ending position (exclusive) of the word.
-
toString
Returns the textual representation of this word, which is the same asgetText().
-