Struct Index

Source
pub struct Index<IdType>
where IdType: Clone + Eq + Hash + Serialize + Debug,
{ pub index: HashMap<IdType, (DefaultSparseVec<u16>, u64)>, pub avg_tokens_len: u64, pub max_tokens_len: u64, pub idf: Map<Vec<u8>>, pub total_doc_count: u64, }

Fields§

§index: HashMap<IdType, (DefaultSparseVec<u16>, u64)>§avg_tokens_len: u64§max_tokens_len: u64§idf: Map<Vec<u8>>§total_doc_count: u64

Implementations§

Source§

impl<IdType> Index<IdType>
where IdType: Clone + Eq + Hash + Serialize + Debug,

Source

pub fn new_with_set( index: HashMap<IdType, (DefaultSparseVec<u16>, u64)>, idf: Map<Vec<u8>>, avg_tokens_len: u64, max_tokens_len: u64, total_doc_count: u64, ) -> Self

Source

pub fn get_index(&self) -> &HashMap<IdType, (DefaultSparseVec<u16>, u64)>

Source

pub fn search_cos_similarity( &self, query: &[&str], n: usize, ) -> Vec<(&IdType, f64)>

単純なコサイン類似度検索

Source

pub fn search_cos_similarity_tuned( &self, query: &[&str], n: usize, b: f64, ) -> Vec<(&IdType, f64)>

文書長を正規化するパラメータを入れたコサイン類似度検索

Source

pub fn search_bm25_tfidf( &self, query: &[&str], n: usize, k1: f64, b: f64, ) -> Vec<(&IdType, f64)>

Source

pub fn synthesize_index(&mut self, other: Self)

Source

pub fn bm25_with_csvec_optimized( query_vec: &DefaultSparseVec<u16>, doc_vec: &DefaultSparseVec<u16>, doc_len: u64, avg_doc_len: f64, k1: f64, b: f64, ) -> f64

Trait Implementations§

Source§

impl<IdType> Clone for Index<IdType>
where IdType: Clone + Eq + Hash + Serialize + Debug + Clone,

Source§

fn clone(&self) -> Index<IdType>

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<IdType> Debug for Index<IdType>
where IdType: Clone + Eq + Hash + Serialize + Debug + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<IdType> Freeze for Index<IdType>

§

impl<IdType> RefUnwindSafe for Index<IdType>
where IdType: RefUnwindSafe,

§

impl<IdType> Send for Index<IdType>
where IdType: Send,

§

impl<IdType> Sync for Index<IdType>
where IdType: Sync,

§

impl<IdType> Unpin for Index<IdType>
where IdType: Unpin,

§

impl<IdType> UnwindSafe for Index<IdType>
where IdType: UnwindSafe,

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.