aboutsummaryrefslogtreecommitdiffstats
path: root/test/schema/test_serialize.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/schema/test_serialize.py')
-rw-r--r--test/schema/test_serialize.py335
1 files changed, 179 insertions, 156 deletions
diff --git a/test/schema/test_serialize.py b/test/schema/test_serialize.py
index 84512e9..7d5d3ae 100644
--- a/test/schema/test_serialize.py
+++ b/test/schema/test_serialize.py
@@ -14,6 +14,8 @@ from bsfs.schema.serialize import from_string, to_string
## code ##
+ns.bse = ns.bsfs.Entity()
+
class TestFromString(unittest.TestCase):
def test_empty(self):
@@ -25,7 +27,7 @@ class TestFromString(unittest.TestCase):
# must not have circular dependencies
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- prefix bsfs: <http://bsfs.ai/schema/>
+ prefix bsfs: <https://schema.bsfs.io/core/>
bsfs:Entity rdfs:subClassOf bsfs:Node .
# ah, a nice circular dependency
bsfs:Entity rdfs:subClassOf bsfs:Document .
@@ -39,8 +41,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -54,7 +56,7 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
+ prefix bsfs: <https://schema.bsfs.io/core/>
bsfs:Entity rdfs:subClassOf bsfs:Node .
bsfs:Document rdfs:subClassOf bsfs:Node .
@@ -66,8 +68,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({}, {n_unused}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:unused rdfs:subClassOf bsfs:Node . # unused symbol
'''))
@@ -80,8 +82,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({}, {n_ent, n_tag, n_doc, n_image}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
# nodes inherit from same parent
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -100,8 +102,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({p_filename}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -116,7 +118,7 @@ class TestFromString(unittest.TestCase):
self.assertDictEqual(from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
+ prefix bsfs: <https://schema.bsfs.io/core/>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -124,7 +126,7 @@ class TestFromString(unittest.TestCase):
self.assertDictEqual(from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
+ prefix bsfs: <https://schema.bsfs.io/core/>
bsfs:Entity rdfs:subClassOf bsfs:Node ;
rdfs:label "hello world"^^xsd:string ;
@@ -141,8 +143,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -156,7 +158,7 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
+ prefix bsfs: <https://schema.bsfs.io/core/>
xsd:string rdfs:subClassOf bsfs:Literal .
xsd:name rdfs:subClassOf bsfs:Literal .
@@ -168,8 +170,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({}, {}, {l_unused}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
xsd:unused rdfs:subClassOf bsfs:Literal . # unused symbol
'''))
@@ -182,13 +184,14 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({}, {}, {l_string, l_integer, l_unsigned, l_signed}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
# literals inherit from same parent
xsd:string rdfs:subClassOf bsfs:Literal .
- bsfs:Number rdfs:subClassOf bsfs:Literal .
- xsd:integer rdfs:subClassOf bsfs:Number .
+ bsl:Number rdfs:subClassOf bsfs:Literal .
+ xsd:integer rdfs:subClassOf bsl:Number .
# literals inherit from same parent
xsd:unsigned rdfs:subClassOf xsd:integer .
@@ -203,8 +206,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({p_filename}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -219,7 +222,7 @@ class TestFromString(unittest.TestCase):
self.assertDictEqual(from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
+ prefix bsfs: <https://schema.bsfs.io/core/>
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -227,7 +230,7 @@ class TestFromString(unittest.TestCase):
self.assertDictEqual(from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
+ prefix bsfs: <https://schema.bsfs.io/core/>
xsd:string rdfs:subClassOf bsfs:Literal ;
rdfs:label "hello world"^^xsd:string ;
@@ -244,8 +247,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -258,8 +261,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Literal .
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -274,8 +277,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -288,8 +291,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -302,8 +305,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -320,8 +323,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({p_comment}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -340,8 +343,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({p_comment}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -362,8 +365,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({p_comment}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
xsd:string rdfs:subClassOf bsfs:Literal .
@@ -383,8 +386,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({p_foo}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -405,8 +408,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({p_foobar}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
bsfs:Image rdfs:subClassOf bsfs:Entity .
@@ -421,8 +424,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
bsfs:Image rdfs:subClassOf bsfs:Entity .
@@ -444,8 +447,8 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema({p_foobar}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
bsfs:Image rdfs:subClassOf bsfs:Entity .
@@ -460,8 +463,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
bsfs:Image rdfs:subClassOf bsfs:Entity .
@@ -478,8 +481,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
bsfs:Annotation rdfs:subClassOf bsfs:Predicate .
@@ -499,8 +502,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -516,8 +519,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -533,8 +536,8 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bsfs:Entity rdfs:subClassOf bsfs:Node .
@@ -551,8 +554,8 @@ class TestFromString(unittest.TestCase):
self.assertDictEqual(from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bse:comment rdfs:subClassOf bsfs:Predicate ;
rdfs:range bsfs:Node .
@@ -561,8 +564,8 @@ class TestFromString(unittest.TestCase):
self.assertDictEqual(from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
bse:comment rdfs:subClassOf bsfs:Predicate ;
rdfs:range bsfs:Node ;
@@ -581,70 +584,78 @@ class TestFromString(unittest.TestCase):
self.assertEqual(Schema(literals={f_colors}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
- bsfs:Colors rdfs:subClassOf bsfs:Feature .
+ bsfs:Colors rdfs:subClassOf bsa:Feature .
'''))
# features inherit properties from parents
- f_colors = types.ROOT_FEATURE.child(ns.bsfs.Colors, dimension=1234, dtype=ns.bsfs.i32)
- f_main_colors = f_colors.child(ns.bsfs.MainColor, distance=ns.bsfs.cosine, dtype=ns.bsfs.f16)
+ f_colors = types.ROOT_FEATURE.child(ns.bsfs.Colors, dimension=1234, dtype=ns.bsfs.dtype().i32)
+ f_main_colors = f_colors.child(ns.bsfs.MainColor, distance=ns.bsfs.cosine, dtype=ns.bsfs.dtype().f16)
self.assertEqual(Schema(literals={f_colors, f_main_colors}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
- bsfs:Colors rdfs:subClassOf bsfs:Feature ; # inherits distance from bsfs:Feature
- bsfs:dimension "1234"^^xsd:integer ; # overwrites bsfs:Feature
- bsfs:dtype bsfs:i32 . # overwrites bsfs:Feature
+ bsfs:Colors rdfs:subClassOf bsa:Feature ; # inherits distance from bsa:Feature
+ bsfs:dimension "1234"^^xsd:integer ; # overwrites bsa:Feature
+ bsfs:dtype <https://schema.bsfs.io/core/dtype#i32> . # overwrites bsa:Feature
bsfs:MainColor rdfs:subClassOf bsfs:Colors ; # inherits dimension from bsfs:Colors
- bsfs:distance bsfs:cosine ; # overwrites bsfs:Feature
- bsfs:dtype bsfs:f16 . # overwrites bsfs:Colors
+ bsfs:distance bsfs:cosine ; # overwrites bsa:Feature
+ bsfs:dtype <https://schema.bsfs.io/core/dtype#f16> . # overwrites bsfs:Colors
'''))
# feature definition can be split across multiple statements.
# statements can be repeated
- f_colors = types.ROOT_FEATURE.child(ns.bsfs.Colors, dimension=1234, dtype=ns.bsfs.f32)
+ f_colors = types.ROOT_FEATURE.child(ns.bsfs.Colors, dimension=1234, dtype=ns.bsfs.dtype().f32)
self.assertEqual(Schema(literals={f_colors}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
bsfs:dimension "1234"^^xsd:integer .
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
bsfs:dimension "1234"^^xsd:integer ; # non-conflicting repetition
- bsfs:dtype bsfs:f32 .
+ bsfs:dtype <https://schema.bsfs.io/core/dtype#f32> .
'''))
# cannot define the same feature from multiple parents
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
- bsfs:ColorSpace rdfs:subClassOf bsfs:Feature .
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
+ bsfs:ColorSpace rdfs:subClassOf bsa:Feature .
- bsfs:Colors rdfs:subClassOf bsfs:Feature .
+ bsfs:Colors rdfs:subClassOf bsa:Feature .
bsfs:Colors rdfs:subClassOf bsfs:ColorSpace .
''')
@@ -652,16 +663,18 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
bsfs:dimension "1234"^^xsd:integer .
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
bsfs:dimension "4321"^^xsd:integer . # conflicting dimension
''')
@@ -669,32 +682,36 @@ class TestFromString(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
- bsfs:dtype bsfs:f32 .
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
+ bsfs:dtype <https://schema.bsfs.io/core/dtype#i32> .
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
- bsfs:dtype bsfs:f16 . # conflicting dtype
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
+ bsfs:dtype <https://schema.bsfs.io/core/dtype#f16> . # conflicting dtype
''')
# cannot assign multiple conflicting distance metrics to the same feature
self.assertRaises(errors.ConsistencyError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
bsfs:distance bsfs:euclidean .
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
bsfs:distance bsfs:cosine . # conflicting distance
''')
@@ -702,26 +719,30 @@ class TestFromString(unittest.TestCase):
self.assertDictEqual(from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
bsfs:dimension "1234"^^xsd:integer .
''').literal(ns.bsfs.Colors).annotations, {})
self.assertDictEqual(from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
- bsfs:Colors rdfs:subClassOf bsfs:Feature ;
+ bsfs:Colors rdfs:subClassOf bsa:Feature ;
bsfs:dimension "1234"^^xsd:integer ;
rdfs:label "hello world"^^xsd:string ;
bsfs:foo "1234"^^xsd:integer .
@@ -748,10 +769,10 @@ class TestFromString(unittest.TestCase):
p_group = p_tag.child(ns.bse.group, domain=n_image, unique=True)
p_comment = p_annotation.child(ns.bse.comment, range=l_string)
# features
- f_colors = types.ROOT_FEATURE.child(URI('http://bsfs.ai/schema/Feature/colors_spatial'),
- dtype=ns.bsfs.f16, distance=ns.bsfs.euclidean)
- f_colors1234 = f_colors.child(URI('http://bsfs.ai/schema/Feature/colors_spatial#1234'), dimension=1024)
- f_colors4321 = f_colors.child(URI('http://bsfs.ai/schema/Feature/colors_spatial#4321'), dimension=2048)
+ f_colors = types.ROOT_FEATURE.child(URI('https://schema.bsfs.io/core/Feature/colors_spatial'),
+ dtype=ns.bsfs.dtype().f16, distance=ns.bsfs.euclidean)
+ f_colors1234 = f_colors.child(URI('https://schema.bsfs.io/core/Feature/colors_spatial#1234'), dimension=1024)
+ f_colors4321 = f_colors.child(URI('https://schema.bsfs.io/core/Feature/colors_spatial#4321'), dimension=2048)
# schema
ref = Schema(
{p_annotation, p_tag, p_group, p_comment},
@@ -764,8 +785,10 @@ class TestFromString(unittest.TestCase):
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
# bsfs prefixes
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
+ prefix bsfs: <https://schema.bsfs.io/core/>
+ prefix bse: <https://schema.bsfs.io/core/Entity#>
+ prefix bsl: <https://schema.bsfs.io/core/Literal/>
+ prefix bsa: <https://schema.bsfs.io/core/Literal/Array/>
# nodes
bsfs:Entity rdfs:subClassOf bsfs:Node ;
@@ -777,10 +800,10 @@ class TestFromString(unittest.TestCase):
# literals
xsd:string rdfs:subClassOf bsfs:Literal ;
rdfs:label "A sequence of characters"^^xsd:string .
- bsfs:Array rdfs:subClassOf bsfs:Literal .
- bsfs:Feature rdfs:subClassOf bsfs:Array.
- bsfs:Number rdfs:subClassOf bsfs:Literal .
- xsd:integer rdfs:subClassOf bsfs:Number .
+ bsl:Array rdfs:subClassOf bsfs:Literal .
+ bsa:Feature rdfs:subClassOf bsl:Array.
+ bsl:Number rdfs:subClassOf bsfs:Literal .
+ xsd:integer rdfs:subClassOf bsl:Number .
xsd:boolean rdfs:subClassOf bsfs:Literal .
@@ -789,19 +812,19 @@ class TestFromString(unittest.TestCase):
rdfs:label "node annotation"^^xsd:string .
# feature instances
- <http://bsfs.ai/schema/Feature/colors_spatial> rdfs:subClassOf bsfs:Feature ;
- bsfs:dtype bsfs:f16 ;
+ <https://schema.bsfs.io/core/Feature/colors_spatial> rdfs:subClassOf bsa:Feature ;
+ bsfs:dtype <https://schema.bsfs.io/core/dtype#f16> ;
bsfs:distance bsfs:euclidean ;
# annotations
rdfs:label "ColorsSpatial instances. Dimension depends on instance."^^xsd:string ;
bsfs:first_arg "1234"^^xsd:integer ;
bsfs:second_arg "hello world"^^xsd:string .
- <http://bsfs.ai/schema/Feature/colors_spatial#1234> rdfs:subClassOf <http://bsfs.ai/schema/Feature/colors_spatial> ;
+ <https://schema.bsfs.io/core/Feature/colors_spatial#1234> rdfs:subClassOf <https://schema.bsfs.io/core/Feature/colors_spatial> ;
bsfs:dimension "1024"^^xsd:integer ;
rdfs:label "Main colors spatial instance"^^xsd:string .
- <http://bsfs.ai/schema/Feature/colors_spatial#4321> rdfs:subClassOf <http://bsfs.ai/schema/Feature/colors_spatial> ;
+ <https://schema.bsfs.io/core/Feature/colors_spatial#4321> rdfs:subClassOf <https://schema.bsfs.io/core/Feature/colors_spatial> ;
bsfs:dimension "2048"^^xsd:integer .
# predicate instances
@@ -829,19 +852,19 @@ class TestFromString(unittest.TestCase):
self.assertDictEqual(gen.node(ns.bsfs.Tag).annotations, {ns.rdfs.label: 'Tag'})
self.assertDictEqual(gen.literal(ns.xsd.string).annotations, {ns.rdfs.label: 'A sequence of characters'})
self.assertDictEqual(gen.predicate(ns.bsfs.Annotation).annotations, {ns.rdfs.label: 'node annotation'})
- self.assertDictEqual(gen.literal(URI('http://bsfs.ai/schema/Feature/colors_spatial')).annotations, {
+ self.assertDictEqual(gen.literal(URI('https://schema.bsfs.io/core/Feature/colors_spatial')).annotations, {
ns.rdfs.label: 'ColorsSpatial instances. Dimension depends on instance.',
ns.bsfs.first_arg: 1234,
ns.bsfs.second_arg: 'hello world',
})
- self.assertDictEqual(gen.literal(URI('http://bsfs.ai/schema/Feature/colors_spatial#1234')).annotations, {
+ self.assertDictEqual(gen.literal(URI('https://schema.bsfs.io/core/Feature/colors_spatial#1234')).annotations, {
ns.rdfs.label: 'Main colors spatial instance'})
self.assertDictEqual(gen.predicate(ns.bse.tag).annotations, {ns.rdfs.label: 'connect entity to a tag'})
# blank nodes result in an error
self.assertRaises(errors.BackendError, from_string, '''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- prefix bsfs: <http://bsfs.ai/schema/>
+ prefix bsfs: <https://schema.bsfs.io/core/>
bsfs:Entity rdfs:subClassOf bsfs:Node ;
bsfs:foo _:bar .
''')
@@ -976,29 +999,29 @@ class TestToString(unittest.TestCase):
def test_feature(self):
# root features
- f_colors = types.ROOT_FEATURE.child(URI('http://bsfs.ai/schema/Feature/colors'),
+ f_colors = types.ROOT_FEATURE.child(URI('https://schema.bsfs.io/core/Feature/colors'),
distance=ns.bsfs.cosine)
# derived features
- f_colors1234 = f_colors.child(URI('http://bsfs.ai/schema/Feature/colors#1234'),
+ f_colors1234 = f_colors.child(URI('https://schema.bsfs.io/core/Feature/colors#1234'),
dimension=1024) # inherits dtype, distance
- f_colors4321 = f_colors.child(URI('http://bsfs.ai/schema/Feature/colors#4321'),
+ f_colors4321 = f_colors.child(URI('https://schema.bsfs.io/core/Feature/colors#4321'),
dimension=2048, distance=ns.bsfs.euclidean) # inherits dtype
# create schema
schema = Schema(literals={f_colors, f_colors1234, f_colors4321})
schema_str = to_string(schema)
# all symbols are serialized
- self.assertIn('bsfs:Array', schema_str)
- self.assertIn('<http://bsfs.ai/schema/Feature/colors', schema_str)
- self.assertIn('<http://bsfs.ai/schema/Feature/colors#1234', schema_str)
- self.assertIn('<http://bsfs.ai/schema/Feature/colors#4321', schema_str)
+ self.assertIn('bsl:Array', schema_str)
+ self.assertIn('<https://schema.bsfs.io/core/Feature/colors', schema_str)
+ self.assertIn('<https://schema.bsfs.io/core/Feature/colors#1234', schema_str)
+ self.assertIn('<https://schema.bsfs.io/core/Feature/colors#4321', schema_str)
# inherited properties are not serialized
- self.assertIsNotNone(re.search(r'<http://bsfs\.ai/schema/Feature/colors#1234>[^\.]*bsfs:dimension[^\.]', schema_str))
- self.assertIsNone(re.search(r'<http://bsfs\.ai/schema/Feature/colors#1234>[^\.]*bsfs:dtype[^\.]', schema_str))
- self.assertIsNone(re.search(r'<http://bsfs\.ai/schema/Feature/colors#1234>[^\.]*bsfs:distance[^\.]', schema_str))
- self.assertIsNotNone(re.search(r'<http://bsfs\.ai/schema/Feature/colors#4321>[^\.]*bsfs:dimension[^\.]', schema_str))
- self.assertIsNotNone(re.search(r'<http://bsfs\.ai/schema/Feature/colors#4321>[^\.]*bsfs:distance[^\.]', schema_str))
- self.assertIsNone(re.search(r'<http://bsfs\.ai/schema/Feature/colors#4321>[^\.]*bsfs:dtype[^\.]', schema_str))
+ self.assertIsNotNone(re.search(r'<https://schema.bsfs\.io/core/Feature/colors#1234>.*[^\.]*bsfs:dimension[^\.]', schema_str))
+ self.assertIsNone(re.search(r'<https://schema\.bsfs\.io/core/Feature/colors#1234>.*[^\.]*bsfs:dtype[^\.]', schema_str))
+ self.assertIsNone(re.search(r'<https://schema\.bsfs\.io/core/Feature/colors#1234>.*[^\.]*bsfs:distance[^\.]', schema_str))
+ self.assertIsNotNone(re.search(r'<https://schema\.bsfs\.io/core/Feature/colors#4321>.*[^\.]*bsfs:dimension[^\.]', schema_str))
+ self.assertIsNotNone(re.search(r'<https://schema\.bsfs\.io/core/Feature/colors#4321>.*[^\.]*bsfs:distance[^\.]', schema_str))
+ self.assertIsNone(re.search(r'<https://schema\.bsfs\.io/core/Feature/colors#4321>.*[^\.]*bsfs:dtype[^\.]', schema_str))
# unserialize yields the original schema
self.assertEqual(schema, from_string(schema_str))
@@ -1009,12 +1032,12 @@ class TestToString(unittest.TestCase):
ns.bsfs.foo: 1234,
ns.bsfs.bar: False,
}
- f_colors = types.ROOT_FEATURE.child(URI('http://bsfs.ai/schema/Feature/colors'),
- dtype=ns.bsfs.f16, distance=ns.bsfs.euclidean,
+ f_colors = types.ROOT_FEATURE.child(URI('https://schema.bsfs.io/core/Feature/colors'),
+ dtype=ns.bsfs.dtype().f16, distance=ns.bsfs.euclidean,
**annotations)
self.assertDictEqual(
annotations,
- from_string(to_string(Schema(literals={f_colors}))).literal(URI('http://bsfs.ai/schema/Feature/colors')).annotations)
+ from_string(to_string(Schema(literals={f_colors}))).literal(URI('https://schema.bsfs.io/core/Feature/colors')).annotations)
## main ##