Stay organized with collections
Save and categorize content based on your preferences.
WordSegmentFinder
open class WordSegmentFinder : SegmentFinder
Implementation of SegmentFinder
using words as the text segment. Word boundaries are found using WordIterator
. Whitespace characters are excluded, so they are not included in any text segments.
For example, the text "Hello, World!" would be subdivided into four text segments: "Hello", ",", "World", "!". The space character does not belong to any text segments.
Summary
Inherited constants |
From class SegmentFinder
Int |
DONE
Return value of previousStartBoundary(int), previousEndBoundary(int), nextStartBoundary(int), and nextEndBoundary(int) when there are no boundaries of the specified type in the specified direction.
|
|
Public constructors |
Constructs a WordSegmentFinder instance for the specified text which uses the provided locale to determine word boundaries.
|
Public methods |
open Int |
Returns the character offset of the next text segment end boundary after the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the next text segment start boundary after the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the previous text segment end boundary before the specified character offset, or DONE if there are none.
|
open Int |
Returns the character offset of the previous text segment start boundary before the specified character offset, or DONE if there are none.
|
Public constructors
WordSegmentFinder
WordSegmentFinder(
text: CharSequence,
locale: ULocale)
Constructs a WordSegmentFinder instance for the specified text which uses the provided locale to determine word boundaries.
Parameters |
text |
CharSequence: text to be segmented This value cannot be null . |
locale |
ULocale: locale used for analyzing the text This value cannot be null . |
Public methods
nextEndBoundary
open fun nextEndBoundary(offset: Int): Int
Returns the character offset of the next text segment end boundary after the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
nextStartBoundary
open fun nextStartBoundary(offset: Int): Int
Returns the character offset of the next text segment start boundary after the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
previousEndBoundary
open fun previousEndBoundary(offset: Int): Int
Returns the character offset of the previous text segment end boundary before the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
previousStartBoundary
open fun previousStartBoundary(offset: Int): Int
Returns the character offset of the previous text segment start boundary before the specified character offset, or DONE
if there are none.
Parameters |
offset |
Int: Value is 0 or greater |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# WordSegmentFinder\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nWordSegmentFinder\n=================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/text/WordSegmentFinder \"View this page in Java\") \n\n```\nopen class WordSegmentFinder : SegmentFinder\n```\n\n|---|---|-------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [android.text.SegmentFinder](/reference/kotlin/android/text/SegmentFinder) ||\n| | ↳ | [android.text.WordSegmentFinder](#) |\n\nImplementation of [SegmentFinder](/reference/kotlin/android/text/SegmentFinder) using words as the text segment. Word boundaries are found using `WordIterator`. Whitespace characters are excluded, so they are not included in any text segments.\n\nFor example, the text \"Hello, World!\" would be subdivided into four text segments: \"Hello\", \",\", \"World\", \"!\". The space character does not belong to any text segments.\n\nSummary\n-------\n\n| Inherited constants ||\n|---|---|\n| From class [SegmentFinder](/reference/kotlin/android/text/SegmentFinder) |----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [DONE](/reference/kotlin/android/text/SegmentFinder#DONE:kotlin.Int) Return value of previousStartBoundary(int), previousEndBoundary(int), nextStartBoundary(int), and nextEndBoundary(int) when there are no boundaries of the specified type in the specified direction. \u003cbr /\u003e | ||\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [WordSegmentFinder](#WordSegmentFinder(kotlin.CharSequence,%20android.icu.util.ULocale))`(`text:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`, `locale:` `[ULocale](../icu/util/ULocale.html#)`)` Constructs a WordSegmentFinder instance for the specified text which uses the provided locale to determine word boundaries. |\n\n| Public methods ||\n|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [nextEndBoundary](#nextEndBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the next text segment end boundary after the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [nextStartBoundary](#nextStartBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the next text segment start boundary after the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [previousEndBoundary](#previousEndBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the previous text segment end boundary before the specified character offset, or `DONE` if there are none. |\n| open [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [previousStartBoundary](#previousStartBoundary(kotlin.Int))`(`offset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the character offset of the previous text segment start boundary before the specified character offset, or `DONE` if there are none. |\n\nPublic constructors\n-------------------\n\n### WordSegmentFinder\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nWordSegmentFinder(\n text: CharSequence, \n locale: ULocale)\n```\n\nConstructs a WordSegmentFinder instance for the specified text which uses the provided locale to determine word boundaries.\n\n| Parameters ||\n|----------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| `text` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html): text to be segmented This value cannot be `null`. |\n| `locale` | [ULocale](../icu/util/ULocale.html#): locale used for analyzing the text This value cannot be `null`. |\n\nPublic methods\n--------------\n\n### nextEndBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun nextEndBoundary(offset: Int): Int\n```\n\nReturns the character offset of the next text segment end boundary after the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### nextStartBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun nextStartBoundary(offset: Int): Int\n```\n\nReturns the character offset of the next text segment start boundary after the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### previousEndBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun previousEndBoundary(offset: Int): Int\n```\n\nReturns the character offset of the previous text segment end boundary before the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |\n\n### previousStartBoundary\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun previousStartBoundary(offset: Int): Int\n```\n\nReturns the character offset of the previous text segment start boundary before the specified character offset, or `DONE` if there are none.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `offset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is 0 or greater |"]]