rdf-n3 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +0 -1
- data/History.md +6 -1
- data/README.md +15 -1
- data/Rakefile +1 -28
- data/VERSION +1 -1
- data/lib/rdf/n3/format.rb +6 -2
- data/lib/rdf/n3/reader/bnf-rules.n3 +134 -0
- data/lib/rdf/n3/reader/n3-selectors.n3 +0 -0
- data/lib/rdf/n3/reader/n3.n3 +261 -0
- data/lib/rdf/n3/reader/parser.rb +1 -1
- data/rdf-n3.gemspec +411 -603
- data/script/build_meta +20 -13
- data/script/parse +2 -2
- data/script/yard-to-rubyforge +2 -0
- data/spec/.gitignore +1 -0
- data/spec/cwm_spec.rb +8 -13
- data/spec/cwm_test.rb +76 -0
- data/spec/format_spec.rb +4 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/swap_spec.rb +35 -31
- data/spec/swap_test.rb +79 -0
- data/spec/turtle_spec.rb +13 -19
- data/spec/turtle_test.rb +98 -0
- data/spec/writer_spec.rb +7 -10
- metadata +38 -228
- data/.gitignore +0 -5
- data/spec/rdf_helper.rb +0 -226
- data/spec/swap_test/animal.rdf +0 -17
- data/spec/swap_test/anon-prop.n3 +0 -14
- data/spec/swap_test/anonymous_loop.n3 +0 -2
- data/spec/swap_test/contexts.n3 +0 -16
- data/spec/swap_test/daml-pref.n3 +0 -10
- data/spec/swap_test/i18n/hiragana.n3 +0 -22
- data/spec/swap_test/i18n/n3string.n3 +0 -4
- data/spec/swap_test/list/itemType.rdf +0 -12
- data/spec/swap_test/lists-simple.n3 +0 -40
- data/spec/swap_test/lists.n3 +0 -35
- data/spec/swap_test/n3/n3parser.tests_n3_10001.nt +0 -3
- data/spec/swap_test/n3/n3parser.tests_n3_10002.nt +0 -7
- data/spec/swap_test/n3/n3parser.tests_n3_10003.nt +0 -3
- data/spec/swap_test/n3/n3parser.tests_n3_10004.nt +0 -119
- data/spec/swap_test/n3/n3parser.tests_n3_10005.nt +0 -3
- data/spec/swap_test/n3/n3parser.tests_n3_10006.nt +0 -225
- data/spec/swap_test/n3/n3parser.tests_n3_10007.nt +0 -79
- data/spec/swap_test/n3/n3parser.tests_n3_10008.nt +0 -5
- data/spec/swap_test/n3/n3parser.tests_n3_10009.nt +0 -13
- data/spec/swap_test/n3/n3parser.tests_n3_10010.nt +0 -21
- data/spec/swap_test/n3/n3parser.tests_n3_10011.nt +0 -9
- data/spec/swap_test/n3/n3parser.tests_n3_10012.nt +0 -53
- data/spec/swap_test/n3/n3parser.tests_n3_10013.nt +0 -19
- data/spec/swap_test/n3/n3parser.tests_n3_10014.nt +0 -103
- data/spec/swap_test/n3/n3parser.tests_n3_10015.nt +0 -103
- data/spec/swap_test/n3/n3parser.tests_n3_10016.nt +0 -3
- data/spec/swap_test/n3/n3parser.tests_n3_10017.nt +0 -151
- data/spec/swap_test/n3/n3parser.tests_n3_10018.nt +0 -9
- data/spec/swap_test/n3/n3parser.tests_n3_10019.nt +0 -3
- data/spec/swap_test/n3/n3parser.tests_n3_10020.nt +0 -13
- data/spec/swap_test/n3parser.tests +0 -160
- data/spec/swap_test/n3parser.yml +0 -174
- data/spec/swap_test/nodeID/classes.n3 +0 -9
- data/spec/swap_test/nodeID/classes.ref.rdf +0 -15
- data/spec/swap_test/nodeID/ex1.rdf +0 -15
- data/spec/swap_test/norm/fix.rdf +0 -33
- data/spec/swap_test/owl-ex.rdf +0 -150
- data/spec/swap_test/ref/animal.n3 +0 -11
- data/spec/swap_test/ref/anon-prop-1.n3 +0 -8
- data/spec/swap_test/ref/anonymous_loop.ref +0 -7
- data/spec/swap_test/ref/bnode.n3 +0 -6
- data/spec/swap_test/ref/bnode.rdf +0 -16
- data/spec/swap_test/ref/colon-in-uri.n3 +0 -15
- data/spec/swap_test/ref/contexts-1.n3 +0 -12
- data/spec/swap_test/ref/daml-ex.n3 +0 -103
- data/spec/swap_test/ref/daml-ont.n3 +0 -289
- data/spec/swap_test/ref/djb1a-out.n3 +0 -4
- data/spec/swap_test/ref/dot-dash.n3 +0 -8
- data/spec/swap_test/ref/in-xml-t.n3 +0 -4
- data/spec/swap_test/ref/itemType.n3 +0 -9
- data/spec/swap_test/ref/keywords1.n3 +0 -11
- data/spec/swap_test/ref/keywords2.n3 +0 -11
- data/spec/swap_test/ref/lists-simple-1.rdf +0 -108
- data/spec/swap_test/ref/lists.n3 +0 -43
- data/spec/swap_test/ref/lstring-out.n3 +0 -20
- data/spec/swap_test/ref/n3string.n3 +0 -13
- data/spec/swap_test/ref/no-last-nl.n3 +0 -3
- data/spec/swap_test/ref/numbers.n3 +0 -18
- data/spec/swap_test/ref/path1.n3 +0 -8
- data/spec/swap_test/ref/path2.n3 +0 -39
- data/spec/swap_test/ref/prefix1.rdf +0 -31
- data/spec/swap_test/ref/prefix2.rdf +0 -33
- data/spec/swap_test/ref/prefix3.rdf +0 -31
- data/spec/swap_test/ref/rdf-redefine.rdf +0 -11
- data/spec/swap_test/ref/reluri-1.rdf +0 -18
- data/spec/swap_test/ref/strquot.n3 +0 -22
- data/spec/swap_test/ref/strquot_a.n3 +0 -23
- data/spec/swap_test/ref/xml-base3.n3 +0 -5
- data/spec/swap_test/ref/xml-redefine.rdf +0 -20
- data/spec/swap_test/ref/xml-redefine2.rdf +0 -23
- data/spec/swap_test/ref/xml-syntax-basic-serialization.rdf +0 -10
- data/spec/swap_test/ref/xmllit.nt +0 -3
- data/spec/swap_test/regression.n3 +0 -231
- data/spec/swap_test/regression.yml +0 -256
- data/spec/swap_test/reluri-1.n3 +0 -10
- data/spec/swap_test/strquot.n3 +0 -23
- data/spec/swap_test/syntax/colon-in-uri.rdf +0 -27
- data/spec/swap_test/syntax/djb1a.n3 +0 -3
- data/spec/swap_test/syntax/dot-dash.n3 +0 -15
- data/spec/swap_test/syntax/equals1.n3 +0 -1
- data/spec/swap_test/syntax/equals2.n3 +0 -1
- data/spec/swap_test/syntax/keywords1.n3 +0 -17
- data/spec/swap_test/syntax/keywords2.n3 +0 -18
- data/spec/swap_test/syntax/lstring.n3 +0 -26
- data/spec/swap_test/syntax/neg-formula-predicate.n3 +0 -1
- data/spec/swap_test/syntax/neg-keywords3.n3 +0 -1
- data/spec/swap_test/syntax/neg-literal-predicate.n3 +0 -1
- data/spec/swap_test/syntax/neg-single-quote.n3 +0 -1
- data/spec/swap_test/syntax/neg-thisadoc.n3 +0 -1
- data/spec/swap_test/syntax/no-last-nl.n3 +0 -2
- data/spec/swap_test/syntax/numbers.n3 +0 -26
- data/spec/swap_test/syntax/path1.n3 +0 -23
- data/spec/swap_test/syntax/path2.n3 +0 -31
- data/spec/swap_test/syntax/qvars1.n3 +0 -19
- data/spec/swap_test/syntax/qvars2.n3 +0 -19
- data/spec/swap_test/syntax/this-quantifiers.n3 +0 -164
- data/spec/swap_test/syntax/this-rules.n3 +0 -43
- data/spec/swap_test/syntax/too-nested.n3 +0 -25
- data/spec/swap_test/syntax/trailing-semicolon.n3 +0 -12
- data/spec/swap_test/syntax/zero-objects.n3 +0 -1
- data/spec/swap_test/syntax/zero-predicates.n3 +0 -3
- data/spec/swap_test/tests-work.txt +0 -25
- data/spec/swap_test/xml-syntax/basic-serialization.n3 +0 -8
- data/spec/swap_test/xml-syntax/in-xml.xml +0 -13
- data/spec/swap_test/xml-syntax/non-ascii-pred.rdf +0 -14
- data/spec/swap_test/xml-syntax/rdf_prefix.n3 +0 -2
- data/spec/swap_test/xml-syntax/xml_prefix.n3 +0 -7
- data/spec/swap_test/xml-syntax/xml_prefix2.n3 +0 -9
- data/spec/swap_test/xml-syntax/xmlbase3.rdf +0 -10
- data/spec/swap_test/xml-syntax/xmllit.rdf +0 -33
- data/spec/turtle/README.txt +0 -20
- data/spec/turtle/bad-00.ttl +0 -2
- data/spec/turtle/bad-01.ttl +0 -3
- data/spec/turtle/bad-02.ttl +0 -3
- data/spec/turtle/bad-03.ttl +0 -3
- data/spec/turtle/bad-04.ttl +0 -3
- data/spec/turtle/bad-05.ttl +0 -4
- data/spec/turtle/bad-06.ttl +0 -3
- data/spec/turtle/bad-07.ttl +0 -4
- data/spec/turtle/bad-08.ttl +0 -2
- data/spec/turtle/bad-09.ttl +0 -3
- data/spec/turtle/bad-10.ttl +0 -3
- data/spec/turtle/bad-11.ttl +0 -3
- data/spec/turtle/bad-12.ttl +0 -3
- data/spec/turtle/bad-13.ttl +0 -3
- data/spec/turtle/bad-14.ttl +0 -6
- data/spec/turtle/manifest-bad.ttl +0 -88
- data/spec/turtle/manifest-bad.yml +0 -91
- data/spec/turtle/manifest.ttl +0 -215
- data/spec/turtle/manifest.yml +0 -187
- data/spec/turtle/rdf-schema.out +0 -126
- data/spec/turtle/rdf-schema.ttl +0 -156
- data/spec/turtle/rdfq-results.out +0 -36
- data/spec/turtle/rdfq-results.ttl +0 -39
- data/spec/turtle/rdfs-namespace.out +0 -131
- data/spec/turtle/rdfs-namespace.ttl +0 -160
- data/spec/turtle/test-00.out +0 -1
- data/spec/turtle/test-00.ttl +0 -2
- data/spec/turtle/test-01.out +0 -3
- data/spec/turtle/test-01.ttl +0 -7
- data/spec/turtle/test-02.out +0 -3
- data/spec/turtle/test-02.ttl +0 -5
- data/spec/turtle/test-03.out +0 -3
- data/spec/turtle/test-03.ttl +0 -5
- data/spec/turtle/test-04.out +0 -2
- data/spec/turtle/test-04.ttl +0 -4
- data/spec/turtle/test-05.out +0 -4
- data/spec/turtle/test-05.ttl +0 -4
- data/spec/turtle/test-06.out +0 -1
- data/spec/turtle/test-06.ttl +0 -3
- data/spec/turtle/test-07.out +0 -5
- data/spec/turtle/test-07.ttl +0 -3
- data/spec/turtle/test-08.out +0 -1
- data/spec/turtle/test-08.ttl +0 -3
- data/spec/turtle/test-09.out +0 -4
- data/spec/turtle/test-09.ttl +0 -10
- data/spec/turtle/test-10.out +0 -5
- data/spec/turtle/test-10.ttl +0 -5
- data/spec/turtle/test-11.out +0 -4
- data/spec/turtle/test-11.ttl +0 -10
- data/spec/turtle/test-12.out +0 -4
- data/spec/turtle/test-12.ttl +0 -9
- data/spec/turtle/test-13.out +0 -2
- data/spec/turtle/test-13.ttl +0 -7
- data/spec/turtle/test-14.out +0 -10000
- data/spec/turtle/test-14.ttl +0 -10002
- data/spec/turtle/test-15.out +0 -10000
- data/spec/turtle/test-15.ttl +0 -3
- data/spec/turtle/test-16.out +0 -10000
- data/spec/turtle/test-16.ttl +0 -10002
- data/spec/turtle/test-17.out +0 -1
- data/spec/turtle/test-17.ttl +0 -6
- data/spec/turtle/test-18.out +0 -2
- data/spec/turtle/test-18.ttl +0 -9
- data/spec/turtle/test-19.out +0 -1
- data/spec/turtle/test-19.ttl +0 -4
- data/spec/turtle/test-20.out +0 -2
- data/spec/turtle/test-20.ttl +0 -6
- data/spec/turtle/test-21.out +0 -3
- data/spec/turtle/test-21.ttl +0 -4
- data/spec/turtle/test-22.out +0 -3
- data/spec/turtle/test-22.ttl +0 -4
- data/spec/turtle/test-23.out +0 -1
- data/spec/turtle/test-23.ttl +0 -3
- data/spec/turtle/test-24.out +0 -2
- data/spec/turtle/test-24.ttl +0 -3
- data/spec/turtle/test-25.out +0 -7
- data/spec/turtle/test-25.ttl +0 -14
- data/spec/turtle/test-26.out +0 -1
- data/spec/turtle/test-26.ttl +0 -4
- data/spec/turtle/test-27.out +0 -1
- data/spec/turtle/test-27.ttl +0 -5
- data/spec/turtle/test-28-out.ttl +0 -6
- data/spec/turtle/test-28.out +0 -22
- data/spec/turtle/test-28.ttl +0 -22
- data/spec/turtle/test-29.out +0 -1
- data/spec/turtle/test-29.ttl +0 -1
- data/spec/turtle/test-30.out +0 -5
- data/spec/turtle/test-30.ttl +0 -12
data/spec/rdf_helper.rb
DELETED
@@ -1,226 +0,0 @@
|
|
1
|
-
autoload :YAML, "yaml"
|
2
|
-
autoload :CGI, 'cgi'
|
3
|
-
|
4
|
-
RDFCORE_DIR = File.join(File.dirname(__FILE__), 'rdfcore')
|
5
|
-
RDFCORE_TEST = "http://www.w3.org/2000/10/rdf-tests/rdfcore/Manifest.rdf"
|
6
|
-
SWAP_DIR = File.join(File.dirname(__FILE__), 'swap_test')
|
7
|
-
SWAP_TEST = "http://www.w3.org/2000/10/swap/test/n3parser.tests"
|
8
|
-
CWM_TEST = "http://www.w3.org/2000/10/swap/test/regression.n3"
|
9
|
-
TURTLE_DIR = File.join(File.dirname(__FILE__), 'turtle')
|
10
|
-
TURTLE_TEST = "http://www.w3.org/2001/sw/DataAccess/df1/tests/manifest.ttl"
|
11
|
-
TURTLE_BAD_TEST = "http://www.w3.org/2001/sw/DataAccess/df1/tests/manifest-bad.ttl"
|
12
|
-
|
13
|
-
module RdfHelper
|
14
|
-
# Class representing test cases in format http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#
|
15
|
-
|
16
|
-
class TestCase
|
17
|
-
class MF < RDF::Vocabulary("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#"); end
|
18
|
-
class QT < RDF::Vocabulary("http://www.w3.org/2001/sw/DataAccess/tests/test-query#"); end
|
19
|
-
|
20
|
-
attr_accessor :about
|
21
|
-
attr_accessor :approval
|
22
|
-
attr_accessor :conclusionDocument
|
23
|
-
attr_accessor :data
|
24
|
-
attr_accessor :description
|
25
|
-
attr_accessor :discussion
|
26
|
-
attr_accessor :document
|
27
|
-
attr_accessor :entailmentRules
|
28
|
-
attr_accessor :inputDocument
|
29
|
-
attr_accessor :issue
|
30
|
-
attr_accessor :name
|
31
|
-
attr_accessor :outputDocument
|
32
|
-
attr_accessor :premiseDocument
|
33
|
-
attr_accessor :rdf_type
|
34
|
-
attr_accessor :status
|
35
|
-
attr_accessor :warning
|
36
|
-
attr_accessor :parser
|
37
|
-
attr_accessor :compare
|
38
|
-
attr_accessor :debug
|
39
|
-
|
40
|
-
def initialize(statements, uri_prefix, test_dir, options = {})
|
41
|
-
case options[:test_type]
|
42
|
-
when :mf
|
43
|
-
parse_mf(statements, uri_prefix, test_dir, options[:graph])
|
44
|
-
else
|
45
|
-
parse_w3c(statements, uri_prefix, test_dir)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def parse_w3c(statements, uri_prefix, test_dir)
|
50
|
-
statements.each do |statement|
|
51
|
-
next if statement.subject.is_a?(RDF::Node)
|
52
|
-
pred = statement.predicate.to_s.split(/[\#\/]/).last
|
53
|
-
obj = statement.object.is_a?(RDF::Literal) ? statement.object.value : statement.object.to_s
|
54
|
-
|
55
|
-
puts "#{pred.inspect}: #{obj}" if ::RDF::N3::debug?
|
56
|
-
pred = "outputDocument" if pred == "referenceOutput"
|
57
|
-
if statement.predicate == RDF.type
|
58
|
-
self.rdf_type = obj.to_s.split(/[\#\/]/).last
|
59
|
-
#puts statement.subject.to_s
|
60
|
-
elsif pred =~ /Document\Z/i
|
61
|
-
puts "sub #{uri_prefix} in #{obj} for #{test_dir}" if ::RDF::N3::debug?
|
62
|
-
about = obj
|
63
|
-
obj = obj.sub(uri_prefix, test_dir)
|
64
|
-
puts " => #{obj}" if ::RDF::N3::debug?
|
65
|
-
self.send("#{pred}=", obj)
|
66
|
-
if pred == "inputDocument"
|
67
|
-
self.about ||= about
|
68
|
-
self.name ||= statement.subject.to_s.split(/[\#\/]/).last
|
69
|
-
end
|
70
|
-
elsif self.respond_to?("#{pred}=")
|
71
|
-
self.send("#{pred}=", obj)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def parse_mf(subject, uri_prefix, test_dir, graph)
|
77
|
-
props = graph.properties(subject)
|
78
|
-
puts "MF #{subject}: #{props.inspect}" if ::RDF::N3::debug?
|
79
|
-
@name = (props[MF["name"].to_s] || []).first.to_s
|
80
|
-
@description = (props[RDF::RDFS.comment.to_s] || []).first.to_s
|
81
|
-
@outputDocument = (props[MF.result.to_s] || []).first
|
82
|
-
@outputDocument = @outputDocument.to_s.sub(uri_prefix, test_dir) if @outputDocument
|
83
|
-
action = (props[MF.action.to_s] || []).first
|
84
|
-
a_props = graph.properties(action)
|
85
|
-
@about = (a_props[QT.data.to_s] || []).first.to_s
|
86
|
-
@inputDocument = @about.to_s.sub(uri_prefix, test_dir)
|
87
|
-
end
|
88
|
-
|
89
|
-
def inspect
|
90
|
-
"[Test Case " + %w(
|
91
|
-
about
|
92
|
-
name
|
93
|
-
inputDocument
|
94
|
-
outputDocument
|
95
|
-
issue
|
96
|
-
status
|
97
|
-
approval
|
98
|
-
rdf_type
|
99
|
-
description
|
100
|
-
discussion
|
101
|
-
issue
|
102
|
-
warning
|
103
|
-
).map {|a| v = self.send(a); "#{a}='#{v}'" if v}.compact.join(", ") +
|
104
|
-
"]"
|
105
|
-
end
|
106
|
-
|
107
|
-
# Read in file, and apply modifications reference either .html or .xhtml
|
108
|
-
def input
|
109
|
-
@input ||= File.read(inputDocument)
|
110
|
-
end
|
111
|
-
|
112
|
-
def output
|
113
|
-
@output ||= outputDocument && File.read(outputDocument)
|
114
|
-
end
|
115
|
-
|
116
|
-
# Run test case, yields input for parser to create triples
|
117
|
-
def run_test(options = {})
|
118
|
-
rdf_string = input
|
119
|
-
|
120
|
-
# Run
|
121
|
-
graph = yield(rdf_string)
|
122
|
-
|
123
|
-
return unless output
|
124
|
-
|
125
|
-
case self.compare
|
126
|
-
when :none
|
127
|
-
# Don't check output, just parse to graph
|
128
|
-
when :array
|
129
|
-
@parser.graph.should be_equivalent_graph(self.output, self)
|
130
|
-
else
|
131
|
-
#puts "parse #{self.outputDocument} as #{RDF::Reader.for(self.outputDocument)}"
|
132
|
-
format = detect_format(File.open(self.outputDocument))
|
133
|
-
output_graph = RDF::Graph.load(self.outputDocument, :format => format, :base_uri => self.about)
|
134
|
-
puts "result: #{CGI.escapeHTML(graph.to_ntriples)}" if ::RDF::N3::debug?
|
135
|
-
graph.should Matchers::be_equivalent_graph(output_graph, self)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def trace
|
140
|
-
(@debug || []).to_a.join("\n")
|
141
|
-
end
|
142
|
-
|
143
|
-
def self.parse_test_cases(test_uri = nil, test_dir = nil)
|
144
|
-
raise "Missing test_uri" unless test_uri
|
145
|
-
raise "Missing test_dir" unless test_dir
|
146
|
-
@test_cases = [] unless test_uri == @test_uri
|
147
|
-
return unless @test_cases.empty?
|
148
|
-
|
149
|
-
test = test_uri.to_s.split('/').last
|
150
|
-
test_dir = test_dir + "/" unless test_dir.match(%r(/$))
|
151
|
-
ext = test.split(".").last
|
152
|
-
|
153
|
-
@positive_parser_tests = []
|
154
|
-
@negative_parser_tests = []
|
155
|
-
@positive_entailment_tests = []
|
156
|
-
@negative_entailment_tests = []
|
157
|
-
|
158
|
-
unless File.file?(File.join(test_dir, test.sub(ext, "yml")))
|
159
|
-
load_opts = {:base_uri => test_uri, :intern => false}
|
160
|
-
load_opts[:format] = :n3 if ext == "tests" # For swap tests
|
161
|
-
graph = RDF::Graph.load(File.join(test_dir, test), load_opts)
|
162
|
-
uri_base = Addressable::URI.join(test_uri, ".").to_s
|
163
|
-
t_uri = RDF::URI.new(test_uri)
|
164
|
-
|
165
|
-
# If this is a turtle test (type mf:Manifest) parse with
|
166
|
-
# alternative test case
|
167
|
-
case graph.type_of(t_uri).first
|
168
|
-
when MF.Manifest
|
169
|
-
# Get test entries
|
170
|
-
entries = graph.first(:subject => t_uri, :predicate => MF["entries"])
|
171
|
-
raise "No entires found for MF Manifest" unless entries.is_a?(RDF::Statement)
|
172
|
-
|
173
|
-
@test_cases = RDF::List.new(entries.object, graph).to_a.map do |subject|
|
174
|
-
TestCase.new(subject, uri_base, test_dir, :test_type => :mf, :graph => graph)
|
175
|
-
end
|
176
|
-
else
|
177
|
-
# One of:
|
178
|
-
# http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema
|
179
|
-
# http://www.w3.org/2000/10/swap/test.n3#
|
180
|
-
# http://www.w3.org/2004/11/n3test#
|
181
|
-
# Group by subject
|
182
|
-
@test_cases = graph.subjects.map do |subj|
|
183
|
-
t = TestCase.new(graph.query(:subject => subj), uri_base, test_dir)
|
184
|
-
t.name ? t : nil
|
185
|
-
end.
|
186
|
-
compact.
|
187
|
-
sort_by{|t| t.name.to_s}
|
188
|
-
end
|
189
|
-
else
|
190
|
-
# Read tests from Manifest.yml
|
191
|
-
self.from_yaml(File.join(test_dir, test.sub(ext, "yml")))
|
192
|
-
end
|
193
|
-
|
194
|
-
@test_cases.each do |tc|
|
195
|
-
next if tc.status && tc.status != "APPROVED"
|
196
|
-
case tc.rdf_type
|
197
|
-
when "PositiveParserTest" then @positive_parser_tests << tc
|
198
|
-
when "NegativeParserTest" then @negative_parser_tests << tc
|
199
|
-
when "PositiveEntailmentTest" then @positive_entailment_tests << tc
|
200
|
-
when "NegativeEntailmentTest" then @negative_entailment_tests << tc
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
def self.test_cases(test_uri = nil, test_dir = nil); parse_test_cases(test_uri, test_dir); @test_cases; end
|
205
|
-
def self.positive_parser_tests(test_uri = nil, test_dir = nil); parse_test_cases(test_uri, test_dir); @positive_parser_tests; end
|
206
|
-
def self.negative_parser_tests(test_uri = nil, test_dir = nil); parse_test_cases(test_uri, test_dir); @negative_parser_tests; end
|
207
|
-
def self.positive_entailment_tests(test_uri = nil, test_dir = nil); parse_test_cases(test_uri, test_dir); @positive_entailment_tests; end
|
208
|
-
def self.negative_entailment_tests(test_uri = nil, test_dir = nil); parse_test_cases(test_uri, test_dir); @negative_entailment_tests; end
|
209
|
-
|
210
|
-
def self.to_yaml(test_uri, test_dir, file)
|
211
|
-
test_cases = self.test_cases(test_uri, test_dir)
|
212
|
-
File.open(file, 'w') do |out|
|
213
|
-
YAML.dump(test_cases, out )
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
def self.from_yaml(file)
|
218
|
-
YAML::add_private_type("RdfHelper::TestCase") do |type, val|
|
219
|
-
TestCase.new( val )
|
220
|
-
end
|
221
|
-
File.open(file, 'r') do |input|
|
222
|
-
@test_cases = YAML.load(input)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
data/spec/swap_test/animal.rdf
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
<!-- A simple RDF file for parser testing -->
|
2
|
-
<rdf:RDF
|
3
|
-
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
|
4
|
-
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
5
|
-
xmlns:daml="http://www.daml.org/2001/03/daml+oil#"
|
6
|
-
xmlns="http://www.daml.org/2000/12/daml+oil#">
|
7
|
-
<rdfs:Class rdf:ID="Animal">
|
8
|
-
<rdfs:label>Animal</rdfs:label>
|
9
|
-
<restrictedBy>
|
10
|
-
<Restriction>
|
11
|
-
<onProperty rdf:resource="#parent"/>
|
12
|
-
<cardinality>2</cardinality>
|
13
|
-
</Restriction>
|
14
|
-
</restrictedBy>
|
15
|
-
</rdfs:Class>
|
16
|
-
</rdf:RDF>
|
17
|
-
|
data/spec/swap_test/anon-prop.n3
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# $Id: anon-prop.n3,v 1.1 2001-02-26 15:22:30 connolly Exp $
|
2
|
-
#
|
3
|
-
# I discovered a bug in cwm.py while writing
|
4
|
-
# http://www.w3.org/2001/02pd/gv.n3 (rev/date)
|
5
|
-
# at or before gv.n3,v 1.3 2001/02/22 06:17:55
|
6
|
-
#
|
7
|
-
# notation3.py reads it in and spits out just what I'd expect
|
8
|
-
# (by naming the anonymous node and using log:forSome)
|
9
|
-
# but running it thru cwm.py -think causes the property
|
10
|
-
# of the property to get lost altogether, and the anonymous
|
11
|
-
# property gets a name without an existential quantifier.
|
12
|
-
|
13
|
-
<#anySubj> [ <#propProp> "red" ] <#anyObj>.
|
14
|
-
|
data/spec/swap_test/contexts.n3
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Test data in notation3 http://www.w3.org/DesignIssues/Notation3.html
|
2
|
-
#
|
3
|
-
@prefix u: <http://www.example.org/utilities#> .
|
4
|
-
@prefix : <#> .
|
5
|
-
|
6
|
-
:assumption = { :fred u:knows :john .
|
7
|
-
:john u:knows :mary .} .
|
8
|
-
|
9
|
-
:conclusion = { :fred u:knows :mary . } .
|
10
|
-
|
11
|
-
# The empty context is trivially true.
|
12
|
-
# Check that we can input it and output it!
|
13
|
-
|
14
|
-
:trivialTruth = { }.
|
15
|
-
|
16
|
-
# ENDS
|
data/spec/swap_test/daml-pref.n3
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
# Suitable prefixes for DAML-ONT etc
|
2
|
-
|
3
|
-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
4
|
-
@prefix s: <http://www.w3.org/2000/01/rdf-schema#> .
|
5
|
-
@prefix daml: <http://www.daml.org/2001/03/daml-ont#> .
|
6
|
-
@prefix dpo: <http://www.daml.org/2001/03/daml+oil#> .
|
7
|
-
@prefix ex: <http://www.daml.org/2001/03/daml-ex#> .
|
8
|
-
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
9
|
-
|
10
|
-
|
@@ -1,22 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# TEST of unicode invariou splaces.
|
3
|
-
# Note: D<C3><BC>rst is the utf-8 encodeing
|
4
|
-
#
|
5
|
-
# Base was: file:/devel/WWW/2000/10/swap/test/i18n/umlaut.rdf
|
6
|
-
@prefix s: <http://www.w3.org/2000/01/rdf-schema#> .
|
7
|
-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
8
|
-
@prefix : <#>.
|
9
|
-
|
10
|
-
[ s:label "Martin J D\u00fcrst" ; :script "ひらがな" ].
|
11
|
-
|
12
|
-
[] s:label "A test with a non-ascii qname"; :related :ひらがな.
|
13
|
-
[] s:label "A test with a non-ascii fragid"; :related <#Dürst>.
|
14
|
-
|
15
|
-
|
16
|
-
[] s:label "A test with a percent-encoded unicode char in an IRI";
|
17
|
-
:related <#D%C3%BCrst>.
|
18
|
-
|
19
|
-
|
20
|
-
<#D%C3%BCrst> a "URI percent ^encoded as C3, BC".
|
21
|
-
<#Dürst> a "URI straight in UTF8".
|
22
|
-
#ENDS
|
@@ -1,12 +0,0 @@
|
|
1
|
-
<rdf:RDF
|
2
|
-
xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
|
3
|
-
xmlns='http://example/palmagent/danger#'>
|
4
|
-
<event rdf:about='#2414'>
|
5
|
-
<reminders rdf:parseType='Collection'>
|
6
|
-
<reminders_item>
|
7
|
-
<seconds_prior rdf:datatype='http://www.w3.org/2001/XMLSchema#integer'>432000</seconds_prior>
|
8
|
-
</reminders_item>
|
9
|
-
<rdf:Description rdf:about="http://example/foo#"/>
|
10
|
-
</reminders>
|
11
|
-
</event>
|
12
|
-
</rdf:RDF>
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# Test list syntax
|
2
|
-
#
|
3
|
-
# With no {} so it can be translated in DAML easily
|
4
|
-
#
|
5
|
-
|
6
|
-
@prefix t: <http://example.com/test#> .
|
7
|
-
@prefix : <http://example.com/test#> .
|
8
|
-
@prefix log: <http://www.w3.org/2000/10/swap/log#> .
|
9
|
-
|
10
|
-
# This is cheating a bit - in case output of
|
11
|
-
# first and rest or equivalentTo is needed.
|
12
|
-
|
13
|
-
@prefix dpo: <http://www.daml.org/2001/03/daml+oil#>.
|
14
|
-
@prefix owl: <http://www.w3.org/2002/07/owl#>.
|
15
|
-
|
16
|
-
|
17
|
-
:a_threebrackets = ( ( ( :fff ) ) ) .
|
18
|
-
|
19
|
-
[ :anonVerb12 :anonObj12 ] :verb12 :obj12.
|
20
|
-
|
21
|
-
:threeItems = ( :b :c :d ) .
|
22
|
-
|
23
|
-
:nested =( :first :second ( :left3 :right3 ) :fourth ) .
|
24
|
-
|
25
|
-
:emptyList = ( ) .
|
26
|
-
|
27
|
-
:listOf2Empties = (()()) .
|
28
|
-
|
29
|
-
:twoAnons = ([a :mother][a :father]).
|
30
|
-
|
31
|
-
() :verb0 :object0.
|
32
|
-
( "subj1" ) :verb1 :object1.
|
33
|
-
( "subj2a" "subj2b" ) :verb2 :object2.
|
34
|
-
|
35
|
-
# Supressed: - see lists.n3 for version with this in
|
36
|
-
# :twoFormulae = ({:a a :mother} {:b a :father}).
|
37
|
-
|
38
|
-
|
39
|
-
#ENDS
|
40
|
-
|
data/spec/swap_test/lists.n3
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Test list syntax
|
2
|
-
#
|
3
|
-
|
4
|
-
@prefix t: <test#> .
|
5
|
-
@prefix : <test#> .
|
6
|
-
@prefix ont: <http://www.w3.org/2000/10/swap/log#> .
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
:threeItems = ( :b :c :d ) .
|
11
|
-
|
12
|
-
:nested =( :first :second ( :left3 :right3 ) :fourth ) .
|
13
|
-
|
14
|
-
:emptyList = ( ) .
|
15
|
-
|
16
|
-
:listOf2Empties = (()()) .
|
17
|
-
|
18
|
-
:twoAnons = ([a :mother][a :father]).
|
19
|
-
|
20
|
-
() :verb0 :object0.
|
21
|
-
( "subj1" ) :verb1 :object1.
|
22
|
-
( "subj2a" "subj2b" ) :verb2 :object2.
|
23
|
-
|
24
|
-
|
25
|
-
# N3 only:
|
26
|
-
|
27
|
-
( 1 ) <#linksEqualLists> ( 1 ) .
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
:twoFormulae = ({:a a :mother} {:b a :father}).
|
32
|
-
|
33
|
-
|
34
|
-
#ENDS
|
35
|
-
|
@@ -1,7 +0,0 @@
|
|
1
|
-
|
2
|
-
<http://example.com/foo#a> <http://example.com/foo#b> <http://example.com/foo#c> .
|
3
|
-
|
4
|
-
<http://example.com/foo#hyphen-ated> <http://example.com/foo#dot.ted> <http://example.com/foo#hyphen-and.dot> .
|
5
|
-
|
6
|
-
<http://example.com/foo#minus-_underscore> <http://example.com/foo#under_score> <http://example.com/foo#underscore_-minus> .
|
7
|
-
|
@@ -1,119 +0,0 @@
|
|
1
|
-
|
2
|
-
_:g39 <http://www.w3.org/2002/07/owl#oneOf> _:li3 .
|
3
|
-
|
4
|
-
_:li3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#a" .
|
5
|
-
|
6
|
-
_:li3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:li2 .
|
7
|
-
|
8
|
-
_:li2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#b" .
|
9
|
-
|
10
|
-
_:li2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:li1 .
|
11
|
-
|
12
|
-
_:li1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#c" .
|
13
|
-
|
14
|
-
_:li1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
15
|
-
|
16
|
-
_:g40 <http://www.w3.org/2002/07/owl#oneOf> _:li6 .
|
17
|
-
|
18
|
-
_:li6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#x" .
|
19
|
-
|
20
|
-
_:li6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:li5 .
|
21
|
-
|
22
|
-
_:li5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#y" .
|
23
|
-
|
24
|
-
_:li5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:li4 .
|
25
|
-
|
26
|
-
_:li4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#z" .
|
27
|
-
|
28
|
-
_:li4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
29
|
-
|
30
|
-
_:g41 <http://www.w3.org/2002/07/owl#oneOf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
31
|
-
|
32
|
-
_:g42 <http://www.w3.org/2002/07/owl#oneOf> _:li8 .
|
33
|
-
|
34
|
-
_:li8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:g14 .
|
35
|
-
|
36
|
-
_:li8 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:li7 .
|
37
|
-
|
38
|
-
_:li7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:g18 .
|
39
|
-
|
40
|
-
_:li7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
41
|
-
|
42
|
-
_:g43 <http://www.w3.org/2002/07/owl#oneOf> _:li9 .
|
43
|
-
|
44
|
-
_:li9 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:g27 .
|
45
|
-
|
46
|
-
_:li9 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
47
|
-
|
48
|
-
_:g44 <http://www.w3.org/2002/07/owl#oneOf> _:li10 .
|
49
|
-
|
50
|
-
_:li10 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:g10 .
|
51
|
-
|
52
|
-
_:li10 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
|
53
|
-
|
54
|
-
_:b _:a _:c .
|
55
|
-
|
56
|
-
_:g7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/10/swap/log#Truth> .
|
57
|
-
|
58
|
-
_:g7 <http://www.w3.org/2004/06/rei#existentials> _:g39 .
|
59
|
-
|
60
|
-
_:g7 <http://www.w3.org/2004/06/rei#statements> _:g44 .
|
61
|
-
|
62
|
-
_:g7 <http://www.w3.org/2004/06/rei#universals> _:g40 .
|
63
|
-
|
64
|
-
_:g10 <http://www.w3.org/2004/06/rei#object> _:g24 .
|
65
|
-
|
66
|
-
_:g10 <http://www.w3.org/2004/06/rei#predicate> _:g23 .
|
67
|
-
|
68
|
-
_:g10 <http://www.w3.org/2004/06/rei#subject> _:g11 .
|
69
|
-
|
70
|
-
_:g11 <http://www.w3.org/2004/06/rei#existentials> _:g41 .
|
71
|
-
|
72
|
-
_:g11 <http://www.w3.org/2004/06/rei#statements> _:g42 .
|
73
|
-
|
74
|
-
_:g11 <http://www.w3.org/2004/06/rei#universals> _:g41 .
|
75
|
-
|
76
|
-
_:g14 <http://www.w3.org/2004/06/rei#object> _:g17 .
|
77
|
-
|
78
|
-
_:g14 <http://www.w3.org/2004/06/rei#predicate> _:g16 .
|
79
|
-
|
80
|
-
_:g14 <http://www.w3.org/2004/06/rei#subject> _:g15 .
|
81
|
-
|
82
|
-
_:g15 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#x" .
|
83
|
-
|
84
|
-
_:g16 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#mother" .
|
85
|
-
|
86
|
-
_:g17 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#y" .
|
87
|
-
|
88
|
-
_:g18 <http://www.w3.org/2004/06/rei#object> _:g21 .
|
89
|
-
|
90
|
-
_:g18 <http://www.w3.org/2004/06/rei#predicate> _:g20 .
|
91
|
-
|
92
|
-
_:g18 <http://www.w3.org/2004/06/rei#subject> _:g19 .
|
93
|
-
|
94
|
-
_:g19 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#y" .
|
95
|
-
|
96
|
-
_:g20 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#sister" .
|
97
|
-
|
98
|
-
_:g21 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#z" .
|
99
|
-
|
100
|
-
_:g23 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/log#implies" .
|
101
|
-
|
102
|
-
_:g24 <http://www.w3.org/2004/06/rei#existentials> _:g41 .
|
103
|
-
|
104
|
-
_:g24 <http://www.w3.org/2004/06/rei#statements> _:g43 .
|
105
|
-
|
106
|
-
_:g24 <http://www.w3.org/2004/06/rei#universals> _:g41 .
|
107
|
-
|
108
|
-
_:g27 <http://www.w3.org/2004/06/rei#object> _:g30 .
|
109
|
-
|
110
|
-
_:g27 <http://www.w3.org/2004/06/rei#predicate> _:g29 .
|
111
|
-
|
112
|
-
_:g27 <http://www.w3.org/2004/06/rei#subject> _:g28 .
|
113
|
-
|
114
|
-
_:g28 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#x" .
|
115
|
-
|
116
|
-
_:g29 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#aunt" .
|
117
|
-
|
118
|
-
_:g30 <http://www.w3.org/2004/06/rei#uri> "http://www.w3.org/2000/10/swap/test/syntax/foo.n3#z" .
|
119
|
-
|