From ce780444ea066b72f58cacf0ccd776092bf35fd5 Mon Sep 17 00:00:00 2001 From: Sarath Date: Wed, 10 Jul 2024 15:43:02 +0200 Subject: [PATCH 1/6] add label and desc to term --- atomrdf/network/term.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/atomrdf/network/term.py b/atomrdf/network/term.py index a852dd0..f55c904 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,8 @@ def __init__( self.subclasses = [] self.subproperties = [] self.delimiter = delimiter + self.description = description + self.label = label self.is_domain_of = [] self.is_range_of = [] self._condition = None From 8473b79e3822c04ee9a80432f5f3b13d712da6f4 Mon Sep 17 00:00:00 2001 From: Sarath Date: Wed, 10 Jul 2024 15:46:25 +0200 Subject: [PATCH 2/6] fix types of desc and labe; --- atomrdf/network/term.py | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/atomrdf/network/term.py b/atomrdf/network/term.py index f55c904..6b988db 100644 --- a/atomrdf/network/term.py +++ b/atomrdf/network/term.py @@ -73,6 +73,8 @@ def __init__( 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 @@ -102,6 +104,48 @@ 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) > 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) > 1: + val = ". ".join(val) + else: + val = val[0] + self._label = val + @property def name_without_prefix(self): """ From ea8fc60e4f5c3035a350e9423acd09ffc3e8fc9f Mon Sep 17 00:00:00 2001 From: Sarath Date: Wed, 10 Jul 2024 15:48:17 +0200 Subject: [PATCH 3/6] fix types of desc and labe; --- atomrdf/network/term.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/atomrdf/network/term.py b/atomrdf/network/term.py index 6b988db..fec5ff9 100644 --- a/atomrdf/network/term.py +++ b/atomrdf/network/term.py @@ -119,7 +119,9 @@ def description(self): @description.setter def description(self, val): if isinstance(val, list): - if len(val) > 1: + if len(val) == 0: + val = '' + elif len(val) > 1: val = ". ".join(val) else: val = val[0] @@ -140,7 +142,9 @@ def label(self): @label.setter def label(self, val): if isinstance(val, list): - if len(val) > 1: + if len(val) == 0: + val = '' + elif len(val) > 1: val = ". ".join(val) else: val = val[0] From a93d0ac4e25cae01784c413b42e974d9d67153a5 Mon Sep 17 00:00:00 2001 From: Sarath Date: Wed, 10 Jul 2024 15:52:11 +0200 Subject: [PATCH 4/6] add label and desc to terms --- atomrdf/network/parser.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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] From 0c5a65059a50479a3e0a9243493c5b4001de1760 Mon Sep 17 00:00:00 2001 From: Sarath Date: Wed, 10 Jul 2024 15:59:59 +0200 Subject: [PATCH 5/6] add desc to __str__ method of term --- atomrdf/network/term.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atomrdf/network/term.py b/atomrdf/network/term.py index fec5ff9..7ff6e26 100644 --- a/atomrdf/network/term.py +++ b/atomrdf/network/term.py @@ -295,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": From 0c0308bd7ef280910738de0ec2f7f59f98202b38 Mon Sep 17 00:00:00 2001 From: Sarath Date: Wed, 10 Jul 2024 16:00:07 +0200 Subject: [PATCH 6/6] =?UTF-8?q?Bump=20version:=200.9.2=20=E2=86=92=200.9.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- CITATION.cff | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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',