pub struct WikipediaKnowledgeStore {
pub entity_types: HashMap<String, WikidataNERType>,
pub outlinks: HashMap<String, HashSet<String>>,
pub categories: HashMap<String, Vec<String>>,
pub dictionary: Option<Arc<WikidataDictionary>>,
}Expand description
Store of Wikipedia/Wikidata knowledge for joint inference.
Provides semantic information about entities:
- Type mappings (Q5 → Person, Q43229 → Organization)
- Outgoing links (for relatedness computation)
- Categories
Fields§
§entity_types: HashMap<String, WikidataNERType>Entity types by KB ID
outlinks: HashMap<String, HashSet<String>>Outgoing links by KB ID
categories: HashMap<String, Vec<String>>Categories by KB ID
dictionary: Option<Arc<WikidataDictionary>>Wikidata dictionary for type lookups
Implementations§
Source§impl WikipediaKnowledgeStore
impl WikipediaKnowledgeStore
Sourcepub fn from_dictionary(dict: WikidataDictionary) -> Self
pub fn from_dictionary(dict: WikidataDictionary) -> Self
Create from a Wikidata dictionary.
Sourcepub fn get_type(&self, kb_id: &str) -> Option<WikidataNERType>
pub fn get_type(&self, kb_id: &str) -> Option<WikidataNERType>
Get the entity type for a KB ID.
Sourcepub fn add_type(&mut self, kb_id: &str, ner_type: WikidataNERType)
pub fn add_type(&mut self, kb_id: &str, ner_type: WikidataNERType)
Add a type mapping.
Sourcepub fn add_outlinks(
&mut self,
kb_id: &str,
links: impl IntoIterator<Item = String>,
)
pub fn add_outlinks( &mut self, kb_id: &str, links: impl IntoIterator<Item = String>, )
Add outgoing links for an entity.
Check if two entities share outlinks.
Sourcepub fn mutual_link(&self, kb_id_a: &str, kb_id_b: &str) -> bool
pub fn mutual_link(&self, kb_id_a: &str, kb_id_b: &str) -> bool
Check if entities mutually link to each other.
Compute relatedness score between two entities.
Based on Wikipedia link structure (Milne & Witten 2008 style).
Trait Implementations§
Source§impl Clone for WikipediaKnowledgeStore
impl Clone for WikipediaKnowledgeStore
Source§fn clone(&self) -> WikipediaKnowledgeStore
fn clone(&self) -> WikipediaKnowledgeStore
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 WikipediaKnowledgeStore
impl Debug for WikipediaKnowledgeStore
Source§impl Default for WikipediaKnowledgeStore
impl Default for WikipediaKnowledgeStore
Source§fn default() -> WikipediaKnowledgeStore
fn default() -> WikipediaKnowledgeStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for WikipediaKnowledgeStore
impl RefUnwindSafe for WikipediaKnowledgeStore
impl Send for WikipediaKnowledgeStore
impl Sync for WikipediaKnowledgeStore
impl Unpin for WikipediaKnowledgeStore
impl UnsafeUnpin for WikipediaKnowledgeStore
impl UnwindSafe for WikipediaKnowledgeStore
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