sparql 3.1.6 → 3.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/sparql/algebra/aggregate.rb +1 -1
- data/lib/sparql/algebra/evaluatable.rb +4 -4
- data/lib/sparql/algebra/operator.rb +2 -2
- data/lib/sparql/algebra/operator/abs.rb +1 -1
- data/lib/sparql/algebra/operator/avg.rb +1 -1
- data/lib/sparql/algebra/operator/bnode.rb +1 -1
- data/lib/sparql/algebra/operator/ceil.rb +1 -1
- data/lib/sparql/algebra/operator/compare.rb +39 -40
- data/lib/sparql/algebra/operator/contains.rb +1 -1
- data/lib/sparql/algebra/operator/count.rb +1 -1
- data/lib/sparql/algebra/operator/datatype.rb +1 -1
- data/lib/sparql/algebra/operator/day.rb +1 -1
- data/lib/sparql/algebra/operator/divide.rb +1 -1
- data/lib/sparql/algebra/operator/encode_for_uri.rb +1 -1
- data/lib/sparql/algebra/operator/equal.rb +1 -1
- data/lib/sparql/algebra/operator/floor.rb +1 -1
- data/lib/sparql/algebra/operator/greater_than.rb +3 -2
- data/lib/sparql/algebra/operator/greater_than_or_equal.rb +2 -2
- data/lib/sparql/algebra/operator/group_concat.rb +1 -1
- data/lib/sparql/algebra/operator/hours.rb +1 -1
- data/lib/sparql/algebra/operator/iri.rb +1 -1
- data/lib/sparql/algebra/operator/is_blank.rb +1 -1
- data/lib/sparql/algebra/operator/is_iri.rb +1 -1
- data/lib/sparql/algebra/operator/is_literal.rb +1 -1
- data/lib/sparql/algebra/operator/is_numeric.rb +1 -1
- data/lib/sparql/algebra/operator/is_triple.rb +1 -1
- data/lib/sparql/algebra/operator/lang.rb +1 -1
- data/lib/sparql/algebra/operator/lang_matches.rb +1 -1
- data/lib/sparql/algebra/operator/lcase.rb +1 -1
- data/lib/sparql/algebra/operator/less_than.rb +3 -2
- data/lib/sparql/algebra/operator/less_than_or_equal.rb +2 -2
- data/lib/sparql/algebra/operator/max.rb +1 -1
- data/lib/sparql/algebra/operator/md5.rb +1 -1
- data/lib/sparql/algebra/operator/min.rb +1 -1
- data/lib/sparql/algebra/operator/minutes.rb +1 -1
- data/lib/sparql/algebra/operator/month.rb +1 -1
- data/lib/sparql/algebra/operator/multiply.rb +1 -1
- data/lib/sparql/algebra/operator/negate.rb +1 -1
- data/lib/sparql/algebra/operator/not.rb +1 -1
- data/lib/sparql/algebra/operator/not_equal.rb +3 -1
- data/lib/sparql/algebra/operator/now.rb +1 -1
- data/lib/sparql/algebra/operator/object.rb +1 -1
- data/lib/sparql/algebra/operator/order.rb +7 -1
- data/lib/sparql/algebra/operator/plus.rb +1 -1
- data/lib/sparql/algebra/operator/predicate.rb +1 -1
- data/lib/sparql/algebra/operator/rand.rb +1 -1
- data/lib/sparql/algebra/operator/regex.rb +1 -1
- data/lib/sparql/algebra/operator/replace.rb +1 -1
- data/lib/sparql/algebra/operator/round.rb +1 -1
- data/lib/sparql/algebra/operator/same_term.rb +1 -1
- data/lib/sparql/algebra/operator/sample.rb +1 -1
- data/lib/sparql/algebra/operator/seconds.rb +1 -1
- data/lib/sparql/algebra/operator/sha1.rb +1 -1
- data/lib/sparql/algebra/operator/sha256.rb +1 -1
- data/lib/sparql/algebra/operator/sha384.rb +1 -1
- data/lib/sparql/algebra/operator/sha512.rb +1 -1
- data/lib/sparql/algebra/operator/str.rb +1 -1
- data/lib/sparql/algebra/operator/strafter.rb +1 -1
- data/lib/sparql/algebra/operator/strbefore.rb +1 -1
- data/lib/sparql/algebra/operator/strdt.rb +1 -1
- data/lib/sparql/algebra/operator/strends.rb +1 -1
- data/lib/sparql/algebra/operator/strlang.rb +1 -1
- data/lib/sparql/algebra/operator/strlen.rb +1 -1
- data/lib/sparql/algebra/operator/strstarts.rb +1 -1
- data/lib/sparql/algebra/operator/struuid.rb +1 -1
- data/lib/sparql/algebra/operator/subject.rb +1 -1
- data/lib/sparql/algebra/operator/substr.rb +1 -1
- data/lib/sparql/algebra/operator/subtract.rb +1 -1
- data/lib/sparql/algebra/operator/sum.rb +1 -1
- data/lib/sparql/algebra/operator/timezone.rb +1 -1
- data/lib/sparql/algebra/operator/triple.rb +1 -1
- data/lib/sparql/algebra/operator/tz.rb +1 -1
- data/lib/sparql/algebra/operator/ucase.rb +1 -1
- data/lib/sparql/algebra/operator/uuid.rb +1 -1
- data/lib/sparql/algebra/operator/year.rb +1 -1
- data/lib/sparql/grammar/meta.rb +334 -138
- data/lib/sparql/grammar/parser11.rb +16 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcc81f10a741a9060299f9b3f54e1a7a35442fb7b68b7a79b2d1b67e16c0108a
|
4
|
+
data.tar.gz: aa6dd52a91d86b9a981edb5f4d56bdd0da288932ece265578ba773bb289a5fe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64669164cff7cdd9b1580bba3576247dafff7feef77ab63ba355afb51bded23a8f996ca952332abea8a4d06f8aca4ae5db25702a69748f8577aeedb720c5f788
|
7
|
+
data.tar.gz: d269e6c8edf25e5929876d292290257527f4bfe69def6fbe3e4500283a0ed2418ac4df5420a24fd35f826970ae63c3d679ba998d27184851cc8fe58648521df7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.7
|
@@ -44,7 +44,7 @@ module SPARQL; module Algebra
|
|
44
44
|
# Enumerable yielding evaluated operands
|
45
45
|
# @return [RDF::Term]
|
46
46
|
# @abstract
|
47
|
-
def apply(enum)
|
47
|
+
def apply(enum, **options)
|
48
48
|
raise NotImplementedError, "#{self.class}#apply(#{operands.map(&:class).join(', ')})"
|
49
49
|
end
|
50
50
|
|
@@ -15,16 +15,16 @@ module SPARQL; module Algebra
|
|
15
15
|
# @abstract
|
16
16
|
def evaluate(bindings, **options)
|
17
17
|
args = operands.map { |operand| operand.evaluate(bindings, depth: options[:depth].to_i + 1, **options) }
|
18
|
-
options[:memoize] ? memoize(*args) : apply(*args)
|
18
|
+
options[:memoize] ? memoize(*args, **options) : apply(*args, **options)
|
19
19
|
end
|
20
20
|
|
21
21
|
##
|
22
22
|
# @param [Array<RDF::Term>] operands
|
23
23
|
# evaluated operands
|
24
24
|
# @return [RDF::Term] the memoized result
|
25
|
-
def memoize(*operands)
|
25
|
+
def memoize(*operands, **options)
|
26
26
|
@cache ||= RDF::Util::Cache.new(options[:memoize].is_a?(Integer) ? options[:memoize] : -1)
|
27
|
-
@cache[operands] ||= apply(*operands)
|
27
|
+
@cache[operands] ||= apply(*operands, **options)
|
28
28
|
end
|
29
29
|
|
30
30
|
##
|
@@ -32,7 +32,7 @@ module SPARQL; module Algebra
|
|
32
32
|
# evaluated operands
|
33
33
|
# @return [RDF::Term]
|
34
34
|
# @abstract
|
35
|
-
def apply(*operands)
|
35
|
+
def apply(*operands, **options)
|
36
36
|
raise NotImplementedError, "#{self.class}#apply(#{operands.map(&:class).join(', ')})"
|
37
37
|
end
|
38
38
|
|
@@ -314,8 +314,8 @@ module SPARQL; module Algebra
|
|
314
314
|
# @param [Array<RDF::Term>] operands
|
315
315
|
# @return [RDF::Term]
|
316
316
|
# @see Operator#evaluate
|
317
|
-
def self.evaluate(*operands)
|
318
|
-
self.new(*operands).evaluate(RDF::Query::Solution.new)
|
317
|
+
def self.evaluate(*operands, **options)
|
318
|
+
self.new(*operands, **options).evaluate(RDF::Query::Solution.new, **options)
|
319
319
|
end
|
320
320
|
|
321
321
|
##
|
@@ -20,7 +20,7 @@ module SPARQL; module Algebra
|
|
20
20
|
# the operand
|
21
21
|
# @return [RDF::Literal] literal of same type
|
22
22
|
# @raise [TypeError] if the operand is not a numeric value
|
23
|
-
def apply(operand)
|
23
|
+
def apply(operand, **options)
|
24
24
|
case operand
|
25
25
|
when RDF::Literal::Numeric then operand.abs
|
26
26
|
else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
|
@@ -29,7 +29,7 @@ module SPARQL; module Algebra
|
|
29
29
|
# @param [Enumerable<Array<RDF::Term>>] enum
|
30
30
|
# enum of evaluated operand
|
31
31
|
# @return [RDF::Literal::Numeric] The numeric average of the terms
|
32
|
-
def apply(enum)
|
32
|
+
def apply(enum, **options)
|
33
33
|
# FIXME: we don't actually do anything with distinct
|
34
34
|
operands.shift if distinct = (operands.first == :distinct)
|
35
35
|
if enum.empty?
|
@@ -57,7 +57,7 @@ module SPARQL; module Algebra
|
|
57
57
|
# a query solution containing zero or more variable bindings
|
58
58
|
# @return [RDF::Node]
|
59
59
|
# @raise [TypeError] if the operand is not a simple literal or nil
|
60
|
-
def apply(literal, bindings)
|
60
|
+
def apply(literal, bindings, **options)
|
61
61
|
@@bnode_base ||= "b0"
|
62
62
|
@@bindings ||= bindings
|
63
63
|
@@bnodes ||= {}
|
@@ -20,7 +20,7 @@ module SPARQL; module Algebra
|
|
20
20
|
# the operand
|
21
21
|
# @return [RDF::Literal] literal of same type
|
22
22
|
# @raise [TypeError] if the operand is not a numeric value
|
23
|
-
def apply(operand)
|
23
|
+
def apply(operand, **options)
|
24
24
|
case operand
|
25
25
|
when RDF::Literal::Numeric then operand.ceil
|
26
26
|
else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
|
@@ -30,69 +30,68 @@ module SPARQL; module Algebra
|
|
30
30
|
# @param [RDF::Literal] right
|
31
31
|
# a literal
|
32
32
|
# @return [RDF::Literal::Integer] `-1`, `0`, or `1`
|
33
|
-
# @raise [TypeError] if either operand is not a
|
34
|
-
def apply(left, right)
|
33
|
+
# @raise [TypeError] if either operand is not a term
|
34
|
+
def apply(left, right, **options)
|
35
|
+
RDF::Literal(spaceship(left, right, **options))
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
# Define <=> as private for recursive statements
|
40
|
+
def spaceship(left, right, **options)
|
35
41
|
case
|
36
42
|
# @see https://www.w3.org/TR/sparql11-query/#OperatorMapping
|
37
43
|
# @see https://www.w3.org/TR/sparql11-query/#modOrderBy
|
38
44
|
when left.is_a?(RDF::Literal) && right.is_a?(RDF::Literal)
|
39
|
-
case
|
40
45
|
# @see https://www.w3.org/TR/xpath-functions/#string-compare
|
41
46
|
# @see https://www.w3.org/TR/xpath-functions/#comp.numeric
|
42
47
|
# @see https://www.w3.org/TR/xpath-functions/#op.boolean
|
43
48
|
# @see https://www.w3.org/TR/xpath-functions/#comp.duration.datetime
|
44
|
-
|
45
|
-
(left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric)) ||
|
46
|
-
(left.datatype == right.datatype && left.language == right.language)
|
47
|
-
RDF::Literal(left.send(self.class.const_get(:NAME), right))
|
48
|
-
|
49
|
-
# A plain literal is lower than an RDF literal with type xsd:string of the same lexical form.
|
50
|
-
when left.simple? && right.datatype == RDF::XSD.string && left.value == right.value
|
51
|
-
RDF::Literal(-1)
|
52
|
-
when right.simple? && left.datatype == RDF::XSD.string && right.value == left.value
|
53
|
-
RDF::Literal(-1)
|
54
|
-
|
55
|
-
else
|
56
|
-
left <=> right
|
57
|
-
end
|
58
|
-
|
49
|
+
left <=> right
|
59
50
|
when left.is_a?(RDF::URI) && right.is_a?(RDF::URI)
|
51
|
+
raise TypeError, "Comparing IRIs not supported" unless options[:order_by] || left == right
|
60
52
|
# Pairs of IRIs are ordered by comparing them as simple literals.
|
61
|
-
|
53
|
+
left.to_s <=> right.to_s
|
62
54
|
when left.is_a?(RDF::Node) && right.is_a?(RDF::Node)
|
55
|
+
raise TypeError, "Comparing Blank nodes not supported" unless options[:order_by] || left == right
|
63
56
|
# BNode comparison is undefined.
|
64
|
-
|
65
|
-
when left.is_a?(RDF::Statement) && right.is_a?(RDF::Statement)
|
66
|
-
RDF::Literal(RDF::Literal(left.to_s).send(self.class.const_get(:NAME), RDF::Literal(right.to_s)))
|
57
|
+
left == right ? 0 : 1
|
67
58
|
when left.nil? && right.nil?
|
68
|
-
|
69
|
-
|
59
|
+
0
|
60
|
+
|
61
|
+
when left.is_a?(RDF::Statement) && right.is_a?(RDF::Statement)
|
62
|
+
v = spaceship(left.subject, right.subject, **options)
|
63
|
+
v = spaceship(left.predicate, right.predicate, **options) if v == 0
|
64
|
+
v = spaceship(left.object, right.object, **options) if v == 0
|
65
|
+
v
|
66
|
+
when left.is_a?(RDF::Statement) && right.is_a?(RDF::Term)
|
67
|
+
raise TypeError, "Comparing statement with #{right.inspect}" unless options[:order_by]
|
68
|
+
1
|
69
|
+
when right.is_a?(RDF::Statement) && left.is_a?(RDF::Term)
|
70
|
+
raise TypeError, "Comparing statement with #{left.inspect}" unless options[:order_by]
|
71
|
+
-1
|
72
|
+
|
70
73
|
# SPARQL also fixes an order between some kinds of RDF terms that would not otherwise be ordered:
|
71
74
|
|
72
75
|
when left.nil? && !right.nil?
|
73
|
-
|
76
|
+
-1
|
74
77
|
when right.nil?
|
75
|
-
|
78
|
+
1
|
76
79
|
|
77
80
|
when left.is_a?(RDF::Node) && right.is_a?(RDF::Term)
|
78
|
-
|
81
|
+
raise TypeError, "Comparing Blank nodes not supported" unless options[:order_by]
|
82
|
+
# Nodes lower than other terms
|
83
|
+
-1
|
79
84
|
when right.is_a?(RDF::Node) && left.is_a?(RDF::Term)
|
80
|
-
|
81
|
-
|
82
|
-
when left.is_a?(RDF::Statement) && right.is_a?(RDF::Term)
|
83
|
-
RDF::Literal(-1)
|
84
|
-
when right.is_a?(RDF::Statement) && left.is_a?(RDF::Term)
|
85
|
-
RDF::Literal(1)
|
86
|
-
|
87
|
-
when left.is_a?(RDF::Node) && right.is_a?(RDF::URI)
|
88
|
-
RDF::Literal(-1)
|
89
|
-
when right.is_a?(RDF::Node) && left.is_a?(RDF::URI)
|
90
|
-
RDF::Literal(1)
|
85
|
+
raise TypeError, "Comparing Blank nodes not supported" unless options[:order_by]
|
86
|
+
1
|
91
87
|
|
92
88
|
when left.is_a?(RDF::URI) && right.is_a?(RDF::Term)
|
93
|
-
|
89
|
+
raise TypeError, "Comparing IRIs not supported" unless options[:order_by]
|
90
|
+
# IRIs lower than terms other than nodes
|
91
|
+
-1
|
94
92
|
when right.is_a?(RDF::URI) && left.is_a?(RDF::Term)
|
95
|
-
|
93
|
+
raise TypeError, "Comparing IRIs not supported" unless options[:order_by]
|
94
|
+
1
|
96
95
|
else raise TypeError, "expected two RDF::Term operands, but got #{left.inspect} and #{right.inspect}"
|
97
96
|
end
|
98
97
|
end
|
@@ -31,7 +31,7 @@ module SPARQL; module Algebra
|
|
31
31
|
# a literal
|
32
32
|
# @return [RDF::Literal::Boolean]
|
33
33
|
# @raise [TypeError] if operands are not compatible
|
34
|
-
def apply(left, right)
|
34
|
+
def apply(left, right, **options)
|
35
35
|
case
|
36
36
|
when !left.compatible?(right)
|
37
37
|
raise TypeError, "expected two RDF::Literal operands, but got #{left.inspect} and #{right.inspect}"
|
@@ -22,7 +22,7 @@ module SPARQL; module Algebra
|
|
22
22
|
# @param [Enumerable<Array<RDF::Term>>] enum
|
23
23
|
# enum of evaluated operand
|
24
24
|
# @return [RDF::Literal::Integer] The number of non-error terms in the multiset
|
25
|
-
def apply(enum)
|
25
|
+
def apply(enum, **options)
|
26
26
|
RDF::Literal(enum.length)
|
27
27
|
end
|
28
28
|
end # Count
|
@@ -27,7 +27,7 @@ module SPARQL; module Algebra
|
|
27
27
|
# a typed or simple literal
|
28
28
|
# @return [RDF::URI] the datatype IRI, or `xsd:string` for simple literals
|
29
29
|
# @raise [TypeError] if the operand is not a typed or simple literal
|
30
|
-
def apply(literal)
|
30
|
+
def apply(literal, **options)
|
31
31
|
case literal
|
32
32
|
when RDF::Literal then literal.datatype
|
33
33
|
else raise TypeError, "expected an RDF::Literal, but got #{literal.inspect}"
|
@@ -22,7 +22,7 @@ module SPARQL; module Algebra
|
|
22
22
|
# the operand
|
23
23
|
# @return [RDF::Literal]
|
24
24
|
# @raise [TypeError] if the operand is not a simple literal
|
25
|
-
def apply(operand)
|
25
|
+
def apply(operand, **options)
|
26
26
|
raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime)
|
27
27
|
RDF::Literal(operand.object.day)
|
28
28
|
end
|
@@ -21,7 +21,7 @@ module SPARQL; module Algebra
|
|
21
21
|
# a numeric literal
|
22
22
|
# @return [RDF::Literal::Numeric]
|
23
23
|
# @raise [TypeError] if either operand is not a numeric literal
|
24
|
-
def apply(left, right)
|
24
|
+
def apply(left, right, **options)
|
25
25
|
case
|
26
26
|
when left.is_a?(RDF::Literal::Numeric) && right.is_a?(RDF::Literal::Numeric)
|
27
27
|
# For xsd:decimal and xsd:integer operands, if the divisor is
|
@@ -27,7 +27,7 @@ module SPARQL; module Algebra
|
|
27
27
|
# the operand
|
28
28
|
# @return [RDF::Literal] literal of same type
|
29
29
|
# @raise [TypeError] if the operand is not a literal value
|
30
|
-
def apply(operand)
|
30
|
+
def apply(operand, **options)
|
31
31
|
case operand
|
32
32
|
when RDF::Literal then RDF::Literal(CGI.escape(operand.to_s))
|
33
33
|
else raise TypeError, "expected an RDF::Literal, but got #{operand.inspect}"
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# @raise [TypeError] if either operand is not an RDF term or operands are not comperable
|
27
27
|
#
|
28
28
|
# @see RDF::Term#==
|
29
|
-
def apply(term1, term2)
|
29
|
+
def apply(term1, term2, **options)
|
30
30
|
term1 = term1.dup.extend(RDF::TypeCheck)
|
31
31
|
term2 = term2.dup.extend(RDF::TypeCheck)
|
32
32
|
RDF::Literal(term1 == term2)
|
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
|
|
24
24
|
# the operand
|
25
25
|
# @return [RDF::Literal] literal of same type
|
26
26
|
# @raise [TypeError] if the operand is not a numeric value
|
27
|
-
def apply(operand)
|
27
|
+
def apply(operand, **options)
|
28
28
|
case operand
|
29
29
|
when RDF::Literal::Numeric then operand.floor
|
30
30
|
else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
|
@@ -24,8 +24,9 @@ module SPARQL; module Algebra
|
|
24
24
|
# a literal
|
25
25
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
26
26
|
# @raise [TypeError] if either operand is not a literal
|
27
|
-
def apply(left, right)
|
28
|
-
super
|
27
|
+
def apply(left, right, **options)
|
28
|
+
#require 'byebug'; byebug if super == RDF::Literal(1)
|
29
|
+
RDF::Literal(super == RDF::Literal(1))
|
29
30
|
end
|
30
31
|
end # GreaterThan
|
31
32
|
end # Operator
|
@@ -25,8 +25,8 @@ module SPARQL; module Algebra
|
|
25
25
|
# a literal
|
26
26
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
27
27
|
# @raise [TypeError] if either operand is not a literal
|
28
|
-
def apply(left, right)
|
29
|
-
super
|
28
|
+
def apply(left, right, **options)
|
29
|
+
RDF::Literal(super >= RDF::Literal(0))
|
30
30
|
end
|
31
31
|
end # GreaterThanOrEqual
|
32
32
|
end # Operator
|
@@ -50,7 +50,7 @@ module SPARQL; module Algebra
|
|
50
50
|
# enum of evaluated operand
|
51
51
|
# @return [RDF::Term] An arbitrary term
|
52
52
|
# @raise [TypeError] If enum is empty
|
53
|
-
def apply(enum, separator)
|
53
|
+
def apply(enum, separator, **options)
|
54
54
|
RDF::Literal(enum.flatten.map(&:to_s).join(separator.to_s))
|
55
55
|
end
|
56
56
|
end # GroupConcat
|
@@ -22,7 +22,7 @@ module SPARQL; module Algebra
|
|
22
22
|
# the operand
|
23
23
|
# @return [RDF::Literal]
|
24
24
|
# @raise [TypeError] if the operand is not a simple literal
|
25
|
-
def apply(operand)
|
25
|
+
def apply(operand, **options)
|
26
26
|
raise TypeError, "expected an RDF::Literal::DateTime, but got #{operand.inspect}" unless operand.is_a?(RDF::Literal::DateTime)
|
27
27
|
RDF::Literal(operand.object.hour)
|
28
28
|
end
|
@@ -29,7 +29,7 @@ module SPARQL; module Algebra
|
|
29
29
|
# a simple literal
|
30
30
|
# @return [RDF::URI]
|
31
31
|
# @raise [TypeError] if the operand is not a simple literal
|
32
|
-
def apply(literal)
|
32
|
+
def apply(literal, **options)
|
33
33
|
raise TypeError, "expected an simple literal, but got #{literal.inspect}" unless literal.literal? && literal.simple?
|
34
34
|
base = Operator.base_uri || RDF::URI("")
|
35
35
|
base.join(literal.to_s)
|
@@ -23,7 +23,7 @@ module SPARQL; module Algebra
|
|
23
23
|
# an RDF term
|
24
24
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
25
25
|
# @raise [TypeError] if the operand is not an RDF term
|
26
|
-
def apply(term)
|
26
|
+
def apply(term, **options)
|
27
27
|
case term
|
28
28
|
when RDF::Node then RDF::Literal::TRUE
|
29
29
|
when RDF::Term then RDF::Literal::FALSE
|
@@ -23,7 +23,7 @@ module SPARQL; module Algebra
|
|
23
23
|
# an RDF term
|
24
24
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
25
25
|
# @raise [TypeError] if the operand is not an RDF term
|
26
|
-
def apply(term)
|
26
|
+
def apply(term, **options)
|
27
27
|
case term
|
28
28
|
when RDF::URI then RDF::Literal::TRUE
|
29
29
|
when RDF::Term then RDF::Literal::FALSE
|
@@ -24,7 +24,7 @@ module SPARQL; module Algebra
|
|
24
24
|
# an RDF term
|
25
25
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
26
26
|
# @raise [TypeError] if the operand is not an RDF term
|
27
|
-
def apply(term)
|
27
|
+
def apply(term, **options)
|
28
28
|
case term
|
29
29
|
when RDF::Literal then RDF::Literal::TRUE
|
30
30
|
when RDF::Term then RDF::Literal::FALSE
|
@@ -26,7 +26,7 @@ module SPARQL; module Algebra
|
|
26
26
|
# an RDF term
|
27
27
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
28
28
|
# @raise [TypeError] if the operand is not an RDF term
|
29
|
-
def apply(term)
|
29
|
+
def apply(term, **options)
|
30
30
|
case term
|
31
31
|
when RDF::Literal::NonPositiveInteger then RDF::Literal::FALSE
|
32
32
|
when RDF::Literal::NonNegativeInteger then RDF::Literal::FALSE
|
@@ -18,7 +18,7 @@ module SPARQL; module Algebra
|
|
18
18
|
# an RDF term
|
19
19
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
20
20
|
# @raise [TypeError] if the operand is not an RDF term
|
21
|
-
def apply(term)
|
21
|
+
def apply(term, **options)
|
22
22
|
case term
|
23
23
|
when RDF::Statement then RDF::Literal::TRUE
|
24
24
|
when RDF::Term then RDF::Literal::FALSE
|
@@ -18,7 +18,7 @@ module SPARQL; module Algebra
|
|
18
18
|
# a literal
|
19
19
|
# @return [RDF::Literal] a simple literal
|
20
20
|
# @raise [TypeError] if the operand is not a literal
|
21
|
-
def apply(literal)
|
21
|
+
def apply(literal, **options)
|
22
22
|
case literal
|
23
23
|
when RDF::Literal then RDF::Literal(literal.language.to_s)
|
24
24
|
else raise TypeError, "expected an RDF::Literal, but got #{literal.inspect}"
|
@@ -27,7 +27,7 @@ module SPARQL; module Algebra
|
|
27
27
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
28
28
|
# @raise [TypeError] if either operand is unbound
|
29
29
|
# @raise [TypeError] if either operand is not a simple literal
|
30
|
-
def apply(language_tag, language_range)
|
30
|
+
def apply(language_tag, language_range, **options)
|
31
31
|
raise TypeError, "expected a plain RDF::Literal for language_tag, but got #{language_tag.inspect}" unless language_tag.is_a?(RDF::Literal) && language_tag.simple?
|
32
32
|
language_tag = language_tag.to_s.downcase
|
33
33
|
|
@@ -20,7 +20,7 @@ module SPARQL; module Algebra
|
|
20
20
|
# the operand
|
21
21
|
# @return [RDF::Literal] literal of same type
|
22
22
|
# @raise [TypeError] if the operand is not a literal value
|
23
|
-
def apply(operand)
|
23
|
+
def apply(operand, **options)
|
24
24
|
case operand
|
25
25
|
when RDF::Literal then RDF::Literal(operand.to_s.downcase, datatype: operand.datatype, language: operand.language)
|
26
26
|
else raise TypeError, "expected an RDF::Literal::Numeric, but got #{operand.inspect}"
|
@@ -24,8 +24,9 @@ module SPARQL; module Algebra
|
|
24
24
|
# a literal
|
25
25
|
# @return [RDF::Literal::Boolean] `true` or `false`
|
26
26
|
# @raise [TypeError] if either operand is not a literal
|
27
|
-
def apply(left, right)
|
28
|
-
super
|
27
|
+
def apply(left, right, **options)
|
28
|
+
#require 'byebug'; byebug if super == RDF::Literal(-1)
|
29
|
+
RDF::Literal(super == RDF::Literal(-1))
|
29
30
|
end
|
30
31
|
end # LessThan
|
31
32
|
end # Operator
|