oeg-upm / mapeathor

Translator of spreadsheet mappings into R2RML, RML or YARRRML
https://morph.oeg.fi.upm.es/tool/mapeathor
Apache License 2.0
30 stars 10 forks source link

Generate owl:equivalentClass triples #41

Open nleguillarme opened 2 years ago

nleguillarme commented 2 years ago

Hi, As part of my knowledge graph creation process, I have some data in a csv file I need to transform into owl:equivalentClass triples. My data basically consists of two columns, one with the subject IRI, the second with the object IRI, and I want to generate triples of the form (subject_iri, owl:equivalentClass, object_iri). It does not seem possible, as mapeathor treats each subject as individuals. Here, my subjects are classes. Am I right ?

anaigmo commented 2 years ago

Interesting point. I think yes, but by definition I think all mappings in [R2]RML create always subjects as instances. Please show an example if you have found a way to do it. I'm thinking, maybe, deleting the rr:class and in a POM stating that is an owl:class?

Anyway, this issue is more related to what RML and R2RML can represent. The only problem I can see that addresses Mapeathor if it forces the user to specify a rr:class for the subject. I meant, please check first if this can be done and correctly processed by an [R2]RML-processor, and if so, I'll see if it affects the current behaviour of Mapeathor, because right now I'm not sure if it is affected.

nleguillarme commented 2 years ago

Here is how I do it in YARRRML:

SRCTAXON:
    sources:
      - access: ./taxon.tsv
        referenceFormulation: csv
        delimiter: "\t"
    s: $(src_iri)
    po:
      - p: owl:equivalentClass
        o:
          mapping: TGTTAXON
          condition:
            function: equal
            parameters:
              - [str1, $(ID)]
              - [str2, $(ID)]

This generates the following RML rules

:rules_000 void:exampleResource :map_SRCTAXON_000.
:map_SRCTAXON_000 rml:logicalSource :source_004.
:source_004 a rml:LogicalSource;
    rml:source :csvw_004.
:csvw_004 a csvw:Table;
    csvw:url "./taxon.tsv";
    csvw:dialect :csvw-dialect_004.
:csvw-dialect_004 a csvw:Dialect;
    csvw:delimiter "\t".
:source_004 rml:referenceFormulation ql:CSV.
:map_SRCTAXON_000 a rr:TriplesMap;
    rdfs:label "SRCTAXON".
:s_004 a rr:SubjectMap.
:map_SRCTAXON_000 rr:subjectMap :s_004.
:s_004 rml:reference "src_iri".
:pom_010 a rr:PredicateObjectMap.
:map_SRCTAXON_000 rr:predicateObjectMap :pom_010.
:pm_010 a rr:PredicateMap.
:pom_010 rr:predicateMap :pm_010.
:pm_010 rr:constant owl:equivalentClass.
:pom_010 rr:objectMap :om_010.
anaigmo commented 2 years ago

I see, I've been running tests and mapeathor creates "rr:class nan" when provided with no class, so that should be changed in order to address your use case, the rest (I think) is fine. Tagging for modification

anaigmo commented 2 years ago

The new release v1.5.4 can create a subject with no class, I hope it works for you now!

nleguillarme commented 2 years ago

Hi @anaigmo, subject with no class creation works for me, thank you ! However, I still lack the possibility of specifying that the URI I read in my source file is a IRI -> the subject is recognized as a BlankNode. Would it be possible to add a "IsIRI" column in the Subject tab, so that if I set Class to empty and IsIRI to true, mapeathor recognized that my subject is a class ?

anaigmo commented 2 years ago

I'm glad that works :)

I'm re-opening the issue for the additional column issue. Could you provide an example of the IRI that is recognized as BN? So I can see why it behaving like this. I'd like to avoid adding more columns when possible, so first I want to check if it is possible to distinguish IRI/BN in all cases. Thanks!

nleguillarme commented 2 years ago

Here are a few examples

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

iri | queryIRI -- | -- https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=288551 | https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=288551 http://www.gbif.org/species/2280552  | https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=288551

I would like to be able to create owl:equivalentClass triples between elements in the iri and queryIRI columns

nleguillarme commented 1 year ago

Hi, I just realized that what I meant all along was not to generate owl:sameAs triples but owl:equivalentClass triples (to indicate that two classes are equivalent). I have changed all my previous posts to reflect this.

I am still interested in creating triples relating classes (and not individuals).