linkml / schema-automator

Automated assistance for the schema development lifecycle
https://linkml.io/schema-automator/
BSD 3-Clause "New" or "Revised" License
33 stars 12 forks source link

Missing Schema When Reading in Turtle File #117

Open Sulstice opened 1 year ago

Sulstice commented 1 year ago

Hi,

I am receiving this error:

  File "schema_automator/generalizers/rdf_data_generalizer.py", line 43, in convert
    sv = SchemaView(schemas[0])
IndexError: list index out of range

And the command I am running:

schemauto --verbose generalize-rdf graph.ttl -d link_ml

I'm wondering is there something wrong with my initial turtle file. I produced the graph with RDFLib and here is an example of the output in n3 notation:


import rdflib
graph = rdflib.Graph()
....
graph.serialize(destination='graph.ttl', format='n3')

Here's an example of the input

@prefix ns1: <#> .

<#/%28%2B%29-norpseudoephedrine> ns1:connectsTo <#/schedule_four> .

<#/%28%C2%B1%29cis-4-methylaminorex> ns1:connectsTo <#/schedule_one> .

<#/%281%2C1%E2%80%B2%2C3%2C3%E2%80%B2-tetraoxo%5B5%2C5%E2%80%B2-biisoindoline%5D-2%2C2%E2%80%B2-diyl%29biphenyl> ns1:connectsTo <#/common_monomer_repeating_units> .

<#/%281%2C1-dioxobenzo%5Bb%5Dthiophene-2-yl%29methyloxycarbonyl> ns1:connectsTo <#/amino_acid_protecting_groups> .

<#/%281%2C1-dioxonaptho%5B1%2C2-b%5Dthiophene-2-yl%29methyloxycarbonyl> ns1:connectsTo <#/amino_acid_protecting_groups> .

<#/%281R%2C4S%2C
caufieldjh commented 1 year ago

Hi @Sulstice, Yes - I think your input may need to take a form more like this:

@base <http://example.org/> .
@prefix ns1: <http://www.w3.org/ns/1#> .

<#%28%2B%29-norpseudoephedrine>
    ns1:connectsTo <#schedule_four> ;
    a ns1:Category .

<#%28%C2%B1%29cis-4-methylaminorex>
    ns1:connectsTo <#schedule_one> ;
    a ns1:Category .

I think the general issue is that, without specifying at least what the object in each of these triples is, there really isn't enough to generalize into a schema. Either that or schemaview is just very particular about what needs to be present in a schema.