ISA SOME (Goat Milk)

ISA SOME (Goat Milk)#

Diese Seite: Sonderfall von BY FROM SOME (Goat Milk):

Ziegenmilch ist eine Milch, die von einer Ziege kommt.

Sonderfall hier: Anders als in BY FROM SOME (Goat Milk) haben wir hier statt BY has_source FROM Animal nun lediglich einen Knoten ISA (ID_003).

Wenn der Knoten SOME goat (ID_999) als Großelternknoten nicht ein BY has_source SOME Animal (ID_003) hat, sondern lediglich ein ISA (ebenfalls ID_003), werden wir für die Codegenerierung von SOME das ISA als einen Spezialfall behandeln:

  • ISA ist äquivalent mit BY anyproperty FROM anything

Hier am Bsp. ID_999

xml_isa = """<map version="freeplane 1.7.0">
<!--To view this file, download free mind mapping software Freeplane from http://freeplane.sourceforge.net -->
<node TEXT="goat-milk-ISA-SOME" ID="ID_0" STYLE="oval" FOLDED="false">
  <node TEXT="TAXONOMY isa" ID="ID_001">
    <node TEXT="Milk" ID="ID_002">
      <font BOLD="true"/>
      <node TEXT="ISA" ID="ID_003"> <!-- variation -->
        <node TEXT="Goat Milk" ID="ID_004" >
        <font BOLD="true"/> 
          <node TEXT="SOME Goat" ID="ID_999" />  <!-- this is our FOCUS -->
        </node>
        <node TEXT="Cow Milk" ID="ID_1466284350">
          <font BOLD="true"/>
          <node TEXT="SOME Cow" ID="ID_396346079"/>
        </node>
      </node>
    </node>
  </node>
</node>
</map>
"""

Write to mm file; read mm file:

with open("goat-milk-ISA-SOME.mm", "w") as goatmilkfile_isa:
    goatmilkfile_isa.write(xml_isa)

from gd07 import GenDifS
m = GenDifS("goat-milk-ISA-SOME.mm", verb=2)

Compile:

m.compile(language_list_list=['RDFStest', 'OWLtest', 'OWL', 'RDFS'])
m.taxonomies_by_name.keys()
dict_keys(['isa'])
isa = m.taxonomies_by_name["isa"]
ID_999 = isa.dict_of_all_gdn['ID_999']
ID_999.molecule_dict
{'DE': '# ID_999 DE\n:Goat_Milk :explanation "*:Goat_Milk* ist eine Subklasse der Klasse *:Milk* ." . \n:Goat :explanation "*Goat* ist eine Subklasse der Klasse *anything* ." .  \n:Milk :explanation "Ein *:Milk*, das für das Attribut *anyproperty* einen Wert aus  *Goat* hat, ist ein *{ species.c(reverse = True) }*." .  ',
 'RDFS': '# ID_999 RDFS\n:Goat_Milk a owl:Class;\n   rdfs:subClassOf :Milk .\n:Goat rdfs:subClassOf :anything .',
 'OWL': '# ID_999 OWL\n:anyproperty rdf:type owl:ObjectProperty .\n:BY_SOME_ID_999_restriction a owl:class ;\n   a owl:Restriction ;\n   rdfs:label "BY_ex:anyproperty_FROM_ex:anything_SOME_ex:Goat" ;\n   owl:onProperty :anyproperty ;\n   owl:someValuesFrom :Goat .\n:BY_SOME_ID_999_intersection a owl:class ;\n   rdfs:label "(BY_ex:anyproperty_FROM_ex:anything_SOME_ex:Goat)_INTERSECT_ex:Milk" ;\n   rdfs:subClassOf :Goat_Milk ;\n   owl:intersectionOf (:BY_SOME_ID_999_restriction :Milk ) .',
 'OWLtest': '# ID_999 OWLtest\nex:Goat_Milk_ID_999 a :Goat_Milk .\nex:Milk_ID_999   a :Milk ;\n   :anyproperty ex:Goat_ID_999 ;\n   gendifs:classify_similar ex:Goat_Milk_ID_999 .\nex:Goat_ID_999 a :Goat .',
 'SKOS': '# ID_999 SKOS\ncpt:Milk a skos:Concept .\ncpt:Goat_Milk a skos:Concept ;\n   skos:broader cpt:Milk .\ncpt:anything a skos:Concept .\ncpt:Goat a skos:Concept ;\n   skos:broader cpt:anything .\ncpt:anyproperty   a rdfs:Property ;\n   rdfs:subPropertyOf skos:related .'}
ID_999.molecule_per_language.entity_context
{'id': 'ID_999',
 'codeclass': 'BY_SOME',
 'genus': Entity(self.source_gdn.id='ID_002', self.text='Milk'),
 'by': Entity(self.source_gdn.id='ID_999', self.text='anyproperty'),
 'frm': Entity(self.source_gdn.id='ID_999', self.text='anything'),
 'some': Entity(self.source_gdn.id='ID_999', self.text='Goat'),
 'species': Entity(self.source_gdn.id='ID_004', self.text='Goat_Milk')}
ID_999.molecule_per_language.inspect_inferencing.test_results
{(b'urn:ex#Milk_ID_999', b'urn:ex#Goat_Milk_ID_999'): {'cat1 not empty': True,
  'cat2 not empty': True,
  'disjoint before': True,
  'subset after': True,
  'ok': True}}
def focus(focus_curie_list, ttl):
    return "\n\n".join( [ paragraph for paragraph in ttl.split("\n\n") \
                         if any( [ focus_curie in paragraph for focus_curie in focus_curie_list ] ) ] )
g1_ttl =  ID_999.molecule_per_language.inspect_inferencing.g1.serialize()
print( focus(["ex:Milk_ID_999"], g1_ttl) )
ex:Milk_ID_999 a :Milk ;
    :anyproperty ex:Goat_ID_999 ;
    gendifs:classify_similar ex:Goat_Milk_ID_999 .
g2_ttl = ID_999.molecule_per_language.inspect_inferencing.g2.serialize()
print( focus([ "ex:Milk_ID_999"], g2_ttl) )
ex:Milk_ID_999 a owl:Thing,
        :BY_SOME_ID_999_intersection,
        :BY_SOME_ID_999_restriction,
        :Goat_Milk,
        :Milk ;
    owl:sameAs ex:Milk_ID_999 ;
    :anyproperty ex:Goat_ID_999 ;
    gendifs:classify_similar ex:Goat_Milk_ID_999 .