Using rudof to compare schemas

Using rudof to compare schemas#

Open In Colab

!pip install pyrudof
Collecting pyrudof
  Downloading pyrudof-0.2.9-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.2 kB)
Downloading pyrudof-0.2.9-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.9 MB)
?25l   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/10.9 MB ? eta -:--:--
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.9/10.9 MB 181.1 MB/s  0:00:00
?25h
Installing collected packages: pyrudof
Successfully installed pyrudof-0.2.9
from pyrudof import Rudof, RudofConfig, ReaderMode
rudof = Rudof(RudofConfig())

Comparing Schemas#

It is possible to use rudof to compare different schemas. For example:

schema1 = """
 PREFIX : <http://example.org/>
 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
 :Person {
    :name xsd:string ;
    :age xsd:integer ;
    :weight xsd:float ;
    :worksFor .
 }
""";
schema2 = """
 PREFIX ex: <http://example.org/>
 PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
 ex:Person {
    ex:name xsd:string ;
    ex:birthDate xsd:date ;
    ex:worksFor .
}
"""
result = rudof.compare_schemas(
    schema1, schema2,
    "shex", "shex",
    "shexc", "shexc",
    None, None,
    "http://example.org/Person", "http://example.org/Person",
    ReaderMode.Lax
    )
print(result)
Shapes Comparison:
 Equal properties:
  - http://example.org/name: 
  - descr1:   - value: http://example.org/name
  - datatype: http://www.w3.org/2001/XMLSchema#string

  - descr2:   - value: http://example.org/name
  - datatype: http://www.w3.org/2001/XMLSchema#string


  - http://example.org/worksFor: 
  - descr1:   - value: http://example.org/worksFor
  - datatype: _

  - descr2:   - value: http://example.org/worksFor
  - datatype: _


 Properties in shape 1 that are not in shape 2:
  - http://example.org/age: 
  - descr:   - value: http://example.org/age
  - datatype: http://www.w3.org/2001/XMLSchema#integer


  - http://example.org/weight: 
  - descr:   - value: http://example.org/weight
  - datatype: http://www.w3.org/2001/XMLSchema#float


 Properties in shape 2 that are not in shape 1:
  - http://example.org/birthDate: 
  - descr:   - value: http://example.org/birthDate
  - datatype: http://www.w3.org/2001/XMLSchema#date