pub struct Code2VecEncoder { /* private fields */ }Expand description
Code2Vec encoder for generating embeddings from AST paths
Implementations§
Source§impl Code2VecEncoder
impl Code2VecEncoder
Sourcepub fn new(dim: usize) -> Code2VecEncoder
pub fn new(dim: usize) -> Code2VecEncoder
Create a new Code2Vec encoder
Sourcepub fn with_seed(self, seed: u64) -> Code2VecEncoder
pub fn with_seed(self, seed: u64) -> Code2VecEncoder
Set random seed for reproducible embeddings
Sourcepub fn encode_path(&self, path: &AstPath) -> Vec<f64>
pub fn encode_path(&self, path: &AstPath) -> Vec<f64>
Encode a single path to an embedding vector
Sourcepub fn aggregate_paths(&self, paths: &[AstPath]) -> CodeEmbedding
pub fn aggregate_paths(&self, paths: &[AstPath]) -> CodeEmbedding
Aggregate multiple path embeddings into a single code embedding
Sourcepub fn add_token_embedding(
&mut self,
token: impl Into<String>,
embedding: Vec<f64>,
)
pub fn add_token_embedding( &mut self, token: impl Into<String>, embedding: Vec<f64>, )
Add a token embedding to the vocabulary
Sourcepub fn add_path_embedding(
&mut self,
path_key: impl Into<String>,
embedding: Vec<f64>,
)
pub fn add_path_embedding( &mut self, path_key: impl Into<String>, embedding: Vec<f64>, )
Add a path embedding to the vocabulary
Sourcepub fn token_vocab_size(&self) -> usize
pub fn token_vocab_size(&self) -> usize
Get vocabulary size for tokens
Sourcepub fn path_vocab_size(&self) -> usize
pub fn path_vocab_size(&self) -> usize
Get vocabulary size for paths
Trait Implementations§
Source§impl Debug for Code2VecEncoder
impl Debug for Code2VecEncoder
Source§impl Default for Code2VecEncoder
impl Default for Code2VecEncoder
Source§fn default() -> Code2VecEncoder
fn default() -> Code2VecEncoder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Code2VecEncoder
impl RefUnwindSafe for Code2VecEncoder
impl Send for Code2VecEncoder
impl Sync for Code2VecEncoder
impl Unpin for Code2VecEncoder
impl UnsafeUnpin for Code2VecEncoder
impl UnwindSafe for Code2VecEncoder
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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