-
Notifications
You must be signed in to change notification settings - Fork 0
/
trimming.rq
45 lines (34 loc) · 846 Bytes
/
trimming.rq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DELETE { ?s ?p ?o . }
INSERT { ?s ?p ?cleaned_with_lang . }
WHERE {
?s ?p ?o .
### Optional predicate filtering ###
#BIND(dcterms:title AS ?predicate)
### Optional fitlering by class of subject ###
#?s a foaf:Person .
### Optional filter by language tag ###
#FILTER(langMatches(?lang, 'cs'))
### Don't modify below this line ###
FILTER(isLiteral(?o))
FILTER(
IF(
BOUND(?predicate),
?p = ?predicate,
true
)
)
BIND('^\\s+(.*?)\\s*$|^(.*?)\\s+$'
AS ?regexp)
FILTER(REGEX(?o, ?regexp))
BIND(REPLACE(?o, ?regexp, '$1$2')
AS ?cleaned)
BIND(lang(?o) AS ?lang)
BIND(
IF(
?lang = '',
?cleaned,
STRLANG(?cleaned, ?lang))
AS ?cleaned_with_lang)
}