use crate::idx::IdxSplit;
use crate::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const YELP_POLARITY_PACK: Pack = Pack {
name: "yelp_polarity",
version: "1.0.0",
license: "unspecified",
files: &[PackFile {
name: "yelp_review_polarity_csv.tgz",
size: 166_373_201,
shake256: "993cc252c7472e4d5e9d28cadfcb90beea92a31c06f1bb26bd003571c258277c",
urls: &[
"https://fast-ai-nlp.s3.amazonaws.com/yelp_review_polarity_csv.tgz",
"https://s3.amazonaws.com/fast-ai-nlp/yelp_review_polarity_csv.tgz",
],
}],
};
pub type YelpPolaritySplit = IdxSplit;
#[derive(Clone, Debug)]
pub struct YelpPolarityConfig {
pub split: YelpPolaritySplit,
pub text_len: usize,
pub cache_dir: Option<PathBuf>,
pub normalize: bool,
}
impl Default for YelpPolarityConfig {
fn default() -> Self {
Self {
split: YelpPolaritySplit::Train,
text_len: 512,
cache_dir: None,
normalize: true,
}
}
}
impl YelpPolarityConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::YelpPolarity {
#[inline]
pub fn load(config: &YelpPolarityConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &YelpPolarityConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &YelpPolarityConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}