Module bus.extra

Class WordWord

java.lang.Object
org.miaixz.bus.extra.nlp.provider.word.WordWord
All Implemented Interfaces:
Serializable, NLPWord

public class WordWord extends Object implements NLPWord
Wrapper class for a single word from the Word word segmentation library. This class adapts the Word 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

    Constructors
    Constructor
    Description
    WordWord(org.apdplat.word.segmentation.Word word)
    Constructs a WordWord instance by wrapping a Word library's Word object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Retrieves the ending character offset of this word within the original text.
    int
    Retrieves the starting character offset of this word within the original text.
    Retrieves the text of the word from the wrapped Word library's Word.
    Returns the textual representation of this word, which is the same as getText().

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • WordWord

      public WordWord(org.apdplat.word.segmentation.Word word)
      Constructs a WordWord instance by wrapping a Word library's Word object.
      Parameters:
      word - The Word object from Word word segmentation.
  • Method Details

    • getText

      public String getText()
      Retrieves the text of the word from the wrapped Word library's Word.
      Specified by:
      getText in interface NLPWord
      Returns:
      The text of the word as a String.
    • getStartOffset

      public int getStartOffset()
      Retrieves the starting character offset of this word within the original text. Note: The Word library's Word does not directly provide offset information, so this method returns -1.
      Specified by:
      getStartOffset in interface NLPWord
      Returns:
      The starting position (inclusive) of the word, or -1 if not available.
    • getEndOffset

      public int getEndOffset()
      Retrieves the ending character offset of this word within the original text. Note: The Word library's Word does not directly provide offset information, so this method returns -1.
      Specified by:
      getEndOffset in interface NLPWord
      Returns:
      The ending position (exclusive) of the word, or -1 if not available.
    • toString

      public String toString()
      Returns the textual representation of this word, which is the same as getText().
      Overrides:
      toString in class Object
      Returns:
      The text of the word.