use crate::idx::IdxSplit;
use crate::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const IMDB_PACK: Pack = Pack {
name: "imdb",
version: "1.0.0",
license: "unspecified",
files: &[PackFile {
name: "aclImdb_v1.tar.gz",
size: 84_125_825,
shake256: "2688e6ee353cdc3412901bad1cd42be7d432a845c0b231e2860d822eebd14e81",
urls: &["https://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz"],
}],
};
pub type ImdbSplit = IdxSplit;
#[derive(Clone, Debug)]
pub struct ImdbConfig {
pub split: ImdbSplit,
pub text_len: usize,
pub cache_dir: Option<PathBuf>,
pub normalize: bool,
}
impl Default for ImdbConfig {
fn default() -> Self {
Self {
split: ImdbSplit::Train,
text_len: 512,
cache_dir: None,
normalize: true,
}
}
}
impl ImdbConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::Imdb {
#[inline]
pub fn load(config: &ImdbConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &ImdbConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &ImdbConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}