Skip to main content

TextError

Enum TextError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

BatchTooLarge

バッチ要素数(transform)またはコーパス件数(adapt)が上限超過。

Fields

§len: usize
§max: usize
§

InputTooLong

index 番目の入力文字列のバイト数が上限超過。Standardize::UnicodeLower では len は標準化後のバイト数(標準化で伸びた結果が上限を超えた場合)。

Fields

§index: usize
§len: usize
§max: usize
§

CorpusTooLarge

adapt のコーパス総バイト数が上限超過(加算 overflow 時は total_bytes = usize::MAX)。

Fields

§total_bytes: usize
§max: usize
§

VocabularyTooLarge

語彙数(予約 2 件を含む)が上限超過。

Fields

§len: usize
§max: usize
§

VocabularyTokenTooLong

index 番目の語彙のバイト数が上限超過。

Fields

§index: usize
§len: usize
§max: usize
§

EmptyVocabularyToken

index 番目の語彙が空文字列。

Fields

§index: usize
§

ReservedVocabularyToken

index 番目の語彙が予約語(""・"[UNK]")。

Fields

§index: usize
§

DuplicateVocabularyToken

語彙の first 番目と second 番目が重複。

Fields

§first: usize
§second: usize
§

InvalidMaxTokens

max_tokens が 2 以下で語彙が入らない。

Fields

§max_tokens: usize
§

InvalidNgrams

n-gram の n が 0 または上限超過。

Fields

§max: usize
§

OutputSequenceLengthTooLarge

output_sequence_length が上限超過。

Fields

§len: usize
§max: usize
§

TooManyDistinctTokens

adapt 中の異なり語数が上限超過。

Fields

§max: usize
§

OutputTooLarge

出力要素数 B × L(bag 系出力は B × W。またはそのバイト数)が上限超過・overflow (overflow 時は elements = usize::MAX)。

Fields

§elements: usize
§max: usize
§

LimitAboveAbsoluteMaximum

上限の設定値が絶対上限を超えた(TextLimits::with_*)。limit は フィールド名の固定文字列。設計記録 §6 の variant 案にない追加分 (§8「設定値が絶対上限を超えたら Err」を満たすため。公開時の承認対象)。

Fields

§limit: &'static str
§value: usize
§max: usize
§

NgramCountOverflow

n-gram の生成数の上限見積り tokens × n が usize を超えた。設計記録 §6 の variant 案にない追加分(§8 の checked_mul 検査を満たすため。公開時の承認対象)。

Fields

§tokens: usize
§

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 件を含まない)。

Fields

§len: usize
§expected: usize
§

InvalidIdfWeight

index 番目の idf 重みが有限でない、または負。値は持たない。

Fields

§index: usize
§

PadToMaxTokensWithoutMaxTokens

pad_to_max_tokens が true なのに max_tokens が None(出力幅が決まらない)。

§

TokenCountNotExact

index 番目の入力の(n-gram 込みの)トークン数 count が、f32 で整数を正確に 数えられる上限 max(2^24)を超えた。件数の丸めを黙って許さないための fail-closed。

Fields

§index: usize
§count: usize
§max: usize
§

IdOutOfRange

StringLookup の逆引きで id が負または語彙数以上。index は入力 id の位置 (token は常に 0、invert は行優先で平坦化した最初の範囲外の位置)。id の値は持たない。

Fields

§index: usize
§

Shape(ShapeError)

テンソル形状の不整合。

Trait Implementations§

Source§

impl Debug for TextError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for TextError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for TextError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V