Skip to content

Commit

Permalink
build: turn off query and skos crates
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonskj committed Sep 16, 2024
1 parent d9f95e6 commit cafcdae
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 82 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ members = [
"rdftk_iri",
"rdftk_names",
"rdftk_ontology",
"rdftk_query",
"rdftk_skos",
# "rdftk_query",
# "rdftk_skos",
]
3 changes: 3 additions & 0 deletions rdftk_ontology/src/owl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum HeaderProperty {
Imports(IriRef),
}

#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct Ontology {
uri: IriRef,
Expand All @@ -38,13 +39,15 @@ pub struct Ontology {
properties: HashMap<IriRef, Property>,
}

#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct Class {
description: ClassDescription,
axioms: Vec<ClassAxiom>,
deprecated: bool,
}

#[allow(dead_code)]
#[derive(Clone, Debug)]
pub struct Property {
deprecated: bool,
Expand Down
4 changes: 2 additions & 2 deletions rdftk_ontology/src/rdfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ pub struct Property {
// ------------------------------------------------------------------------------------------------

pub fn rdf_schema() -> Vocabulary {
let mut schema = Vocabulary::new(rdfs::namespace_iri().clone());
let mut schema = Vocabulary::new(rdfs::namespace().clone());
let iri = IriRef::from(Iri::from_str("https://www.w3.org/TR/rdf-schema").unwrap());
schema.add_is_defined_by(iri.into());
schema.add_is_defined_by(iri);
// schema.add_comment("W3C Recommendation 25 February 2014".into());

schema.add_class(Class::new(rdfs::resource().clone()));
Expand Down
5 changes: 3 additions & 2 deletions rdftk_skos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ default = ["documentation"]
documentation = ["somedoc"]

[dependencies]
lazy_static = "1.4.0"
paste = "1.0.2"
lazy_static = "1.4"
objio = "0.1"
paste = "1.0"
rdftk_io = { version = "0.3", path = "../rdftk_io" }
rdftk_iri = { version = "0.2.1", path = "../rdftk_iri" }
rdftk_core = { version = "0.4.1", path = "../rdftk_core" }
Expand Down
15 changes: 7 additions & 8 deletions rdftk_skos/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use crate::model::{
LiteralProperty, Resource, Scheme, ToUri,
};
use crate::ns;
use objio::ObjectWriter;
use rdftk_core::model::graph::mapping::PrefixMappingRef;
use rdftk_core::model::literal::LanguageTag;
use rdftk_core::simple;
use rdftk_io::turtle::writer::TurtleWriter;
use rdftk_io::write_graph_to_string;
use rdftk_iri::IRIRef;
use somedoc::error::{Error, ErrorKind, ResultExt};
use rdftk_iri::IriRef;
use somedoc::error::Error;
use somedoc::model::block::{
Cell, Column, Formatted, HasBlockContent, HasLabel, Heading, HeadingLevel, Label as Anchor,
List, Paragraph, Row, Table,
Expand Down Expand Up @@ -53,7 +53,7 @@ struct Context {
pub fn make_document(
scheme: &Scheme,
language: Option<LanguageTag>,
default_namespace: Option<IRIRef>,
default_namespace: Option<IriRef>,
) -> Result<Document, Error> {
let ns_mappings = standard_mappings();
if let Some(default_namespace) = default_namespace {
Expand Down Expand Up @@ -152,8 +152,7 @@ pub fn make_document_with_mappings(

let graph = to_rdf_graph_with_mappings(&scheme, context.ns_mappings, &simple::graph_factory());
let writer = TurtleWriter::default();
let code = write_graph_to_string(&writer, &graph)
.chain_err(|| ErrorKind::Msg("Could not serialize graph".to_string()))?;
let code = writer.write_to_string(&graph)?;

let _ = document.add_formatted(Formatted::from(code));

Expand Down Expand Up @@ -335,7 +334,7 @@ fn write_concept(document: &mut Document, concept: &Concept, context: &Context)

fn write_concept_relations(document: &mut Document, concept: &Concept, context: &Context) {
let _ = document.add_heading(Heading::new("Related Concepts", level_to_heading(4)));
let mut table = Table::new(&[Column::from("Relationship"), Column::from("Concept IRI")]);
let mut table = Table::new(&[Column::from("Relationship"), Column::from("Concept Iri")]);
for (relation, related) in concept.concepts() {
let related = related.borrow();
let label = related.get_preferred_label_for(&context.language);
Expand Down Expand Up @@ -446,7 +445,7 @@ fn write_collection(document: &mut Document, collection: &Collection, context: &
write_collection_membership(document, collection.uri(), context);
}

fn write_collection_membership(document: &mut Document, member_uri: &IRIRef, context: &Context) {
fn write_collection_membership(document: &mut Document, member_uri: &IriRef, context: &Context) {
let in_collections: Vec<&Rc<RefCell<Collection>>> = context
.collections
.iter()
Expand Down
20 changes: 10 additions & 10 deletions rdftk_skos/src/model/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rdftk_core::model::literal::{LanguageTag, LiteralFactoryRef};
use rdftk_core::model::statement::{
ObjectNodeRef, StatementFactoryRef, StatementList, SubjectNodeRef,
};
use rdftk_iri::IRIRef;
use rdftk_iri::IriRef;
use rdftk_names::rdf;
use std::cell::RefCell;
use std::rc::Rc;
Expand All @@ -35,7 +35,7 @@ pub enum Member {

#[derive(Clone, Debug, PartialEq)]
pub struct Collection {
uri: IRIRef,
uri: IriRef,
ordered: bool,
members: Vec<Member>,
preferred_label: Option<String>,
Expand All @@ -48,7 +48,7 @@ pub struct Collection {
// ------------------------------------------------------------------------------------------------

impl Member {
fn uri(&self) -> IRIRef {
fn uri(&self) -> IriRef {
match self {
Member::Concept(member) => member.borrow().uri().clone(),
Member::Collection(member) => member.borrow().uri().clone(),
Expand Down Expand Up @@ -81,7 +81,7 @@ impl Member {
// ------------------------------------------------------------------------------------------------

impl Resource for Collection {
fn uri(&self) -> &IRIRef {
fn uri(&self) -> &IriRef {
&self.uri
}
}
Expand Down Expand Up @@ -197,7 +197,7 @@ impl ToStatements for Collection {
}

impl Collection {
pub(crate) fn new(uri: &IRIRef, ordered: bool) -> Self {
pub(crate) fn new(uri: &IriRef, ordered: bool) -> Self {
Self {
uri: uri.clone(),
ordered,
Expand All @@ -208,7 +208,7 @@ impl Collection {
}
}

pub(crate) fn new_with_label(uri: &IRIRef, ordered: bool, text: &str, language: &str) -> Self {
pub(crate) fn new_with_label(uri: &IriRef, ordered: bool, text: &str, language: &str) -> Self {
let mut collection = Self::new(uri, ordered);
collection.add_label(Label::preferred(text, language));
collection
Expand All @@ -221,15 +221,15 @@ impl Collection {
self.members.push(Member::Collection(collection));
}

pub fn sub_collection(&mut self, uri: &IRIRef, ordered: bool) -> Rc<RefCell<Collection>> {
pub fn sub_collection(&mut self, uri: &IriRef, ordered: bool) -> Rc<RefCell<Collection>> {
let member = Rc::from(RefCell::from(Self::new(uri, ordered)));
self.add_member_collection(member.clone());
member
}

pub fn sub_collection_labeled(
&mut self,
uri: &IRIRef,
uri: &IriRef,
ordered: bool,
label: &str,
language: &str,
Expand Down Expand Up @@ -258,7 +258,7 @@ impl Collection {
!self.members.is_empty()
}

pub fn has_member(&self, uri: &IRIRef) -> bool {
pub fn has_member(&self, uri: &IriRef) -> bool {
self.members.iter().any(|member| &member.uri() == uri)
}

Expand Down Expand Up @@ -316,7 +316,7 @@ fn make_list_node(
fn add_to_list_node(
statements: &mut StatementList,
current: &SubjectNodeRef,
member_uri: &IRIRef,
member_uri: &IriRef,
factory: &StatementFactoryRef,
) {
statements.push(
Expand Down
34 changes: 17 additions & 17 deletions rdftk_skos/src/model/concept.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::model::{ToStatement, ToUri};
use crate::ns;
use rdftk_core::model::literal::{LanguageTag, LiteralFactoryRef};
use rdftk_core::model::statement::{ObjectNodeRef, StatementFactoryRef, StatementList};
use rdftk_iri::IRIRef;
use rdftk_iri::IriRef;
use rdftk_names::rdf;
use std::cell::RefCell;
use std::rc::Rc;
Expand All @@ -39,9 +39,9 @@ pub enum ConceptRelation {

#[derive(Clone, Debug, PartialEq)]
pub struct Concept {
uri: IRIRef,
uri: IriRef,
concepts: Vec<(ConceptRelation, Rc<RefCell<Concept>>)>,
external_relations: Vec<(IRIRef, IRIRef)>,
external_relations: Vec<(IriRef, IriRef)>,
preferred_label: Option<String>,
labels: Vec<Label>,
properties: Vec<LiteralProperty>,
Expand All @@ -58,7 +58,7 @@ impl Default for ConceptRelation {
}

impl ToUri for ConceptRelation {
fn to_uri(&self) -> IRIRef {
fn to_uri(&self) -> IriRef {
match self {
Self::Narrower => ns::narrower(),
Self::NarrowerPartitive => ns::iso::narrower_partitive(),
Expand Down Expand Up @@ -105,7 +105,7 @@ impl ConceptRelation {
// ------------------------------------------------------------------------------------------------

impl Resource for Concept {
fn uri(&self) -> &IRIRef {
fn uri(&self) -> &IriRef {
&self.uri
}
}
Expand Down Expand Up @@ -203,7 +203,7 @@ impl ToStatements for Concept {
}

impl Concept {
pub(crate) fn new(uri: &IRIRef) -> Self {
pub(crate) fn new(uri: &IriRef) -> Self {
Self {
uri: uri.clone(),
concepts: Default::default(),
Expand All @@ -214,7 +214,7 @@ impl Concept {
}
}

pub(crate) fn new_with_label(uri: &IRIRef, text: &str, language: &str) -> Self {
pub(crate) fn new_with_label(uri: &IriRef, text: &str, language: &str) -> Self {
let mut concept = Self::new(uri);
concept.add_label(Label::preferred(text, language));
concept
Expand All @@ -230,15 +230,15 @@ impl Concept {
self.concepts.push((relation, related));
}

pub fn sub_concept(&mut self, uri: &IRIRef) -> Rc<RefCell<Self>> {
pub fn sub_concept(&mut self, uri: &IriRef) -> Rc<RefCell<Self>> {
let new_concept = Rc::from(RefCell::from(Self::new(uri)));
self.add_related_concept(ConceptRelation::Narrower, new_concept.clone());
new_concept
}

pub fn sub_concept_with_label(
&mut self,
uri: &IRIRef,
uri: &IriRef,
text: &str,
language: &str,
) -> Rc<RefCell<Self>> {
Expand All @@ -247,15 +247,15 @@ impl Concept {
new_concept
}

pub fn instance(&mut self, uri: &IRIRef) -> Rc<RefCell<Self>> {
pub fn instance(&mut self, uri: &IriRef) -> Rc<RefCell<Self>> {
let new_concept = Rc::from(RefCell::from(Self::new(uri)));
self.add_related_concept(ConceptRelation::NarrowerInstantial, new_concept.clone());
new_concept
}

pub fn instance_with_label(
&mut self,
uri: &IRIRef,
uri: &IriRef,
text: &str,
language: &str,
) -> Rc<RefCell<Self>> {
Expand All @@ -264,15 +264,15 @@ impl Concept {
new_concept
}

pub fn part(&mut self, uri: &IRIRef) -> Rc<RefCell<Self>> {
pub fn part(&mut self, uri: &IriRef) -> Rc<RefCell<Self>> {
let new_concept = Rc::from(RefCell::from(Self::new(uri)));
self.add_related_concept(ConceptRelation::NarrowerPartitive, new_concept.clone());
new_concept
}

pub fn part_with_label(
&mut self,
uri: &IRIRef,
uri: &IriRef,
text: &str,
language: &str,
) -> Rc<RefCell<Self>> {
Expand All @@ -281,15 +281,15 @@ impl Concept {
new_concept
}

pub fn related(&mut self, uri: &IRIRef) -> Rc<RefCell<Self>> {
pub fn related(&mut self, uri: &IriRef) -> Rc<RefCell<Self>> {
let new_concept = Rc::from(RefCell::from(Self::new(uri)));
self.add_related_concept(ConceptRelation::Related, new_concept.clone());
new_concept
}

pub fn related_with_label(
&mut self,
uri: &IRIRef,
uri: &IriRef,
text: &str,
language: &str,
) -> Rc<RefCell<Self>> {
Expand Down Expand Up @@ -335,11 +335,11 @@ impl Concept {
!self.external_relations.is_empty()
}

pub fn external_relations(&self) -> impl Iterator<Item = &(IRIRef, IRIRef)> {
pub fn external_relations(&self) -> impl Iterator<Item = &(IriRef, IriRef)> {
self.external_relations.iter()
}

pub fn add_external_relation(&mut self, relation: IRIRef, related: IRIRef) {
pub fn add_external_relation(&mut self, relation: IriRef, related: IriRef) {
self.external_relations.push((relation, related));
}
}
Loading

0 comments on commit cafcdae

Please sign in to comment.