Skip to content

Commit dbc4060

Browse files
committed
Add base feature, mention escaping for tracing and remove outdated note
1 parent c4378d6 commit dbc4060

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/content/docs/installation/cli.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,6 @@ This results in the following traces being produced:
4848
│ └─ e(2, 3)
4949
└─ a(3)
5050
```
51+
If you want to trace facts that contain strings, you need to escape the strings properly.
52+
On Unix systems, both
53+
`--trace 'p("a","b")'` and `--trace "p(\"a\",\"b\")"` are recommended options.

src/content/docs/intro/tour.mdx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,15 @@ There are three basic forms for predicate names and abstract constant names in N
8989
@prefix wikidata: <http://www.wikidata.org/entity/> .
9090
```
9191

92-
Internally, Nemo treats all of these as IRIs. Prefixed names are expanded by concatenating prefix and local name (so `wikidata:Q1172264` would be another way of writing `<http://www.wikidata.org/entity/Q1172264>`, and simple string names are interpreted as *relative* IRIs (so `alice` would be another way of writing `<alice>`). You can write your predicate names and constants as you prefer, or use own prefixes as a mere way of adding some "namespaces" to your identifiers.
92+
Internally, Nemo treats all of these as IRIs. Prefixed names are expanded by concatenating prefix and local name (so `wikidata:Q1172264` would be another way of writing `<http://www.wikidata.org/entity/Q1172264>`), and simple string names are interpreted as *relative* IRIs (so `alice` would be another way of writing `<alice>`). You can write your predicate names and constants as you prefer, or use own prefixes as a mere way of adding some "namespaces" to your identifiers.
93+
If you want to use a default prefix for all non-absolute predicate names and non-absolute literals, use the `@base` notation:
94+
```
95+
@base <http://www.wikidata.org/entity/>.
96+
animal("dog","cat").
97+
<test>(<mouse>,<turtle>).
98+
```
99+
In the example above, the first fact will be expanded to `http://www.wikidata.org/entity/animal("http://www.wikidata.org/entity/dog","http://www.wikidata.org/entity/cat")`, while the second fact remains `test(mouse, turtle)` because both the predicate name and literals are absolute.
100+
93101

94102
### Values of other datatypes
95103

src/content/docs/reference/builtins.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ title: Builtin Functions
66
### General-purpose functions
77

88
The following functions can be meaningfully used on data of arbitrary types:
9-
- `DATATYPE` returns the datatype of the value. For IRIs (and constant), the type is reported as `http://www.w3.org/2001/XMLSchema#anyURI`. For language-tagged strings, the type is `http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`. As of Nemo v0.5.0, named nulls (blank nodes) have no defined type and `DATATYPE` does not return a valid result for such value. Moreover, the datatype is currently returned as a string, but will be an IRI in future versions ([#463](https://github.com/knowsys/nemo/issues/463)).
9+
- `DATATYPE` returns the datatype of the value. For IRIs (and constant), the type is reported as `http://www.w3.org/2001/XMLSchema#anyURI`. For language-tagged strings, the type is `http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`. As of Nemo v0.5.0, named nulls (blank nodes) have no defined type and `DATATYPE` does not return a valid result for such value.
1010
- `STR` returns the value as a string. For IRIs, this is the IRI string itself. For all other datatypes, this is the canonical form of the lexical value (without any datatype).
1111
- `fullStr` returns the value as a string that is formatted as in RDF. Such stings would also be correct ways of writing the value in a Nemo rules file (though there might be shorter ways due to Nemo's abbreviations).
1212

1313
Further, it is possible to compare any values using `=` or `!=`.
1414

1515
### Functions for strings
1616

17-
Nemo supports the following functions on strings.
17+
Nemo supports the following functions on plain strings and language tagged string. The behavior of the functions closely follows the [SPARQL recommendations](https://www.w3.org/TR/sparql11-query/#func-strings).
1818
- `STRLEN`: computes the (integer) length of a string
1919
- `UCASE` and `LCASE`: convert a string to upper case and lower case, respectively
2020
- `CONCAT`: creates a new string by concatenating the input strings
@@ -42,7 +42,9 @@ out(f"result: {?x + ?y}") :- in(?x, ?y) .
4242

4343
### Functions for language tagged strings
4444

45-
A language-tagged string is a value like `"Hello world"@en`. The function `LANG` can be used to extract the language tag (`en` in the example), whereas `STR` can be used to obtain the lexical value (`"Hello world"`).
45+
A language tagged string is a value like `"Hello world"@en`. The function `LANG` can be used to extract the language tag (`en` in the example), whereas `STR` can be used to obtain the lexical value (`"Hello world"`).
46+
All [string functions](#functions-for-strings) can be used on language tagged strings.
47+
Most importantly, binary functions return no result if the two language tags are not identical. For example, `CONTAINS("foo"@en, "foo"@gr)` will return no result. This behavior, including any edge cases are described in the [SPARQL recommendations](https://www.w3.org/TR/sparql11-query/#func-strings) in more detail.
4648

4749
### Functions for numbers
4850

0 commit comments

Comments
 (0)