IcuDictionaryBreakEngine Class
A dictionary break engine of ICU: it finds the words of a run of characters of a script that is written without spaces between words, with a word list of ICU (IcuWordDictionary).
public abstract class IcuDictionaryBreakEngineRemarks
The engines are ports of the ones of ICU (icu4c/source/common/dictbe.cpp), which the word break iterator and the line break iterator of ICU use, and so the browsers and Intl.Segmenter of JavaScript:
IcuDictionaryBreakEngine.ChineseJapanese(CjkBreakEngine, without the phrase breaking): the segmentation of the run whose words have the smallest total cost. The run is normalized to NFKC; a character that does not start a word of one character is a word of the highest cost, and a run of katakana is a candidate word with a cost that depends on its length.IcuDictionaryBreakEngine.Thai,IcuDictionaryBreakEngine.Lao,IcuDictionaryBreakEngine.KhmerandIcuDictionaryBreakEngine.Burmese(ThaiBreakEngine,LaoBreakEngine,KhmerBreakEngineandBurmeseBreakEngine): the longest words of the list that are followed by other words of the list, with up to three words of lookahead. The characters that start no word are attached to the word before them, up to a plausible word start; a break is never before a combining mark, and Thai attaches the elision and repetition characters to the word before them.
The engines do not find the runs: a caller applies the rules of its segmentation (the word or line breaking rules of Unicode, of ICU, or of CSS) and gives each run of the characters an engine handles (IcuDictionaryBreakEngine.Handles) to that engine. The text is read by code point, an unpaired surrogate being a code point, as ICU reads it. The engines are stateless and can be used by several threads at the same time; the word list of an engine is loaded on its first use.
Properties
| Name | Description |
|---|---|
| Burmese | Gets the engine of Burmese: the characters of the Myanmar script whose line breaking class is Complex_Context (SA). |
| ChineseJapanese | Gets the engine of Chinese and Japanese: the characters of the Han, Hiragana and Katakana scripts, and U+30FC, U+FF70, U+FF9E and U+FF9F. |
| DictionaryKind | Gets the word list the engine uses. |
| Khmer | Gets the engine of Khmer: the characters of the Khmer script whose line breaking class is Complex_Context (SA). |
| Lao | Gets the engine of Lao: the characters of the Lao script whose line breaking class is Complex_Context (SA). |
| Thai | Gets the engine of Thai: the characters of the Thai script whose line breaking class is Complex_Context (SA). |
Burmese
IcuDictionaryBreakEngine.csGets the engine of Burmese: the characters of the Myanmar script whose line breaking class is Complex_Context (SA).
public static IcuDictionaryBreakEngine Burmese { get; }Property value
ChineseJapanese
IcuDictionaryBreakEngine.csGets the engine of Chinese and Japanese: the characters of the Han, Hiragana and Katakana scripts, and U+30FC, U+FF70, U+FF9E and U+FF9F.
public static IcuDictionaryBreakEngine ChineseJapanese { get; }Property value
DictionaryKind
IcuDictionaryBreakEngine.csGets the word list the engine uses.
public IcuWordDictionaryKind DictionaryKind { get; }Property value
Gets the engine of Khmer: the characters of the Khmer script whose line breaking class is Complex_Context (SA).
public static IcuDictionaryBreakEngine Khmer { get; }Property value
Gets the engine of Lao: the characters of the Lao script whose line breaking class is Complex_Context (SA).
public static IcuDictionaryBreakEngine Lao { get; }Property value
Gets the engine of Thai: the characters of the Thai script whose line breaking class is Complex_Context (SA).
public static IcuDictionaryBreakEngine Thai { get; }Property value
Methods
| Name | Description |
|---|---|
| FindBreaks(ReadOnlySpan<char>, Span<int>) | Finds the boundaries between the words of a run of characters the engine handles. |
| GetEngine(int) | Gets the engine that handles a code point. |
| Handles(int) | Determines whether the engine handles a code point (the set of characters of the engine in ICU). |
FindBreaks(ReadOnlySpan<char>, Span<int>)
IcuDictionaryBreakEngine.csFinds the boundaries between the words of a run of characters the engine handles.
public int FindBreaks(ReadOnlySpan<char> text, Span<int> breakPositions)Parameters
textReadOnlySpan<char>- The run: characters the engine handles (
IcuDictionaryBreakEngine.Handles). It is segmented as a whole: the result for a text that has other characters is not specified. breakPositionsSpan<int>- The buffer that receives the positions, in increasing order. A position is the index of the UTF-16 code unit of
textwhere a word starts, other than the start of the text. As many elements as the length of the text are always enough.
Returns
int The number of positions written; 0 when the run is one word (or too short to have two words).
Exceptions
ArgumentExceptionbreakPositionsis too small.
Remarks
The start and the end of the run are boundaries, and are never written. The engines of ICU are given the whole text and the range of the run; the engines of this package are given the run.
GetEngine(int)
IcuDictionaryBreakEngine.csGets the engine that handles a code point.
public static IcuDictionaryBreakEngine? GetEngine(int codePoint)Parameters
codePointint- The code point.
Returns
IcuDictionaryBreakEngine? The engine whose IcuDictionaryBreakEngine.Handles method returns true for the code point, or null when no engine handles it (the sets of characters of the engines do not overlap).
Handles(int)
Determines whether the engine handles a code point (the set of characters of the engine in ICU).