Struct TokenFrequency

Source
pub struct TokenFrequency { /* private fields */ }
Expand description

TokenFrequency 構造体

Implementations§

Source§

impl TokenFrequency

Tokenの追加、削除の実装

Source

pub fn new() -> Self

Source

pub fn add_token(&mut self, token: &str) -> &mut Self

tokenを追加する

§Arguments
  • token - 追加するトークン
Source

pub fn add_tokens<T>(&mut self, tokens: &[T]) -> &mut Self
where T: AsRef<str>,

複数のtokenを追加する

§Arguments
  • tokens - 追加するトークンのスライス
Source

pub fn set_token_count(&mut self, token: &str, count: u32) -> &mut Self

👎Deprecated: countに0を指定した場合、token_numはそれを1つのユニークなtokenとしてカウントします。 このメソッドは、token_numのカウントを不正にする可能性があるため、非推奨です

tokenの出現回数を指定する

§Arguments
  • token - トークン
  • count - 出現回数
Source§

impl TokenFrequency

TF-calculationの実装

Source

pub fn tf_calc(max_count: u32, count: u32) -> f64

TFの計算メソッド

§Arguments
  • max_count - 最大カウント
  • count - カウント
§Returns
  • f64 - TFの値 (0.0~1.0)
Source

pub fn tf_vector<N>(&self) -> Vec<(String, N)>
where f64: IntoNormalizer<N>, N: Num,

全tokenのTFを取得します

§Returns
  • Vec<(String, N)> - トークンとそのTFのベクタ
Source

pub fn tf_vector_ref_str<N>(&self) -> Vec<(&str, N)>
where f64: IntoNormalizer<N>, N: Num,

全tokenのTFを取得します 文字列はこれの参照を返します

§Returns
  • Vec<(&str, N)> - トークンとそのTFのベクタ
Source

pub fn tf_hashmap<N>(&self) -> HashMap<String, N>
where f64: IntoNormalizer<N>, N: Num,

全tokenのTFを取得します

§Returns
  • HashMap<String, N> - トークンとそのTFのハッシュマップ
Source

pub fn tf_hashmap_ref_str<N>(&self) -> HashMap<&str, N>
where f64: IntoNormalizer<N>, N: Num,

全tokenのTFを取得します 文字列はこれの参照を返します

§Returns
  • HashMap<&str, N> - トークンとそのTFのハッシュマップ
Source

pub fn tf_token<N>(&self, token: &str) -> N
where f64: IntoNormalizer<N>, N: Num,

特定のtokenのTFを取得します

§Arguments
  • token - トークン
§Returns
  • N - トークンのTF
Source§

impl TokenFrequency

IDF-calculationの実装

Source

pub fn idf_calc(total_doc_count: u64, max_idf: f64, doc_count: u32) -> f64

IDFの計算

§Arguments
  • total_doc_count - 全ドキュメント数
  • max_idf - 最大IDF
  • doc_count - ドキュメント内のトークン数
§Returns
  • f64 - IDFの値 (0.0~1.0)
Source

pub fn idf_vector<N>(&self, total_doc_count: u64) -> Vec<(String, N)>
where f64: IntoNormalizer<N>, N: Num,

全tokenのIDFを取得します

§Arguments
  • total_doc_count - 全ドキュメント数
§Returns
  • Vec<(String, N)> - トークンとそのIDFのベクタ
Source

pub fn idf_vector_ref_str<N>(&self, total_doc_count: u64) -> Vec<(&str, N)>
where f64: IntoNormalizer<N>, N: Num,

全tokenのIDFを取得します 文字列はこれの参照を返します

§Arguments
  • total_doc_count - 全ドキュメント数
§Returns
  • Vec<(&str, N)> - トークンとそのIDFのベクタ
Source

pub fn idf_hashmap<N>(&self, total_doc_count: u64) -> HashMap<String, N>
where f64: IntoNormalizer<N>, N: Num,

全tokenのIDFを取得します

§Arguments
  • total_doc_count - 全ドキュメント数
§Returns
  • HashMap<String, N> - トークンとそのIDFのハッシュマップ
Source

pub fn idf_hashmap_ref_str<N>(&self, total_doc_count: u64) -> HashMap<&str, N>
where f64: IntoNormalizer<N>, N: Num,

