java.lang.Object
org.miaixz.bus.extra.nlp.provider.mynlp.MynlpWord
- All Implemented Interfaces:
Serializable,NLPWord
Wrapper class for a single word (WordTerm) from Mynlp word segmentation. This class adapts the Mynlp
WordTerm
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
ConstructorsConstructorDescriptionMynlpWord(com.mayabot.nlp.segment.WordTerm word) Constructs aMynlpWordinstance by wrapping a MynlpWordTerm. -
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 MynlpWordTerm.toString()Returns the textual representation of this word, which is the same asgetText().
-
Constructor Details
-
MynlpWord
public MynlpWord(com.mayabot.nlp.segment.WordTerm word) Constructs aMynlpWordinstance by wrapping a MynlpWordTerm.- Parameters:
word- TheWordTermobject from Mynlp word segmentation.
-
-
Method Details
-
getText
Retrieves the text of the word from the wrapped MynlpWordTerm. -
getStartOffset
public int getStartOffset()Retrieves the starting character offset of this word within the original text. This delegates to theoffsetfield of the MynlpWordTerm.- 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().
-