pub struct DictionaryCandidateGenerator { /* private fields */ }Expand description
In-memory candidate generator using a preloaded dictionary.
Suitable for small KBs or testing.
§Similarity Metrics
The generator supports multiple similarity metrics via with_metric():
use anno::linking::{DictionaryCandidateGenerator, SimilarityMetric};
let gen = DictionaryCandidateGenerator::new()
.with_metric(SimilarityMetric::EditDistance)
.with_well_known();
// For OCR'd text with damage markers:
let gen_ocr = DictionaryCandidateGenerator::new()
.with_metric(SimilarityMetric::EditDistanceWildcard)
.with_well_known();Implementations§
Source§impl DictionaryCandidateGenerator
impl DictionaryCandidateGenerator
Sourcepub fn with_metric(self, metric: SimilarityMetric) -> Self
pub fn with_metric(self, metric: SimilarityMetric) -> Self
Set the similarity metric for fuzzy matching.
§Example
use anno::linking::{DictionaryCandidateGenerator, SimilarityMetric};
// For damaged historical text with wildcards
let gen = DictionaryCandidateGenerator::new()
.with_metric(SimilarityMetric::EditDistanceWildcard);Sourcepub fn metric(&self) -> SimilarityMetric
pub fn metric(&self) -> SimilarityMetric
Get the current similarity metric.
Sourcepub fn add_entry(&mut self, surface: &str, candidate: Candidate)
pub fn add_entry(&mut self, surface: &str, candidate: Candidate)
Add an entry to the dictionary.
Sourcepub fn with_well_known(self) -> Self
pub fn with_well_known(self) -> Self
Load well-known entities (for demo/testing).
Includes diverse entities across cultures and languages per multilingual guidelines. Coverage: Western, East Asian, Middle Eastern, African, South Asian, Latin American.
Trait Implementations§
Source§impl Clone for DictionaryCandidateGenerator
impl Clone for DictionaryCandidateGenerator
Source§fn clone(&self) -> DictionaryCandidateGenerator
fn clone(&self) -> DictionaryCandidateGenerator
Returns a duplicate 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 DictionaryCandidateGenerator
impl Debug for DictionaryCandidateGenerator
Source§impl Default for DictionaryCandidateGenerator
impl Default for DictionaryCandidateGenerator
Source§fn default() -> DictionaryCandidateGenerator
fn default() -> DictionaryCandidateGenerator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DictionaryCandidateGenerator
impl RefUnwindSafe for DictionaryCandidateGenerator
impl Send for DictionaryCandidateGenerator
impl Sync for DictionaryCandidateGenerator
impl Unpin for DictionaryCandidateGenerator
impl UnsafeUnpin for DictionaryCandidateGenerator
impl UnwindSafe for DictionaryCandidateGenerator
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more