ricgraph 2.12__tar.gz → 2.13__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ricgraph-2.12/ricgraph.egg-info → ricgraph-2.13}/PKG-INFO +1 -1
- {ricgraph-2.12 → ricgraph-2.13}/README.md +1 -1
- {ricgraph-2.12 → ricgraph-2.13}/pyproject.toml +1 -1
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/__init__.py +1 -0
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/ricgraph.py +15 -15
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/ricgraph_cache.py +2 -2
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/ricgraph_constants.py +25 -0
- ricgraph-2.13/ricgraph/ricgraph_cypher.py +1067 -0
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/ricgraph_file.py +59 -27
- ricgraph-2.13/ricgraph/ricgraph_graphdb.py +987 -0
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/ricgraph_harvest.py +8 -7
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/ricgraph_researchinfo.py +38 -38
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/ricgraph_restapi.py +2 -1
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph/ricgraph_utils.py +34 -15
- {ricgraph-2.12 → ricgraph-2.13/ricgraph.egg-info}/PKG-INFO +1 -1
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph.egg-info/SOURCES.txt +1 -0
- ricgraph-2.12/ricgraph/ricgraph_graphdb.py +0 -1991
- {ricgraph-2.12 → ricgraph-2.13}/LICENSE +0 -0
- {ricgraph-2.12 → ricgraph-2.13}/README-PyPI.md +0 -0
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph.egg-info/dependency_links.txt +0 -0
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph.egg-info/requires.txt +0 -0
- {ricgraph-2.12 → ricgraph-2.13}/ricgraph.egg-info/top_level.txt +0 -0
- {ricgraph-2.12 → ricgraph-2.13}/setup.cfg +0 -0
|
@@ -390,4 +390,4 @@ please let me know by creating a GitHub *Issue* at the top left of that page.
|
|
|
390
390
|
<!-- Do not change the lines below. The version number will be
|
|
391
391
|
modified by script maintenance/update_version.bash -->
|
|
392
392
|
This README.md file is part of the
|
|
393
|
-
documentation for version 2.
|
|
393
|
+
documentation for version 2.13 of Ricgraph - Research in context graph.
|
|
@@ -43,6 +43,7 @@ from .ricgraph_constants import *
|
|
|
43
43
|
from .ricgraph_cache import *
|
|
44
44
|
from .ricgraph_utils import *
|
|
45
45
|
from .ricgraph_file import *
|
|
46
|
+
from .ricgraph_cypher import *
|
|
46
47
|
from .ricgraph_graphdb import *
|
|
47
48
|
from .ricgraph_researchinfo import *
|
|
48
49
|
from .ricgraph_harvest import *
|
|
@@ -98,8 +98,8 @@ In the default configuration of Ricgraph, the following properties are included:
|
|
|
98
98
|
"""
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
import
|
|
102
|
-
import
|
|
101
|
+
from numpy import nan
|
|
102
|
+
from pandas import DataFrame, concat, set_option
|
|
103
103
|
from typing import Union
|
|
104
104
|
from .ricgraph_graphdb import (timestamp,
|
|
105
105
|
create_update_node, create_two_nodes_and_edge,
|
|
@@ -116,7 +116,7 @@ __package__ = 'Ricgraph'
|
|
|
116
116
|
# __version__ should be placed here instead of in __init__.py.
|
|
117
117
|
# If not here, it cannot be found when executing something like
|
|
118
118
|
# PYTHONPATH=../ricgraph ../bin/python ricgraph_explorer.py
|
|
119
|
-
__version__ = '2.
|
|
119
|
+
__version__ = '2.13'
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
# ##############################################################################
|
|
@@ -131,7 +131,7 @@ def get_ricgraph_version() -> str:
|
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
# Note the similarity with create_nodepairs_and_edges_df().
|
|
134
|
-
def update_nodes_df(nodes:
|
|
134
|
+
def update_nodes_df(nodes: DataFrame) -> None:
|
|
135
135
|
"""Update the values in a node, but only if values have been changed.
|
|
136
136
|
This is done for all the nodes passed in the DataFrame.
|
|
137
137
|
|
|
@@ -143,7 +143,7 @@ def update_nodes_df(nodes: pandas.DataFrame) -> None:
|
|
|
143
143
|
"""
|
|
144
144
|
nodes_clean = nodes.copy(deep=True)
|
|
145
145
|
# Ensure that all '' values are NaN, so that those rows can be easily removed with dropna()
|
|
146
|
-
nodes_clean.replace('',
|
|
146
|
+
nodes_clean.replace('', nan, inplace=True)
|
|
147
147
|
nodes_clean.dropna(axis=0, how='any', inplace=True)
|
|
148
148
|
nodes_clean.drop_duplicates(keep='first', inplace=True, ignore_index=True)
|
|
149
149
|
|
|
@@ -171,7 +171,7 @@ def update_nodes_df(nodes: pandas.DataFrame) -> None:
|
|
|
171
171
|
return
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
def create_nodepairs_and_edges_df(left_and_right_nodepairs:
|
|
174
|
+
def create_nodepairs_and_edges_df(left_and_right_nodepairs: DataFrame) -> None:
|
|
175
175
|
"""Create two nodes (called 'node pairs') and two directed edges between those nodes.
|
|
176
176
|
This is done for all the nodes passed. The nodes are specified in a DataFrame.
|
|
177
177
|
One row in the DataFrame contains two nodes which are to be connected.
|
|
@@ -235,10 +235,10 @@ def create_nodepairs_and_edges_params(name1: Union[dict, str], category1: Union[
|
|
|
235
235
|
:return: None.
|
|
236
236
|
"""
|
|
237
237
|
if isinstance(value1, str):
|
|
238
|
-
left_and_right_nodepairs =
|
|
238
|
+
left_and_right_nodepairs = DataFrame(data={'value1': value1},
|
|
239
239
|
index=[0])
|
|
240
240
|
else:
|
|
241
|
-
left_and_right_nodepairs =
|
|
241
|
+
left_and_right_nodepairs = DataFrame(data=value1).copy(deep=True)
|
|
242
242
|
left_and_right_nodepairs.rename(columns={value1.name: 'value1'}, inplace=True)
|
|
243
243
|
|
|
244
244
|
# This makes programming more efficient
|
|
@@ -258,14 +258,14 @@ def create_nodepairs_and_edges_params(name1: Union[dict, str], category1: Union[
|
|
|
258
258
|
if isinstance(other_value, str):
|
|
259
259
|
left_and_right_nodepairs[prop_name + '1'] = other_value
|
|
260
260
|
else:
|
|
261
|
-
left_and_right_nodepairs =
|
|
261
|
+
left_and_right_nodepairs = concat([left_and_right_nodepairs, other_value], axis='columns')
|
|
262
262
|
left_and_right_nodepairs.rename(columns={other_value.name: prop_name + '1'}, inplace=True)
|
|
263
263
|
|
|
264
264
|
if prop_name + '2' == other_name:
|
|
265
265
|
if isinstance(other_value, str):
|
|
266
266
|
left_and_right_nodepairs[prop_name + '2'] = other_value
|
|
267
267
|
else:
|
|
268
|
-
left_and_right_nodepairs =
|
|
268
|
+
left_and_right_nodepairs = concat([left_and_right_nodepairs, other_value], axis='columns')
|
|
269
269
|
left_and_right_nodepairs.rename(columns={other_value.name: prop_name + '2'}, inplace=True)
|
|
270
270
|
|
|
271
271
|
# Reorder a bit, starting with the last, only the name-category-value property, since they will surely exist
|
|
@@ -280,7 +280,7 @@ def create_nodepairs_and_edges_params(name1: Union[dict, str], category1: Union[
|
|
|
280
280
|
return
|
|
281
281
|
|
|
282
282
|
|
|
283
|
-
def unify_personal_identifiers(personal_identifiers:
|
|
283
|
+
def unify_personal_identifiers(personal_identifiers: DataFrame,
|
|
284
284
|
source_event: Union[dict, str], history_event: Union[dict, str]) -> None:
|
|
285
285
|
"""Unify a collection of personal identifiers (e.g. ORCID, ISNI, etc.).
|
|
286
286
|
That means that every column is unified to every other column.
|
|
@@ -305,7 +305,7 @@ def unify_personal_identifiers(personal_identifiers: pandas.DataFrame,
|
|
|
305
305
|
identifiers = personal_identifiers[[column1, column2]].copy(deep=True)
|
|
306
306
|
|
|
307
307
|
# Ensure that all '' values are NaN, so that those rows can be easily removed with dropna()
|
|
308
|
-
identifiers.replace('',
|
|
308
|
+
identifiers.replace('', nan, inplace=True)
|
|
309
309
|
# dropna(how='any'): drop row if one or more row values contain NaN
|
|
310
310
|
identifiers.dropna(axis=0, how='any', inplace=True)
|
|
311
311
|
identifiers.drop_duplicates(keep='first', inplace=True, ignore_index=True)
|
|
@@ -350,10 +350,10 @@ def unify_personal_identifiers(personal_identifiers: pandas.DataFrame,
|
|
|
350
350
|
# This will be executed on module initialization
|
|
351
351
|
|
|
352
352
|
# Make sure DataFrames are printed with all columns on full width
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
set_option('display.max_columns', None)
|
|
354
|
+
set_option('display.width', 500)
|
|
355
355
|
# To prevent warning
|
|
356
356
|
# "FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed
|
|
357
357
|
# in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`.
|
|
358
358
|
# To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`"
|
|
359
|
-
|
|
359
|
+
set_option('future.no_silent_downcasting', True)
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
# ########################################################################
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
import
|
|
45
|
+
from sys import getsizeof
|
|
46
46
|
from typing import Union
|
|
47
47
|
from neo4j.graph import Node
|
|
48
48
|
from .ricgraph_constants import MAX_NODES_CACHE_NODELINK, MAX_NODES_CACHE_KEY_ID
|
|
@@ -193,5 +193,5 @@ def nodes_cache_nodelink_size() -> tuple[int, float]:
|
|
|
193
193
|
global _nodes_cache_nodelink
|
|
194
194
|
|
|
195
195
|
length = len(_nodes_cache_nodelink)
|
|
196
|
-
size_kb = round(
|
|
196
|
+
size_kb = round(getsizeof(_nodes_cache_nodelink) / 1000, 1)
|
|
197
197
|
return length, size_kb
|
|
@@ -104,11 +104,13 @@ MAX_NR_HISTORYITEMS_TO_ADD = 50
|
|
|
104
104
|
#
|
|
105
105
|
# Call the function lookup_resout_type() to do this mapping.
|
|
106
106
|
# If you add a type, also add it to ROTYPE_ALL.
|
|
107
|
+
# If you add a type that is a publication, also add it to ROTYPE_PUBLICATION.
|
|
107
108
|
#
|
|
108
109
|
# This list is inspired by the Strategy Evaluation Protocol 2021-2027
|
|
109
110
|
# https://www.universiteitenvannederland.nl/files/documenten/Domeinen/Onderzoek/SEP_2021-2027.pdf,
|
|
110
111
|
# Appendix E2.
|
|
111
112
|
ROTYPE_ABSTRACT = 'abstract'
|
|
113
|
+
ROTYPE_ARTEFACT = 'artefact'
|
|
112
114
|
ROTYPE_BOOK = 'book'
|
|
113
115
|
ROTYPE_BOOKCHAPTER = 'book chapter'
|
|
114
116
|
ROTYPE_CONFERENCE_ARTICLE = 'conference article'
|
|
@@ -138,6 +140,7 @@ ROTYPE_THESIS = 'thesis'
|
|
|
138
140
|
ROTYPE_WEBSITE = 'website or web publication'
|
|
139
141
|
|
|
140
142
|
ROTYPE_ALL = [ROTYPE_ABSTRACT,
|
|
143
|
+
ROTYPE_ARTEFACT,
|
|
141
144
|
ROTYPE_BOOK,
|
|
142
145
|
ROTYPE_BOOKCHAPTER,
|
|
143
146
|
ROTYPE_CONFERENCE_ARTICLE,
|
|
@@ -165,3 +168,25 @@ ROTYPE_ALL = [ROTYPE_ABSTRACT,
|
|
|
165
168
|
ROTYPE_SOFTWARE,
|
|
166
169
|
ROTYPE_THESIS,
|
|
167
170
|
ROTYPE_WEBSITE]
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
ROTYPE_PUBLICATION = [ROTYPE_ABSTRACT,
|
|
174
|
+
ROTYPE_BOOK,
|
|
175
|
+
ROTYPE_BOOKCHAPTER,
|
|
176
|
+
ROTYPE_CONFERENCE_ARTICLE,
|
|
177
|
+
ROTYPE_EDITORIAL,
|
|
178
|
+
ROTYPE_ENTRY,
|
|
179
|
+
ROTYPE_JOURNAL_ARTICLE,
|
|
180
|
+
ROTYPE_LETTER,
|
|
181
|
+
ROTYPE_MEMORANDUM,
|
|
182
|
+
ROTYPE_METHOD_DESCRIPTION,
|
|
183
|
+
ROTYPE_PATENT,
|
|
184
|
+
ROTYPE_PHDTHESIS,
|
|
185
|
+
ROTYPE_POSTER,
|
|
186
|
+
ROTYPE_PREPRINT,
|
|
187
|
+
ROTYPE_PRESENTATION,
|
|
188
|
+
ROTYPE_REGISTERED_REPORT,
|
|
189
|
+
ROTYPE_REPORT,
|
|
190
|
+
ROTYPE_RETRACTION,
|
|
191
|
+
ROTYPE_REVIEW,
|
|
192
|
+
ROTYPE_THESIS]
|