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