diff --git a/.bumpversion.cfg b/.bumpversion.cfg index b6df388..504d608 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.9.2 +current_version = 0.9.3 commit = True tag = False diff --git a/CITATION.cff b/CITATION.cff index 617df7a..224c493 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -19,4 +19,4 @@ url: 'https://atomrdf.pyscal.org' license: "MIT" repository-code: https://github.com/pyscal/atomRDF type: software -version: 0.9.2 +version: 0.9.3 diff --git a/atomrdf/network/parser.py b/atomrdf/network/parser.py index dce5715..6709f55 100644 --- a/atomrdf/network/parser.py +++ b/atomrdf/network/parser.py @@ -82,6 +82,17 @@ def _recheck_namespaces(self): key ].namespace_with_prefix + def _add_info(self, term, c): + try: + term.description = c.IAO_0000115 + except: + term.description = "" + try: + term.label = c.label + except: + term.label = "" + return term + def _parse_data_property(self): for c in self.tree.data_properties(): iri = c.iri @@ -120,6 +131,8 @@ def _parse_data_property(self): term.domain = dm term.range = rn term.node_type = "data_property" + term = self._add_info(term, c) + self.attributes["data_property"][term.name] = term # assign this data for d in dm: @@ -161,6 +174,7 @@ def _parse_object_property(self): term = OntoTerm(iri, delimiter=self.delimiter) term.domain = dm term.range = rn + term = self._add_info(term, c) term.node_type = "object_property" self.attributes["object_property"][term.name] = term for d in dm: @@ -186,6 +200,7 @@ def _parse_class_basic(self): subclasses.append(c) for sb in subclasses: term = OntoTerm(sb.iri, delimiter=self.delimiter) + term = self._add_info(term, sb) term.node_type = "class" self.attributes["class"][term.name] = term subclasses = [strip_name(sb.iri, self.delimiter) for sb in subclasses] diff --git a/atomrdf/network/term.py b/atomrdf/network/term.py index a852dd0..7ff6e26 100644 --- a/atomrdf/network/term.py +++ b/atomrdf/network/term.py @@ -54,6 +54,8 @@ def __init__( data_type=None, node_id=None, delimiter="/", + description=None, + label=None, ): self.uri = uri @@ -69,6 +71,10 @@ def __init__( self.subclasses = [] self.subproperties = [] self.delimiter = delimiter + self.description = description + self.label = label + self._description = None + self._label = None self.is_domain_of = [] self.is_range_of = [] self._condition = None @@ -98,6 +104,52 @@ def uri(self): def uri(self, val): self._uri = val + @property + def description(self): + """ + Get the description of the term. + + Returns + ------- + str + The description of the term. + """ + return self._description + + @description.setter + def description(self, val): + if isinstance(val, list): + if len(val) == 0: + val = '' + elif len(val) > 1: + val = ". ".join(val) + else: + val = val[0] + self._description = val + + @property + def label(self): + """ + Get the label of the term. + + Returns + ------- + str + The label of the term. + """ + return self._label + + @label.setter + def label(self, val): + if isinstance(val, list): + if len(val) == 0: + val = '' + elif len(val) > 1: + val = ". ".join(val) + else: + val = val[0] + self._label = val + @property def name_without_prefix(self): """ @@ -243,7 +295,7 @@ def toPython(self): return self.uri def __repr__(self): - return str(self.name) + return str(self.name + '\n' + self.description) def _clean_datatype(self, r): if r == "str": diff --git a/setup.py b/setup.py index 0ab2c20..dcc5a0a 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='atomrdf', - version='0.9.2', + version='0.9.3', author='Abril Azocar Guzman, Sarath Menon', author_email='sarath.menon@pyscal.org', description='Ontology based structural manipulation and quering',