-
Notifications
You must be signed in to change notification settings - Fork 15
Literals
Wouter Beek edited this page Dec 30, 2015
·
1 revision
Observations:
- There are currently 3 compound term representations for literals:
literal(type(D, Lex))
literal(lang(Lang, Lex))
literal(Lex)
- Simple literals (variant 3) were removed in RDF 1.1. They are now (implicitly typed) XSD strings.
- RDF 1.1 specifies the values of language-tagged strings as pairs of lexical expression and language tag in that order.
Requirement:
-
rdf(S,P,O)
<=>rdf(S,P,X), X=O
(steadfastness)
Proposal:
- Two representations for literals:
-
TextOrValue^^Type
(value for known types) Text@Lang
-
- Output arg binds to above form.
- Input for query can only be one of the above.
- RDF assertion predicate converts literal object arguments according to the following table.
Prolog term | Prolog lexical form |
---|---|
Integer | Integer^^xsd:integer |
Float | Float^^xsd:double |
Atoms true and false
|
Atom^^xsd:boolean |
String^^KnownType |
Value^^KnownType |
Atom^^KnownType |
Value^^KnownType |
String^^rdf:langString |
error |
Atom^^rdf:langString |
error |
String^^UnknownType |
String^^UnknownType |
Atom^^UnknownType |
String^^UnknownType |
`[0 | 1]^^xsd:boolean` |
String |
String^^xsd:string |
String@Lang |
String@Lang |
Atom@Lang |
String@Lang |
Proposal:
- Add
rdf_canonical_literal(+Input, -Canonical)
- Add
rdf_match(S,P,Pattern,O)
- Add
rdf_match(S,P,Pattern,O,G)
.-
Pattern
is the first arg of currentliteral(Pattern, Literal)
, or -
Pattern
for matching language ranges:-
lang_matches(BasicLangRange)
(SPARQL 1.1 compatibility) -
basic_filtering(BasicLangRange)
(BCP 47 compatibility) -
extended_filtering(ExtendedLangRange)
(BCP 47 compatibility). - Notice that
lang_matches/1
andbasic_filtering/1
have the same behavior.
-
-
- Remove option
convert_typed_literal(:)
.
Datatype | Compatibility | Prolog type |
---|---|---|
owl:rational |
OWL 2 | rational OpenIssue2 |
owl:real |
OWL 2 | TODO |
rdf:HTML |
, RDF 1.1 | OpenIssue4 |
rdf:XMLLiteral |
OWL 2, RDF 1.1 | OpenIssue4 |
rdf:langString |
, RDF 1.1 | STRING@STRING |
xsd:NCName |
OWL 2, RDF 1.1 | TODO |
xsd:NMTOKEN |
OWL 2, RDF 1.1 | TODO |
xsd:Name |
OWL 2, RDf 1.1 | TODO |
xsd:anyURI |
OWL 2, RDF 1.1 | TODO |
xsd:base64Binary |
OWL 2, RDF 1.1 | TODO |
xsd:boolean |
OWL 2, RDF 1.1 |
'true' and 'false'
|
xsd:byte |
OWL 2, RDF 1.1 | between(-128,127) |
xsd:date |
OWL 1, RDF 1.1 | OpenIssue1 |
xsd:dateTime |
OWL 2, RDF 1.1 | OpenIssue1 |
xsd:dateTimeStamp |
OWL 2, RDF 1.1 | OpenIssue1 |
xsd:dayTimeDuration |
, RDF 1.1 | OpenIssue1 |
xsd:double |
OWL 2, RDF 1.1 | 64-bit float OpenIssue3 |
xsd:decimal |
OWL 2, RDF 1.1 | rational OpenIssue2 |
xsd:duration |
, RDF 1.1 | OpenIssue1 |
xsd:float |
OWL 2, RDF 1.1 | 32-bit float OpenIssue3 |
xsd:gDay |
OWL 1, RDF 1.1 | OpenIssue1 |
xsd:gMonth |
OWL 1, RDF 1.1 | OpenIssue1 |
xsd:gMonthDay |
OWL 1, RDF 1.1 | OpenIssue1 |
xsd:gYearMonth |
OWL 1, RDF 1.1 | OpenIssue1 |
xsd:gYear |
OWL 1, RDF 1.1 | OpenIssue1 |
xsd:hexBinary |
OWL 2, RDF 1.1 | TODO |
xsd:int |
OWL 2, RDF 1.1 | 32-bit integer |
xsd:integer |
OWL 2, RDF 1.1 | between(-∞,∞) OpenIssue2 |
xsd:language |
OWL 2, RDF 1.1 | TODO |
xsd:long |
OWL 2, RDF 1.1 | 64-bit integer |
xsd:negativeInteger |
OWL 2, RDF 1.1 | between(-∞,-1) OpenIssue2 |
xsd:nonNegativeInteger |
OWL 2, RDF 1.1 | between(0,∞) OpenIssue2 |
xsd:nonPositiveInteger |
OWL 2, RDF 1.1 | between(-∞,0) OpenIssue2 |
xsd:normalizedString |
OWL 2, RDF 1.1 | TODO |
xsd:positiveInteger |
OWL 2, RDF 1.1 | between(1,∞) OpenIssue2 |
xsd:short |
OWL 2, RDF 1.1 | between(-32768,32767) |
xsd:string |
OWL 2, RDF 1.1 | string |
xsd:time |
OWL 1, RDF 1.1 | OpenIssue1 |
xsd:token |
OWL 2, RDF 1.1 | TODO |
xsd:unsignedByte |
OWL 2, RDF 1.1 | between(0,255) |
xsd:unsignedInt |
OWL 2 RDF 1.1 | between(0,4294967295) |
xsd:unsignedLong |
OWL 2, RDF 1.1 | between(0,18446744073709551615) |
xsd:unsignedShort |
OWL 2, RDF 1.1 | between(0,65535) |
xsd:yearMonthDuration |
, RDF 1.1 | OpenIssue1 |
Open issues:
- Date-time, recurring date-time and duration representations.
Two places: internal value space and Prolog representation.
There are several options:
- Value space
- Canonical strings
- Time-stamp
- Prolog representation
- Canonical strings
- Time-stamp
- Compound term or dict. These are expensive to create and parse, so most likely not a good idea.
- Value space
- Countably infinite rationals/decimals/integers cannot be fully supported. An exception/warning may be thrown whenever a rational that is too lage is attempted to be asserted.
- Floating point numbers have values that are not covered by Prolog float: NaN, -0, +0, -∞, +∞.
- Should HTML/XML literals be stored as serializations or as DOM objects?
TODO:
- Add equivalence relation for each datatype.
- Add identity relation for each datatype.
- How does SPARQL 1.1 compare literals whose datatypes are strict subtypes?
E.g.,
"1"^^xsd:integer < "2"^^xsd:int
Observation:
- Literals are sorted, but the sorting has little relation to the SPARQL defined ordering. This implies we cannot optimize SPARQL queries that use comparison operators.