Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rdfpandas/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def _is_curie(value: object) -> bool:

"""

return re.match('^\w*:\w*$', str(value))
return re.match('^[_A-Za-z][-._A-Za-z0-9]*:.+$', str(value))

def _is_uri(value: object) -> bool:
"""
Expand All @@ -321,5 +321,5 @@ def _is_uri(value: object) -> bool:

"""

return re.match('^http[s]?://.*$', str(value))
return re.match('^http[s]?://.+$', str(value))

25 changes: 25 additions & 0 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,31 @@ def test_should_convert_data_frame_to_graph_uriref(self):

self.assertEquals(rdflib.compare.isomorphic(g_expected, g_result), True)

def test_should_convert_data_frame_to_graph_uriref_curie(self):
"""Should create triples based on several compliant CURIES.
"""

ds1 = pd.Series(data=['prefix:suffix'], index = ['http://github.com/cadmiumkitty/rdfpandas/one'], dtype = np.unicode_)
ds2 = pd.Series(data=['preffix-._1.:suffix-._1'], index = ['http://github.com/cadmiumkitty/rdfpandas/one'], dtype = np.unicode_)

df = pd.DataFrame({
'http://github.com/cadmiumkitty/rdfpandas/curie1{URIRef}': ds1,
'http://github.com/cadmiumkitty/rdfpandas/curie2{URIRef}': ds2,
})

g_expected = Graph()

g_expected.add((URIRef('http://github.com/cadmiumkitty/rdfpandas/one'),
URIRef('http://github.com/cadmiumkitty/rdfpandas/curie1'),
URIRef('prefix:suffix')))
g_expected.add((URIRef('http://github.com/cadmiumkitty/rdfpandas/one'),
URIRef('http://github.com/cadmiumkitty/rdfpandas/curie2'),
URIRef('preffix-._1.:suffix-._1')))

g_result = rdfpandas.to_graph(df)

self.assertEquals(rdflib.compare.isomorphic(g_expected, g_result), True)

def test_should_convert_data_frame_to_graph_bnode(self):
"""Should create triples based on BNode instance type.
"""
Expand Down