Skip to content

Commit

Permalink
fix ns type predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
nbittich committed Nov 22, 2024
1 parent f352396 commit 1ac9ef4
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tortank"
version = "0.22.0"
version = "0.23.0"
edition = "2021"
authors = ["Nordine Bittich <[email protected]>"]
description = "Turtle/N3 parser"
Expand Down
7 changes: 4 additions & 3 deletions src/triple_common_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,10 @@ pub(crate) mod triple {
)
}
pub(crate) fn ns_type(s: &str) -> ParserResult<Iri> {
map(terminated(char('a'), multispace1), |_| {
Iri::Enclosed(NS_TYPE)
})(s)
map(
preceded(multispace0, terminated(char('a'), multispace1)),
|_| Iri::Enclosed(NS_TYPE),
)(s)
}
pub(crate) fn predicate_list<'a, F1, F2, F3, F4, F5, T>(
subject_extractor: F1,
Expand Down
12 changes: 12 additions & 0 deletions src/turtle/turtle_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,18 @@ mod test {

assert_eq!(9, triples.len());
}
#[test]
fn turtle_doc_could_not_parse_completely() {
let mut buf_c = String::new();
let mut buf_f = String::new();
let turtle_c = TurtleDoc::from_file("tests/modelC.ttl", None, &mut buf_c).unwrap();
let turtle_f = TurtleDoc::from_file("tests/modelF.ttl", None, &mut buf_f).unwrap();

assert!(!turtle_c.to_string().is_empty());
assert_eq!(39, turtle_c.len());
assert_eq!(0, turtle_c.difference(&turtle_f).unwrap().len());
}

