Fix IRI generation by sanitizing column names with spaces.
Regenerate graph-01.ttl and graph-02.ttl with the corrected output.
This commit is contained in:
parent
34754cc68a
commit
aa6f46bfc2
3 changed files with 326756 additions and 367995 deletions
344115
data/graph-01.ttl
344115
data/graph-01.ttl
File diff suppressed because it is too large
Load diff
350623
data/graph-02.ttl
350623
data/graph-02.ttl
File diff suppressed because it is too large
Load diff
|
|
@ -79,10 +79,19 @@ fn class_iri(table: &str) -> SimpleTerm<'static> {
|
|||
)
|
||||
}
|
||||
|
||||
fn sanitize_name(name: &str) -> String {
|
||||
let s: String = name
|
||||
.chars()
|
||||
.map(|c| if c.is_ascii_alphanumeric() || c == '-' { c } else { '_' })
|
||||
.collect();
|
||||
let s = s.replace("__", "_");
|
||||
s.trim_matches('_').to_string()
|
||||
}
|
||||
|
||||
fn column_iri(table: &str, column: &str) -> SimpleTerm<'static> {
|
||||
SimpleTerm::Iri(
|
||||
sophia::api::term::IriRef::new_unchecked(
|
||||
format!("{}{}#{}", BASE_IRI, table, column).into(),
|
||||
format!("{}{}#{}", BASE_IRI, table, sanitize_name(column)).into(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -90,7 +99,7 @@ fn column_iri(table: &str, column: &str) -> SimpleTerm<'static> {
|
|||
fn ref_iri(table: &str, fk_col: &str) -> SimpleTerm<'static> {
|
||||
SimpleTerm::Iri(
|
||||
sophia::api::term::IriRef::new_unchecked(
|
||||
format!("{}{}#ref-{}", BASE_IRI, table, fk_col).into(),
|
||||
format!("{}{}#ref-{}", BASE_IRI, table, sanitize_name(fk_col)).into(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue