#[non_exhaustive]pub enum TextError {
Show 23 variants
BatchTooLarge {
len: usize,
max: usize,
},
InputTooLong {
index: usize,
len: usize,
max: usize,
},
CorpusTooLarge {
total_bytes: usize,
max: usize,
},
VocabularyTooLarge {
len: usize,
max: usize,
},
VocabularyTokenTooLong {
index: usize,
len: usize,
max: usize,
},
EmptyVocabularyToken {
index: usize,
},
ReservedVocabularyToken {
index: usize,
},
DuplicateVocabularyToken {
first: usize,
second: usize,
},
InvalidMaxTokens {
max_tokens: usize,
},
InvalidNgrams {
n: usize,
max: usize,
},
OutputSequenceLengthTooLarge {
len: usize,
max: usize,
},
TooManyDistinctTokens {
max: usize,
},
OutputTooLarge {
elements: usize,
max: usize,
},
LimitAboveAbsoluteMaximum {
limit: &'static str,
value: usize,
max: usize,
},
NgramCountOverflow {
tokens: usize,
n: usize,
},
FrequencyOverflow,
MissingIdfWeights,
IdfWeightsLengthMismatch {
len: usize,
expected: usize,
},
InvalidIdfWeight {
index: usize,
},
PadToMaxTokensWithoutMaxTokens,
TokenCountNotExact {
index: usize,
count: usize,
max: usize,
},
IdOutOfRange {
index: usize,
},
Shape(ShapeError),
}Expand description
テキスト変換の失敗を表す型付きエラー。#[non_exhaustive]: 後続段の variant
追加を非破壊にするため。
どの variant も入力文字列・語彙の中身を持たない(位置・長さ・件数・上限値だけ)。
Display/Debug からも文字列は漏れない。
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BatchTooLarge
バッチ要素数(transform)またはコーパス件数(adapt)が上限超過。
InputTooLong
index 番目の入力文字列のバイト数が上限超過。Standardize::UnicodeLower では
len は標準化後のバイト数(標準化で伸びた結果が上限を超えた場合)。
CorpusTooLarge
adapt のコーパス総バイト数が上限超過(加算 overflow 時は
total_bytes = usize::MAX)。
VocabularyTooLarge
語彙数(予約 2 件を含む)が上限超過。
VocabularyTokenTooLong
index 番目の語彙のバイト数が上限超過。
EmptyVocabularyToken
index 番目の語彙が空文字列。
ReservedVocabularyToken
index 番目の語彙が予約語(""・"[UNK]")。
DuplicateVocabularyToken
語彙の first 番目と second 番目が重複。
InvalidMaxTokens
max_tokens が 2 以下で語彙が入らない。
InvalidNgrams
n-gram の n が 0 または上限超過。
OutputSequenceLengthTooLarge
output_sequence_length が上限超過。
TooManyDistinctTokens
adapt 中の異なり語数が上限超過。
OutputTooLarge
出力要素数 B × L(bag 系出力は B × W。またはそのバイト数)が上限超過・overflow
(overflow 時は elements = usize::MAX)。
LimitAboveAbsoluteMaximum
上限の設定値が絶対上限を超えた(TextLimits::with_*)。limit は
フィールド名の固定文字列。設計記録 §6 の variant 案にない追加分
(§8「設定値が絶対上限を超えたら Err」を満たすため。公開時の承認対象)。
NgramCountOverflow
n-gram の生成数の上限見積り tokens × n が usize を超えた。設計記録 §6 の
variant 案にない追加分(§8 の checked_mul 検査を満たすため。公開時の承認対象)。
FrequencyOverflow
adapt で語の出現頻度(u64)が加算 overflow した。語の文字列は持たない。
設計記録 §6 の variant 案にない追加分(§8 の checked_add 検査を満たすため。
公開時の承認対象)。
MissingIdfWeights
transform_tf_idf を、idf 重みを持たないインスタンス(from_vocabulary/adapt
で作ったもの)で呼んだ。from_vocabulary_with_idf/adapt_tf_idf で作る必要がある。
IdfWeightsLengthMismatch
from_vocabulary_with_idf の idf 重みの個数が語彙の個数と一致しない。
expected は語彙の個数(予約 2 件を含まない)。
InvalidIdfWeight
index 番目の idf 重みが有限でない、または負。値は持たない。
PadToMaxTokensWithoutMaxTokens
pad_to_max_tokens が true なのに max_tokens が None(出力幅が決まらない)。
TokenCountNotExact
index 番目の入力の(n-gram 込みの)トークン数 count が、f32 で整数を正確に
数えられる上限 max(2^24)を超えた。件数の丸めを黙って許さないための fail-closed。
IdOutOfRange
StringLookup の逆引きで id が負または語彙数以上。index は入力 id の位置
(token は常に 0、invert は行優先で平坦化した最初の範囲外の位置)。id の値は持たない。
Shape(ShapeError)
テンソル形状の不整合。
Trait Implementations§
Source§impl Error for TextError
impl Error for TextError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for TextError
impl RefUnwindSafe for TextError
impl Send for TextError
impl Sync for TextError
impl Unpin for TextError
impl UnsafeUnpin for TextError
impl UnwindSafe for TextError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more