Struct kalosm_language::context::DocumentFolder
source · pub struct DocumentFolder { /* private fields */ }
Expand description
A folder full of documents.
§Example
ⓘ
use kalosm_language::prelude::*;
use std::io::Write;
use std::path::PathBuf;
#[tokio::main]
async fn main() {
let documents = DocumentFolder::try_from(PathBuf::from("./documents")).unwrap();
let mut database = DocumentDatabase::new(
Bert::builder().build().unwrap(),
ChunkStrategy::Sentence {
sentence_count: 1,
overlap: 0,
},
);
database.extend(documents.clone()).await.unwrap();
let mut fuzzy = FuzzySearchIndex::default();
fuzzy.extend(documents).await.unwrap();
loop {
print!("Query: ");
std::io::stdout().flush().unwrap();
let mut user_question = String::new();
std::io::stdin().read_line(&mut user_question).unwrap();
println!(
"vector: {:?}",
database
.search(&user_question, 5)
.await
.iter()
.collect::<Vec<_>>()
);
println!(
"fuzzy: {:?}",
fuzzy
.search(&user_question, 5)
.await
.iter()
.collect::<Vec<_>>()
);
}
}
Trait Implementations§
source§impl Clone for DocumentFolder
impl Clone for DocumentFolder
source§fn clone(&self) -> DocumentFolder
fn clone(&self) -> DocumentFolder
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DocumentFolder
impl Debug for DocumentFolder
source§impl IntoDocuments for DocumentFolder
impl IntoDocuments for DocumentFolder
Auto Trait Implementations§
impl RefUnwindSafe for DocumentFolder
impl Send for DocumentFolder
impl Sync for DocumentFolder
impl Unpin for DocumentFolder
impl UnwindSafe for DocumentFolder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more