#[test]
fn turtle_doc_diff_buggy() {
let mut buf_a = String::new();
Expand Down
37 changes: 37 additions & 0 deletions tests/modelC.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

<http://mu.semte.ch/streams/ldes-mow-register> a <http://w3id.org/ldes#EventStream>, <https://w3id.org/tree#Collection>;
<https://w3id.org/tree#view> <./1>;
<http://w3id.org/ldes#timestampPath> <http://www.w3.org/ns/prov#generatedAtTime>;
<http://w3id.org/ldes#versionOfPath> <http://purl.org/dc/terms/isVersionOf>.
<./1> a <https://w3id.org/tree#Node>.
<http://mu.semte.ch/streams/ldes-mow-register> <https://w3id.org/tree#member> <http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1> <http://qudt.org/schema/qudt/hasQuantityKind> <http://qudt.org/vocab/quantitykind/Width>;
<http://www.w3.org/2000/01/rdf-schema#value> 1;
<http://qudt.org/schema/qudt/hasUnit> <http://qudt.org/vocab/unit/MilliM>;
a <http://www.cidoc-crm.org/cidoc-crm/E54_Dimension>;
<http://mu.semte.ch/vocabularies/core/uuid> "673E2195C7E1A9B9F3B8666A";
<http://purl.org/dc/terms/isVersionOf> <http://data.lblod.info/dimensions/673E2195C7E1A9B9F3B8666A>;
<http://www.w3.org/ns/prov#generatedAtTime> "2024-11-22T07:12:35.573Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>.
<http://mu.semte.ch/streams/ldes-mow-register> <https://w3id.org/tree#member> <http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2> <http://www.cidoc-crm.org/cidoc-crm/P2_has_type> <http://data.lblod.info/concept-schemes/0e0897d1-5c74-47ae-9868-adecbde6f2f3>;
<http://www.cidoc-crm.org/cidoc-crm/P43_has_dimension> <http://data.lblod.info/dimensions/673E2195C7E1A9B9F3B8666A>;
a <https://w3id.org/tribont/core#Shape>;
<http://mu.semte.ch/vocabularies/core/uuid> "673E2195C7E1A9B9F3B8666B";
<http://purl.org/dc/terms/isVersionOf> <http://data.lblod.info/tribont-shapes/673E2195C7E1A9B9F3B8666B>;
<http://www.w3.org/ns/prov#generatedAtTime> "2024-11-22T07:12:35.574Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>.
<http://mu.semte.ch/streams/ldes-mow-register> <https://w3id.org/tree#member> <http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://purl.org/dc/terms/type> <http://data.vlaanderen.be/id/concept/Verkeersbordcatergorie/2982567006d9e19f04063df73123f56f40e3a28941031a7ba6e6667f64740fa9>;
a <https://data.vlaanderen.be/ns/mobiliteit#Verkeerstekenconcept>, <https://data.vlaanderen.be/ns/mobiliteit#Verkeersbordconcept>;
<http://mu.semte.ch/vocabularies/core/uuid> "f9312556b1bdfbb278ec04033417152abbb254466df0069ff1894d0ea7a55482";
<http://data.lblod.info/vocabularies/mobiliteit/heeftGerelateerdVerkeersbordconcept> <http://data.vlaanderen.be/id/concept/Verkeersbordconcept/9cbedafef411f1c41317f8b9f4066ea6eccfc832edfc930d421725c3ebc5c167>;
<http://www.w3.org/2004/02/skos/core#prefLabel> "A11";
<http://www.w3.org/2003/06/sw-vocab-status/ns#termStatus> <http://mow.lblod.info/VerkeersbordconceptStatus/f073030491519fd8e60e230713fb1eee4a2cc49c93e69e39bb00fc9924ae9edd>;
<https://w3id.org/isCharacterisedBy#isCharacterisedBy> <http://data.lblod.info/tribont-shapes/673E2195C7E1A9B9F3B8666B>;
<http://www.w3.org/2004/02/skos/core#topConceptOf> <http://data.vlaanderen.be/id/conceptscheme/Verkeersbordconcept>;
<http://www.w3.org/2004/02/skos/core#scopeNote> "Uitweg op een kaai of een oever.";
<https://data.vlaanderen.be/ns/mobiliteit#grafischeWeergave> <http://mobiliteit.vo.data.gift/images/46864672-e9e5-435a-9ab9-586ccdbd8149>;
<https://data.vlaanderen.be/ns/mobiliteit#heeftOnderbordConcept> <http://data.vlaanderen.be/id/concept/Verkeersbordconcept/79d0bab2f07f815d457412b68edab1ba70ee15764d5fcbb531fa87ce24574da6>, <http://data.vlaanderen.be/id/concept/Verkeersbordconcept/061d2edb3caf482931ee7cea26f85d49538a5d4d0781872c0faad20328650beb>;
<http://www.w3.org/2004/02/skos/core#inScheme> <http://data.vlaanderen.be/id/conceptscheme/Verkeersbordconcept>;
<http://mu.semte.ch/vocabularies/ext/zonality> <http://lblod.data.gift/concepts/b651931b-923c-477c-8da9-fc7dd841fdcc>;
<http://purl.org/dc/terms/isVersionOf> <http://data.vlaanderen.be/id/concept/Verkeersbordconcept/f9312556b1bdfbb278ec04033417152abbb254466df0069ff1894d0ea7a55482>;
<http://www.w3.org/ns/prov#generatedAtTime> "2024-11-22T07:12:35.575Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>.
39 changes: 39 additions & 0 deletions tests/modelF.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<http://mu.semte.ch/streams/ldes-mow-register> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://w3id.org/ldes#EventStream>.
<http://mu.semte.ch/streams/ldes-mow-register> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/tree#Collection>.
<http://mu.semte.ch/streams/ldes-mow-register> <https://w3id.org/tree#view> <./1>.
<http://mu.semte.ch/streams/ldes-mow-register> <http://w3id.org/ldes#timestampPath> <http://www.w3.org/ns/prov#generatedAtTime>.
<http://mu.semte.ch/streams/ldes-mow-register> <http://w3id.org/ldes#versionOfPath> <http://purl.org/dc/terms/isVersionOf>.
<./1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/tree#Node>.
<http://mu.semte.ch/streams/ldes-mow-register> <https://w3id.org/tree#member> <http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1> <http://qudt.org/schema/qudt/hasQuantityKind> <http://qudt.org/vocab/quantitykind/Width>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1> <http://www.w3.org/2000/01/rdf-schema#value> "1"^^<http://www.w3.org/2001/XMLSchema#integer>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1> <http://qudt.org/schema/qudt/hasUnit> <http://qudt.org/vocab/unit/MilliM>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.cidoc-crm.org/cidoc-crm/E54_Dimension>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1> <http://mu.semte.ch/vocabularies/core/uuid> "673E2195C7E1A9B9F3B8666A"^^<http://www.w3.org/2001/XMLSchema#string>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1> <http://purl.org/dc/terms/isVersionOf> <http://data.lblod.info/dimensions/673E2195C7E1A9B9F3B8666A>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/1> <http://www.w3.org/ns/prov#generatedAtTime> "2024-11-22T07:12:35.573Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>.
<http://mu.semte.ch/streams/ldes-mow-register> <https://w3id.org/tree#member> <http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2> <http://www.cidoc-crm.org/cidoc-crm/P2_has_type> <http://data.lblod.info/concept-schemes/0e0897d1-5c74-47ae-9868-adecbde6f2f3>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2> <http://www.cidoc-crm.org/cidoc-crm/P43_has_dimension> <http://data.lblod.info/dimensions/673E2195C7E1A9B9F3B8666A>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/tribont/core#Shape>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2> <http://mu.semte.ch/vocabularies/core/uuid> "673E2195C7E1A9B9F3B8666B"^^<http://www.w3.org/2001/XMLSchema#string>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2> <http://purl.org/dc/terms/isVersionOf> <http://data.lblod.info/tribont-shapes/673E2195C7E1A9B9F3B8666B>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/2> <http://www.w3.org/ns/prov#generatedAtTime> "2024-11-22T07:12:35.574Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>.
<http://mu.semte.ch/streams/ldes-mow-register> <https://w3id.org/tree#member> <http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://purl.org/dc/terms/type> <http://data.vlaanderen.be/id/concept/Verkeersbordcatergorie/2982567006d9e19f04063df73123f56f40e3a28941031a7ba6e6667f64740fa9>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://data.vlaanderen.be/ns/mobiliteit#Verkeerstekenconcept>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://data.vlaanderen.be/ns/mobiliteit#Verkeersbordconcept>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://mu.semte.ch/vocabularies/core/uuid> "f9312556b1bdfbb278ec04033417152abbb254466df0069ff1894d0ea7a55482"^^<http://www.w3.org/2001/XMLSchema#string>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://data.lblod.info/vocabularies/mobiliteit/heeftGerelateerdVerkeersbordconcept> <http://data.vlaanderen.be/id/concept/Verkeersbordconcept/9cbedafef411f1c41317f8b9f4066ea6eccfc832edfc930d421725c3ebc5c167>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://www.w3.org/2004/02/skos/core#prefLabel> "A11"^^<http://www.w3.org/2001/XMLSchema#string>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://www.w3.org/2003/06/sw-vocab-status/ns#termStatus> <http://mow.lblod.info/VerkeersbordconceptStatus/f073030491519fd8e60e230713fb1eee4a2cc49c93e69e39bb00fc9924ae9edd>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <https://w3id.org/isCharacterisedBy#isCharacterisedBy> <http://data.lblod.info/tribont-shapes/673E2195C7E1A9B9F3B8666B>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://www.w3.org/2004/02/skos/core#topConceptOf> <http://data.vlaanderen.be/id/conceptscheme/Verkeersbordconcept>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://www.w3.org/2004/02/skos/core#scopeNote> "Uitweg op een kaai of een oever."^^<http://www.w3.org/2001/XMLSchema#string>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <https://data.vlaanderen.be/ns/mobiliteit#grafischeWeergave> <http://mobiliteit.vo.data.gift/images/46864672-e9e5-435a-9ab9-586ccdbd8149>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <https://data.vlaanderen.be/ns/mobiliteit#heeftOnderbordConcept> <http://data.vlaanderen.be/id/concept/Verkeersbordconcept/79d0bab2f07f815d457412b68edab1ba70ee15764d5fcbb531fa87ce24574da6>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <https://data.vlaanderen.be/ns/mobiliteit#heeftOnderbordConcept> <http://data.vlaanderen.be/id/concept/Verkeersbordconcept/061d2edb3caf482931ee7cea26f85d49538a5d4d0781872c0faad20328650beb>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://www.w3.org/2004/02/skos/core#inScheme> <http://data.vlaanderen.be/id/conceptscheme/Verkeersbordconcept>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://mu.semte.ch/vocabularies/ext/zonality> <http://lblod.data.gift/concepts/b651931b-923c-477c-8da9-fc7dd841fdcc>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://purl.org/dc/terms/isVersionOf> <http://data.vlaanderen.be/id/concept/Verkeersbordconcept/f9312556b1bdfbb278ec04033417152abbb254466df0069ff1894d0ea7a55482>.
<http://mu.semte.ch/services/ldes-time-fragmenter/versioned/3> <http://www.w3.org/ns/prov#generatedAtTime> "2024-11-22T07:12:35.575Z"^^<http://www.w3.org/2001/XMLSchema#dateTime>.

0 comments on commit 1ac9ef4

Please sign in to comment.