#![allow(dead_code)]
use scirs2_core::ndarray::Array2;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Word2Vec {
vector_size: usize,
window: usize,
min_count: usize,
workers: usize,
sg: u8, vocabulary: HashMap<String, usize>,
embeddings: Option<Array2<f64>>,
}
impl Word2Vec {
pub fn new() -> Self {
Self {
vector_size: 100,
window: 5,
min_count: 1,
workers: 1,
sg: 0,
vocabulary: HashMap::new(),
embeddings: None,
}
}
pub fn vector_size(mut self, vector_size: usize) -> Self {
self.vector_size = vector_size;
self
}
pub fn window(mut self, window: usize) -> Self {
self.window = window;
self
}
pub fn sg(mut self, sg: u8) -> Self {
self.sg = sg;
self
}
}
impl Default for Word2Vec {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone)]
pub struct GloVe {
vector_size: usize,
learning_rate: f64,
max_iter: usize,
vocabulary: HashMap<String, usize>,
embeddings: Option<Array2<f64>>,
}
impl GloVe {
pub fn new() -> Self {
Self {
vector_size: 100,
learning_rate: 0.05,
max_iter: 100,
vocabulary: HashMap::new(),
embeddings: None,
}
}
pub fn vector_size(mut self, vector_size: usize) -> Self {
self.vector_size = vector_size;
self
}
pub fn learning_rate(mut self, learning_rate: f64) -> Self {
self.learning_rate = learning_rate;
self
}
}
impl Default for GloVe {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone)]
pub struct SentenceEmbeddings {
aggregation_method: AggregationMethod,
vector_size: usize,
}
#[derive(Debug, Clone)]
pub enum AggregationMethod {
Mean,
Max,
TfIdfWeighted,
}
impl SentenceEmbeddings {
pub fn new() -> Self {
Self {
aggregation_method: AggregationMethod::Mean,
vector_size: 100,
}
}
pub fn aggregation_method(mut self, method: AggregationMethod) -> Self {
self.aggregation_method = method;
self
}
}
impl Default for SentenceEmbeddings {
fn default() -> Self {
Self::new()
}
}
#[derive(Debug, Clone)]
pub struct Doc2Vec {
vector_size: usize,
learning_rate: f64,
min_count: usize,
epochs: usize,
}
impl Doc2Vec {
pub fn new() -> Self {
Self {
vector_size: 100,
learning_rate: 0.025,
min_count: 1,
epochs: 20,
}
}
pub fn vector_size(mut self, vector_size: usize) -> Self {
self.vector_size = vector_size;
self
}
pub fn epochs(mut self, epochs: usize) -> Self {
self.epochs = epochs;
self
}
}
impl Default for Doc2Vec {
fn default() -> Self {
Self::new()
}
}