Skip to main content

StaticVectors

Struct StaticVectors 

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

Word vectors from a file.

Implementations§

Source§

impl StaticVectors

Source

pub fn load(path: &Path) -> Result<StaticVectors, Error>

Read path: one word per line followed by its numbers, separated by spaces; a first line of two numbers (count, dimension) is a header and skipped. Words are matched in lower case.

Source

pub fn parse(model: &str, text: &str) -> Result<StaticVectors, String>

The same as load, from text.

Trait Implementations§

Source§

impl Debug for StaticVectors

Source§

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

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

impl Embedder for StaticVectors

Source§

fn model(&self) -> &str

Names the model, so vectors from another one are never compared with these: static:<file name> or local:<program>.
Source§

fn dimension(&self) -> usize

Source§

fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, Error>

One vector per text, in order, each dimension long. A text the model has nothing for gets zeros.

Auto Trait Implementations§

§

impl Forget for StaticVectors

§

impl Freeze for StaticVectors

§

impl Move for StaticVectors

§

impl RefUnwindSafe for StaticVectors

§

impl Send for StaticVectors
where RawVecInner: Send, RawTable<(String, Vec<f32>)>: Send,

§

impl Sync for StaticVectors
where RawVecInner: Sync, RawTable<(String, Vec<f32>)>: Sync,

§

impl Unpin for StaticVectors
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for StaticVectors

§

impl UnwindSafe for StaticVectors
where RawVecInner: UnwindSafe, HashMap<String, Vec<f32>>: 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> 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, 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.