Skip to content

Commit

Permalink
Add opt_fix query to remove newline chars from text
Browse files Browse the repository at this point in the history
Recognizes CR and/or LF and replaces each continuous group with
a single space.
  • Loading branch information
allenbaron committed Jan 9, 2025
1 parent 843b282 commit 831a553
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/sparql/update/opt_fix_newline_in_text.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Replace newlines (/n, /r, or /r/n) in text with spaces

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>

DELETE {
?iri ?pred ?text .
?axiom owl:annotatedTarget ?text .
}
INSERT {
?iri ?pred ?text_new .
?axiom owl:annotatedTarget ?text_new .
}
WHERE {
VALUES ?pred {
rdfs:label
obo:IAO_0000115
oboInOwl:hasExactSynonym
oboInOwl:hasBroadSynonym
oboInOwl:hasNarrowSynonym
oboInOwl:hasRelatedSynonym
rdfs:comment
}
?iri ?pred ?text .

OPTIONAL {
?axiom a owl:Axiom ;
owl:annotatedSource ?iri ;
owl:annotatedProperty ?pred ;
owl:annotatedTarget ?text .
}

FILTER(REGEX(?text, "[\\r\\n]"))
BIND((REPLACE(?text, "[\\r\\n]+", " ")) AS ?text_new)

FILTER NOT EXISTS { ?iri owl:deprecated true }
}

0 comments on commit 831a553

Please sign in to comment.