andrecastro0o / ontology2smw

automating an RDF ontology import into Semantic Mediawiki
GNU General Public License v3.0
16 stars 5 forks source link

refactor branch #31 #41

Closed andrecastro0o closed 3 years ago

andrecastro0o commented 3 years ago

31

I believe there is a bit duplicate data in the objects that are created from

specially the passing of data to the Jinja template.

Investigate & Correct

andrecastro0o commented 3 years ago

SMWCategoryORProp

class arguments

<ontology2smw.classes.SMWCategoryORProp object at 0x7f3a9eb48f60>.__dict__

{'item': 
     (rdflib.term.URIRef('http://purl.obolibrary.org/obo/BFO_0000001'), 
      rdflib.term.URIRef('http://www.w3.org/2002/07/owl#Class'), 
      rdflib.term.Literal('entity', lang='en'), 
      None, 
      rdflib.term.URIRef('http://www.w3.org/2002/07/owl#Thing'), 
      None), 
 'item_dict': 
     {
         'term': rdflib.term.URIRef('http://purl.obolibrary.org/obo/BFO_0000001'), 
         'termType': rdflib.term.URIRef('http://www.w3.org/2002/07/owl#Class'), 
         'label': rdflib.term.Literal('entity', lang='en'), 
         'subclassof': rdflib.term.URIRef('http://www.w3.org/2002/07/owl#Thing')}, 
 'term': rdflib.term.URIRef('http://purl.obolibrary.org/obo/BFO_0000001'), 
 'term_name': 'BFO_0000001', 
 'query': <ontology2smw.classes.QueryOntology object at 0x7f3aa543ddd8>, 
 'namespace': rdflib.term.URIRef('http://purl.obolibrary.org/obo/'),
 'namespace_prefix': 'obo', 
 'query_nsmanager': <rdflib.namespace.NamespaceManager object at 
0x7f3a9f367f28>,
 'resource_type': 'Category',
 'prop_datatype': None,
 'wikipage_name': 'Category:BFO_0000001', 
 'wikipage_content': '\nImported from [[Imported from::obo:BFO_0000001]]\n\nEquivalent URI [[Equivalent URI::http://purl.obolibrary.org/obo/BFO_0000001]]\n\n\nSubcategory of [[:Category:Thing]] [[Category:Thing]]\n\n\nTerm description: [[Has property description::entity@en]]\n\n[[Category:Imported vocabulary]] [[Category:OBO]]'
}

in the code self.item is never used, but only self.item_dict hence it could make sense to remove self.item

https://github.com/TIBHannover/ontology2smw/blob/08c54a5e306d10b72871fdb4faf95d4841440018/ontology2smw/classes.py#L107-L114

Which I did in d61bfbb523559b35e9c896b938c6dc4af7617a38


class template rendering

https://github.com/TIBHannover/ontology2smw/blob/08c54a5e306d10b72871fdb4faf95d4841440018/ontology2smw/classes.py#L171-L181

Is calling mw_property.j2 or mw_category.j2

https://github.com/TIBHannover/ontology2smw/blob/08c54a5e306d10b72871fdb4faf95d4841440018/ontology2smw/jinja_utils.py#L27-L47

Rendering:

issues

andrecastro0o commented 3 years ago
andrecastro0o commented 3 years ago

Currently


{'term_dict': {
'term': rdflib.term.URIRef('http://purl.obolibrary.org/obo/BFO_0000001'),
'termType': rdflib.term.URIRef('http://www.w3.org/2002/07/owl#Class'),
'label': rdflib.term.Literal('entity', lang='en'),
'subclassof': rdflib.term.URIRef('http://www.w3.org/2002/07/owl#Thing')}, 
'term': rdflib.term.URIRef('http://purl.obolibrary.org/obo/BFO_0000001'),
'term_name': 'BFO_0000001', 
'query': <ontology2smw.classes.QueryOntology object at 0x7fbb02189e48>,
 'namespace': rdflib.term.URIRef('http://purl.obolibrary.org/obo/'),
 'namespace_prefix': 'obo', 'query_nsmanager': <rdflib.namespace.NamespaceManager object at 0x7fbaf3f2ff28>, 'resource_type': 'Category',
'prop_datatype': None,
'wikipage_name': 'Category:BFO_0000001', 
'wikipage_content': '\nImported from [[Imported from::obo:BFO_0000001]]\n\nEquivalent URI [[Equivalent URI::http://purl.obolibrary.org/obo/BFO_0000001]]\n\n\nSubcategory of [[:Category:Thing]] [[Category:Thing]]\n\n\nTerm description: [[Has property description::entity@en]]\n\n[[Category:Imported vocabulary]] [[Category:OBO]]'
}