Skip to content

Commit 3c9f27d

Browse files
authored
Merge pull request #676 from KnowledgeCaptureAndDiscovery/dev
Dev
2 parents b1174f5 + bd597be commit 3c9f27d

File tree

3 files changed

+2199
-21
lines changed

3 files changed

+2199
-21
lines changed

pyproject.toml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
[tool.poetry]
22
name = "somef"
3-
version = "0.1.0"
4-
description = ""
5-
authors = ["Jenifer Tabita Ciuciu-Kiss <[email protected]>"]
3+
version = "0.9.5"
4+
description = "SOftware Metadata Extraction Framework: A tool for automatically extracting relevant software information from readme files."
5+
authors = ["Daniel Garijo <[email protected]>"]
6+
packages = [
7+
{ include = "somef", from = "src" }
8+
]
9+
classifiers = [
10+
"Programming Language :: Python :: 3.9",
11+
"Operating System :: OS Independent",
12+
"License :: OSI Approved :: MIT License",
13+
"Topic :: Software Development :: Libraries :: Python Modules"
14+
]
15+
readme = "README.md"
616

717
[tool.poetry.dependencies]
818
python = ">=3.9,<3.12"
@@ -36,6 +46,9 @@ scikit-learn = "^1.3.2"
3646
[tool.poetry.scripts]
3747
somef = "somef.__main__:cli"
3848

49+
[tool.poetry.urls]
50+
homepage = "https://github.com/KnowledgeCaptureAndDiscovery/somef"
51+
3952
[build-system]
4053
requires = ["poetry-core>=1.1.10"]
4154
build-backend = "poetry.core.masonry.api"

src/somef/export/turtle_export.py

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ def reconcile_somef_data(data):
149149
# print(json.dumps(out))
150150
return out
151151

152+
152153
@staticmethod
153154
def apply_mapping(mapping_path, data) -> Graph:
154155

@@ -175,7 +176,16 @@ def apply_mapping(mapping_path, data) -> Graph:
175176
# config = config.replace("$PATH", mapping_path).replace("$DATA", data_file)
176177
# result_graph = morph_kgc.materialize(config)
177178
# os.remove(temp_json_file_path)
178-
179+
180+
# in case parameter 'data' be a path. Example: test_turtle_Export/test_basic_mapping_export
181+
182+
if isinstance(data, str):
183+
try:
184+
with open(data, 'r') as file:
185+
data = json.load(file)
186+
except (json.JSONDecodeError, FileNotFoundError) as e:
187+
return None
188+
179189
# option sending directly the dictionary to materialize. IMPORTANT: just works with rml.ttl, not yml.
180190
config = constants.MAPPING_CONFIG_DICT
181191
config = config.replace("$PATH", mapping_path)
@@ -184,28 +194,33 @@ def apply_mapping(mapping_path, data) -> Graph:
184194
'data_complete': data
185195
}
186196

187-
result_graph = morph_kgc.materialize(config, data_complete)
197+
try:
198+
result_graph = morph_kgc.materialize(config, data_complete)
199+
except Exception as e:
200+
print("Error materialize:")
201+
print(e)
202+
raise
188203

189204
return result_graph
190205

191206
# @staticmethod
192207
# def apply_mapping(mapping_path, data_path) -> Graph:
193-
"""
194-
Given a mapping file and a data file, this method returns the MORPH-KGC materialization for the mapping
195-
Parameters
196-
----------
197-
@param mapping_path: file path of the mapping
198-
@param data_path: file path with the JSON data to transform
199-
200-
Returns
201-
-------
202-
An RDF graph with the desired triples
203-
"""
204-
# mini test for morph-kgc
205-
# config = constants.MAPPING_CONFIG
206-
# # TO DO: Change RML URIs if they have been changed in the configuration.
207-
# config = config.replace("$PATH", mapping_path).replace("$DATA", data_path)
208-
# return morph_kgc.materialize(config)
208+
# """
209+
# Given a mapping file and a data file, this method returns the MORPH-KGC materialization for the mapping
210+
# Parameters
211+
# ----------
212+
# @param mapping_path: file path of the mapping
213+
# @param data_path: file path with the JSON data to transform
214+
215+
# Returns
216+
# -------
217+
# An RDF graph with the desired triples
218+
# """
219+
# # mini test for morph-kgc
220+
# config = constants.MAPPING_CONFIG
221+
# # # TO DO: Change RML URIs if they have been changed in the configuration.
222+
# config = config.replace("$PATH", mapping_path).replace("$DATA", data_path)
223+
# return morph_kgc.materialize(config)
209224

210225
def export_to_file(self, path, graph_format):
211226
"""

0 commit comments

Comments
 (0)