Skip to content

Commit

Permalink
Fixes URL regex, updates nosetests set up, bumps up the version for r…
Browse files Browse the repository at this point in the history
…elease. (#9)
  • Loading branch information
cadmiumkitty authored Apr 4, 2021
1 parent 1e1679d commit 614457f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
author = 'Eugene Morozov'

# The short X.Y version
version = 'v1.1.0'
version = 'v1.1.1'
# The full version, including alpha/beta/rc tags
release = 'v1.1.0'
release = 'v1.1.1'


# -- General configuration ---------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions rdfpandas/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def to_graph(df: pd.DataFrame, namespace_manager: NamespaceManager = None) -> Gr

for (index, series) in df.iterrows():
for (column, value) in series.iteritems():
match = re.search('([\w?:/.]*)(\{(\w*)\})?(\[(\d*)\])?(\(([\w?:/.]*)\))?(@(\w*))?', column)

# Matching unreserved, gen-delims and sub-delims with exception of "(", ")", "@", "[" and "]" from RFC 3986
match = re.search('([\w\-._~:/?#!$&\'*+,;=]*)(\{(\w*)\})?(\[(\d*)\])?(\(([\w?:/.]*)\))?(@(\w*))?', column)
if pd.notna(value) and pd.notnull(value):
s = _get_identifier(prefixes, index)
p = _get_identifier(prefixes, match.group(1))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name = 'rdfpandas',
version = '1.1.0',
version = '1.1.1',
description = 'RDF support for Pandas',
long_description = readme,
author = 'Eugene Morozov',
Expand Down
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .test_graph import ConversionTestCase
11 changes: 8 additions & 3 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,12 @@ def test_should_convert_data_frame_to_graph_uriref(self):

ds1 = pd.Series(data=['https://google.com'], index = ['http://github.com/cadmiumkitty/rdfpandas/one'], dtype = np.unicode_)
ds2 = pd.Series(data=['skos:broader'], index = ['http://github.com/cadmiumkitty/rdfpandas/one'], dtype = np.unicode_)
ds3 = pd.Series(data=['skos:Concept'], index = ['http://github.com/cadmiumkitty/rdfpandas/one'], dtype = np.unicode_)

df = pd.DataFrame({
'http://github.com/cadmiumkitty/rdfpandas/uri{URIRef}': ds1,
'http://github.com/cadmiumkitty/rdfpandas/curie{URIRef}': ds2
'http://github.com/cadmiumkitty/rdfpandas/curie{URIRef}': ds2,
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type{URIRef}': ds3
})

g_expected = Graph()
Expand All @@ -191,6 +193,9 @@ def test_should_convert_data_frame_to_graph_uriref(self):
g_expected.add((URIRef('http://github.com/cadmiumkitty/rdfpandas/one'),
URIRef('http://github.com/cadmiumkitty/rdfpandas/curie'),
URIRef('skos:broader')))
g_expected.add((URIRef('http://github.com/cadmiumkitty/rdfpandas/one'),
URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
URIRef('skos:Concept')))

g_result = rdfpandas.to_graph(df)

Expand Down Expand Up @@ -333,7 +338,7 @@ def test_should_roundtrip_csv_to_graph_to_csv(self):
"""Should roundtrip DF -> Graph -> DF
"""

df = pd.read_csv('./csv/test.csv', index_col = '@id', keep_default_na = True)
df = pd.read_csv('./tests/csv/test.csv', index_col = '@id', keep_default_na = True)
namespace_manager = NamespaceManager(Graph())
namespace_manager.bind('skos', SKOS)
namespace_manager.bind('rdfpandas', Namespace('http://github.com/cadmiumkitty/rdfpandas/'))
Expand All @@ -348,7 +353,7 @@ def test_should_roundtrip_graph_to_csv_to_graph(self):
"""

g = rdflib.Graph()
g.parse('./rdf/test.ttl', format = 'ttl')
g.parse('./tests/rdf/test.ttl', format = 'ttl')
df = rdfpandas.to_dataframe(g)
print(df.T)
g_result = rdfpandas.to_graph(df, g.namespace_manager)
Expand Down

0 comments on commit 614457f

Please sign in to comment.