全tokenのIDFを取得します 文字列はこれの参照を返します

§Arguments
  • total_doc_count - 全ドキュメント数
§Returns
  • HashMap<&str, N> - トークンとそのIDFのハッシュマップ
Source§

impl TokenFrequency

TokenFrequencyの情報を取得するための実装

Source

pub fn token_count_vector(&self) -> Vec<(String, u32)>

すべてのtokenの出現回数を取得します

§Returns
  • Vec<(String, u32)> - トークンとその出現回数のベクタ
Source

pub fn token_count_vector_ref_str(&self) -> Vec<(&str, u32)>

すべてのtokenの出現回数を取得します 文字列はこれの参照を返します

§Returns
  • Vec<(&str, u32)> - トークンとその出現回数のベクタ
Source

pub fn token_count_hashmap_ref_str(&self) -> HashMap<&str, u32>

すべてのtokenの出現回数を取得します 文字列はこれの参照を返します

§Returns
  • HashMap<&str, u32> - トークンとその出現回数のハッシュマップ
Source

pub fn token_total_count(&self) -> u64

全tokenのカウントの合計を取得します

§Returns
  • u64 - tokenのカウントの合計
Source

pub fn token_count(&self, token: &str) -> u32

あるtokenの出現回数を取得します

§Arguments
  • token - トークン
§Returns
  • u32 - トークンの出現回数
Source

pub fn most_frequent_tokens_vector(&self) -> Vec<(String, u32)>

もっとも多く出現したtokenを取得します 同じ出現回数のtokenが複数ある場合は、すべてのtokenを取得します

§Returns
  • Vec<(String, u32)> - トークンとその出現回数のベクタ
Source

pub fn most_frequent_token_count(&self) -> u32

もっとも多く出現したtokenを取得します

§Returns
  • u32 - 再頻出tokenの出現回数
Source

pub fn contains_token(&self, token: &str) -> bool

tokenが存在するかどうかを確認します

§Arguments
  • token - トークン
§Returns
  • bool - tokenが存在する場合はtrue、存在しない場合はfalse
Source

pub fn token_set(&self) -> Vec<String>

tokenのsetを取得します

§Returns
  • Vec<String> - tokenのset
Source

pub fn token_set_ref_str(&self) -> Vec<&str>

tokenのsetを取得します 文字列はこれの参照を返します

§Returns
  • Vec<&str> - tokenのset
Source

pub fn token_hashset(&self) -> HashSet<String>

tokenのsetを取得します

§Returns
  • HashSet<String> - tokenのset
Source

pub fn token_hashset_ref_str(&self) -> HashSet<&str>

tokenのsetを取得します 文字列はこれの参照を返します

§Returns
  • HashSet<&str> - tokenのset
Source

pub fn token_num(&self) -> usize

出現した単語数を取得します

§Returns
  • usize - 出現した単語数
Source

pub fn remove_tokens_by_condition<F>(&mut self, condition: F) -> u64
where F: Fn(&str, &u32) -> bool,

条件に基づいてtokenを削除します

§Arguments
  • condition - 条件を満たすtokenを削除するクロージャ
§Returns
  • u64 - 削除されたtokenの合計数
Source

pub fn sorted_frequency_vector(&self) -> Vec<(String, u32)>

頻度でソートされたトークンのベクタを取得(降順)

§Returns
  • Vec<(String, u32)> - 頻度でソートされたトークンのベクタ
Source

pub fn sorted_dict_order_vector(&self) -> Vec<(String, u32)>

辞書順でソートされたトークンのベクタを取得(昇順)

§Returns
  • Vec<(String, u32)> - 辞書順でソートされたトークンのベクタ
Source

pub fn unique_token_ratio(&self) -> f64

tokenの多様性を計算します 1.0は完全な多様性を示し、0.0は完全な非多様性を示します

§Returns
  • f64 - tokenの多様性
Source

pub fn clear(&mut self)

カウントを全リセットします

Trait Implementations§

Source§

impl Clone for TokenFrequency

Source§

fn clone(&self) -> TokenFrequency

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenFrequency

Source§

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

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

impl<'de> Deserialize<'de> for TokenFrequency

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for TokenFrequency

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,