| 1 |
// This file is part of ICU4X. For terms of use, please see the file |
| 2 |
// called LICENSE at the top level of the ICU4X source tree |
| 3 |
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). |
| 4 |
|
| 5 |
//! 🚧 \[Unstable\] Data provider struct definitions for this ICU4X component. |
| 6 |
//! |
| 7 |
//! <div class="stab unstable"> |
| 8 |
//! 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways, |
| 9 |
//! including in SemVer minor releases. While the serde representation of data structs is guaranteed |
| 10 |
//! to be stable, their Rust representation might not be. Use with caution. |
| 11 |
//! </div> |
| 12 |
//! |
| 13 |
//! Read more about data providers: [`icu_provider`] |
| 14 |
|
| 15 |
// Provider structs must be stable |
| 16 |
#![allow(clippy::exhaustive_structs, clippy::exhaustive_enums)] |
| 17 |
|
| 18 |
mod v1; |
| 19 |
pub use v1::*; |
| 20 |
#[cfg(feature = "unstable")] |
| 21 |
#[allow(missing_docs)] |
| 22 |
mod v2; |
| 23 |
#[cfg(feature = "unstable")] |
| 24 |
pub use v2::*; |
| 25 |
mod complex; |
| 26 |
pub use complex::*; |
| 27 |
|
| 28 |
#[cfg(feature = "datagen")] |
| 29 |
use icu_provider::prelude::*; |
| 30 |
|
| 31 |
#[cfg(feature = "compiled_data")] |
| 32 |
#[derive(Debug)] |
| 33 |
/// Baked data |
| 34 |
/// |
| 35 |
/// <div class="stab unstable"> |
| 36 |
/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways, |
| 37 |
/// including in SemVer minor releases. In particular, the `DataProvider` implementations are only |
| 38 |
/// guaranteed to match with this version's `*_unstable` providers. Use with caution. |
| 39 |
/// </div> |
| 40 |
pub struct Baked; |
| 41 |
|
| 42 |
#[cfg(feature = "compiled_data")] |
| 43 |
#[allow(unused_imports, missing_docs)] |
| 44 |
const _: () = { |
| 45 |
use icu_segmenter_data::*; |
| 46 |
pub mod icu { |
| 47 |
pub use crate as segmenter; |
| 48 |
pub use icu_collections as collections; |
| 49 |
} |
| 50 |
make_provider!(Baked); |
| 51 |
impl_segmenter_break_sentence_v1!(Baked); |
| 52 |
impl_segmenter_dictionary_auto_v1!(Baked); |
| 53 |
impl_segmenter_break_grapheme_cluster_v1!(Baked); |
| 54 |
impl_segmenter_dictionary_extended_v1!(Baked); |
| 55 |
impl_segmenter_break_line_v1!(Baked); |
| 56 |
#[cfg(feature = "unstable")] |
| 57 |
impl_segmenter_break_line_v3!(Baked); |
| 58 |
#[cfg(feature = "lstm")] |
| 59 |
impl_segmenter_lstm_auto_v1!(Baked); |
| 60 |
#[cfg(feature = "unstable")] |
| 61 |
impl_segmenter_unihan_radical_v1!(Baked); |
| 62 |
impl_segmenter_break_word_v1!(Baked); |
| 63 |
impl_segmenter_break_word_override_v1!(Baked); |
| 64 |
impl_segmenter_break_sentence_override_v1!(Baked); |
| 65 |
#[cfg(feature = "unstable")] |
| 66 |
impl_segmenter_break_line_v2!(Baked); |
| 67 |
#[cfg(feature = "unstable")] |
| 68 |
impl_segmenter_break_word_v2!(Baked); |
| 69 |
#[cfg(feature = "unstable")] |
| 70 |
impl_segmenter_break_sentence_v2!(Baked); |
| 71 |
#[cfg(feature = "unstable")] |
| 72 |
impl_segmenter_break_grapheme_cluster_v2!(Baked); |
| 73 |
#[cfg(feature = "unstable")] |
| 74 |
impl_segmenter_break_line_override_v2!(Baked); |
| 75 |
#[cfg(feature = "unstable")] |
| 76 |
impl_segmenter_break_sentence_override_v2!(Baked); |
| 77 |
}; |
| 78 |
|
| 79 |
#[cfg(feature = "datagen")] |
| 80 |
/// The latest minimum set of markers required by this component. |
| 81 |
pub const MARKERS: &[DataMarkerInfo] = &[ |
| 82 |
SegmenterBreakGraphemeClusterV1::INFO, |
| 83 |
SegmenterBreakLineV1::INFO, |
| 84 |
#[cfg(feature = "unstable")] |
| 85 |
SegmenterBreakLineV3::INFO, |
| 86 |
SegmenterBreakSentenceOverrideV1::INFO, |
| 87 |
SegmenterBreakSentenceV1::INFO, |
| 88 |
SegmenterBreakWordOverrideV1::INFO, |
| 89 |
SegmenterBreakWordV1::INFO, |
| 90 |
SegmenterDictionaryAutoV1::INFO, |
| 91 |
SegmenterDictionaryExtendedV1::INFO, |
| 92 |
SegmenterLstmAutoV1::INFO, |
| 93 |
#[cfg(feature = "unstable")] |
| 94 |
SegmenterUnihanRadicalV1::INFO, |
| 95 |
#[cfg(feature = "unstable")] |
| 96 |
SegmenterBreakLineV2::INFO, |
| 97 |
#[cfg(feature = "unstable")] |
| 98 |
SegmenterBreakWordV2::INFO, |
| 99 |
#[cfg(feature = "unstable")] |
| 100 |
SegmenterBreakSentenceV2::INFO, |
| 101 |
#[cfg(feature = "unstable")] |
| 102 |
SegmenterBreakGraphemeClusterV2::INFO, |
| 103 |
#[cfg(feature = "unstable")] |
| 104 |
SegmenterBreakLineOverrideV2::INFO, |
| 105 |
#[cfg(feature = "unstable")] |
| 106 |
SegmenterBreakSentenceOverrideV2::INFO, |
| 107 |
]; |
| 108 |
|
| 109 |
/// A complex script that requires special handling in the segmenter. |
| 110 |
#[allow(missing_docs)] // trivial |
| 111 |
#[zerovec::make_ule(ComplexScriptULE)] |
| 112 |
#[derive(PartialEq, Debug, Copy, Clone, Hash)] |
| 113 |
#[cfg_attr(feature = "serde", derive(serde::Deserialize))] |
| 114 |
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))] |
| 115 |
#[cfg_attr(feature = "datagen", databake(path = icu_segmenter::provider))] |
| 116 |
#[repr(u8)] |
| 117 |
pub enum ComplexScript { |
| 118 |
None = 0, |
| 119 |
Myanmar = 1, |
| 120 |
ChineseOrJapanese = 2, |
| 121 |
Khmer = 3, |
| 122 |
Lao = 4, |
| 123 |
Thai = 5, |
| 124 |
} |