Skip to main content

Corpus

Struct Corpus 

Source
pub struct Corpus {
    pub documents: Vec<CorpusDocument>,
    pub name: String,
}
Expand description

A corpus of documents to be ingested into a colony.

Fields§

§documents: Vec<CorpusDocument>§name: String

Implementations§

Source§

impl Corpus

Source

pub fn from_directory(path: &Path) -> Result<Self>

Load all .txt files from a directory.

Files are assigned positions in a grid layout and categories are inferred from filename prefixes (e.g., cell_biology_01.txt gets category “cell_biology”).

Source

pub fn from_embedded() -> Self

Load corpus from disk or fall back to inline content.

Tries to load the expanded 100-document corpus from the poc/data/corpus/ directory. Falls back to an inline 20-document corpus if the directory is not found (e.g., when running tests from a different working directory).

Topics: cell_biology, molecular_transport, genetics, quantum_computing. Ground-truth clusters enable measuring community detection purity.

Source

pub fn inline_corpus() -> Self

Inline fallback corpus with 20 documents across 4 topics. Used when the disk corpus directory is not available.

Source

pub fn len(&self) -> usize

Number of documents in the corpus.

Source

pub fn is_empty(&self) -> bool

Whether the corpus is empty.

Source

pub fn ground_truth(&self) -> HashMap<String, String>

Get the ground-truth category labels (for NMI computation). Returns a map of document title -> category.

Source

pub fn categories(&self) -> Vec<String>

Get unique categories in the corpus.

Source

pub fn limit(self, max: usize) -> Self

Limit corpus to at most max documents, evenly sampled across categories.

Source

pub fn ingest_into(&self, colony: &mut Colony)

Ingest all documents into a colony.

Auto Trait Implementations§

§

impl Freeze for Corpus

§

impl RefUnwindSafe for Corpus

§

impl Send for Corpus

§

impl Sync for Corpus

§

impl Unpin for Corpus

§

impl UnwindSafe for Corpus

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.