This commit is contained in:
2026-08-16 21:42:14 -04:00
parent 72a39e5baa
commit 025392b129
4 changed files with 37 additions and 4 deletions
+20 -2
View File
@@ -56,6 +56,24 @@ impl<'a> Indexer<'a> {
])
}
fn work(&self, graph: &Graph, subject: NamedNodeRef) -> HashMap<Field, OwnedValue> {
HashMap::from_iter([
(
Schema::field("title", self.language.primary_language()),
self.extract_string(graph, subject, vocab::rdawd::TITLE_OF_WORK),
),
])
}
fn expression(&self, graph: &Graph, subject: NamedNodeRef) -> HashMap<Field, OwnedValue> {
HashMap::from_iter([
(
Schema::field("title", self.language.primary_language()),
self.extract_string(graph, subject, vocab::rdaed::TITLE_OF_EXPRESSION),
),
])
}
pub fn graph(&self, graph: &Graph) -> crate::Result<Vec<HashMap<Field, OwnedValue>>> {
let mut entities_and_types = HashSet::new();
let triples = graph.triples_for_predicate(vocab::rdf::TYPE);
@@ -73,10 +91,10 @@ impl<'a> Indexer<'a> {
Class::RdfProperty => None,
Class::RdfsClass => None,
Class::SkosConcept => None,
Class::Work => Some(self.person(graph, *subject)),
Class::Work => Some(self.work(graph, *subject)),
Class::Person => Some(self.person(graph, *subject)),
Class::CorporateBody => Some(self.corporate_body(graph, *subject)),
Class::Expression => Some(self.person(graph, *subject)),
Class::Expression => Some(self.expression(graph, *subject)),
Class::Manifestation => Some(self.person(graph, *subject)),
}.map(|mut document| {
document.insert(Schema::discriminant_field(), OwnedValue::from(class as u64));
+14
View File
@@ -56,3 +56,17 @@ pub mod rdaad {
pub const NAME_OF_CORPORATE_BODY: NamedNodeRef =
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/a/datatype/P50032");
}
pub mod rdawd {
use oxigraph::model::NamedNodeRef;
pub const TITLE_OF_WORK: NamedNodeRef =
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/w/datatype/P10088");
}
pub mod rdaed {
use oxigraph::model::NamedNodeRef;
pub const TITLE_OF_EXPRESSION: NamedNodeRef =
NamedNodeRef::new_unchecked("http://rdaregistry.info/Elements/e/datatype/P20312");
}
+1 -2
View File
@@ -155,8 +155,7 @@ fn main() -> color_eyre::Result<()> {
.map(Triple::from)
.collect::<Graph>();
let documents = indexer.graph(&graph_with_inferences)?;
for document in documents {
for document in indexer.graph(&graph_with_inferences)? {
writer.add_document(document)?;
}
+2
View File
@@ -39,6 +39,8 @@ impl Schema {
schema_builder.add_text_field("given_name:en", stored_ngram32.clone());
schema_builder.add_text_field("corporate_name:en", stored_ngram32.clone());
schema_builder.add_text_field("title:en", stored_en_stem.clone());
schema_builder.add_u64_field("subtitle_start", schema::STORED);
schema_builder.add_u64_field("subtitle_end", schema::STORED);
schema_builder.add_text_field("subtitle:en", stored_en_stem.clone());