Skip to content
This repository was archived by the owner on Oct 5, 2023. It is now read-only.

Commit a6d4d64

Browse files
authored
Merge pull request #23 from coreofscience/scopus-support
scopus support
2 parents 53dacba + ae80b24 commit a6d4d64

File tree

9 files changed

+76926
-26
lines changed

9 files changed

+76926
-26
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: [3.6, 3.7, 3.8]
18+
python-version: [3.7, 3.8, 3.9]
1919

2020
steps:
2121
- uses: actions/checkout@v2
@@ -49,4 +49,4 @@ jobs:
4949
sap describe example/sample.isi
5050
sap root example/sample.isi
5151
sap trunk example/sample.isi
52-
sap leaf example/sample.isi
52+
sap leaf example/sample.isi

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# History
22

3+
## 2.0.0 (2020-10-16)
4+
5+
- Uses a newer version of `python-wostools` that adds support to scopus.
6+
- Now you can mix and match ISI and Scopus RIS files in your trees.
7+
38
## 1.0.2 (2020-08-15)
49

510
- Fixed small styling issue on the template.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@ to explore all the commands and options you can use.
5757
The Python API is quite small, here's the minimal working example:
5858

5959
```python
60-
from sap import load, Sap, CachedCollection, giant
60+
from sap import load, Sap, Collection, giant
6161

6262
sap = Sap()
63-
graph = giant(CachedCollection(file1, file2, ...))
63+
graph = giant(Collection(file1, file2, ...))
6464
tree = sap.tree(graph)
6565
```
6666

6767
Or if you prefer to user the filenames, you may use:
6868

6969
```python
70-
from sap import load, Sap, CachedCollection, giant
70+
from sap import load, Sap, Collection, giant
7171

7272
sap = Sap()
73-
graph = giant(CachedCollection.from_filenames(filename1, filename2, ...))
73+
graph = giant(Collection.from_filenames(filename1, filename2, ...))
7474
tree = sap.tree(graph)
7575
```
7676

example/bit-pattern-savedrecs.txt

Lines changed: 41086 additions & 0 deletions
Large diffs are not rendered by default.

example/example.ipynb

Lines changed: 7 additions & 7 deletions
Large diffs are not rendered by default.

example/scopus.ris

Lines changed: 35808 additions & 0 deletions
Large diffs are not rendered by default.

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
requirements = [
1111
"Click>=7.0,<8",
1212
"python-igraph>=0.8.0,<1",
13-
"wostools>=2.0.7,<3",
13+
"wostools>=3.0.2,<4",
1414
]
1515

1616
setup_requirements = [
@@ -33,9 +33,9 @@
3333
"License :: OSI Approved :: MIT License",
3434
"Natural Language :: English",
3535
"Programming Language :: Python :: 3",
36-
"Programming Language :: Python :: 3.6",
3736
"Programming Language :: Python :: 3.7",
3837
"Programming Language :: Python :: 3.8",
38+
"Programming Language :: Python :: 3.9",
3939
],
4040
description="Python Tree of Science package",
4141
entry_points={"console_scripts": ["sap=sap.cli:main"]},
@@ -53,6 +53,6 @@
5353
test_suite="tests",
5454
tests_require=test_requirements,
5555
url="https://github.com/coreofscience/python-sap",
56-
version="1.0.2",
56+
version="2.0.0",
5757
zip_safe=False,
5858
)

src/sap/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from typing import Iterator, List, Optional
55

66
from igraph import Graph
7-
from wostools import CachedCollection
7+
from wostools import Collection
88

99
__author__ = """Daniel Stiven Valencia Hernadez"""
1010
__email__ = "dsvalenciah@gmail.com"
11-
__version__ = "1.0.2"
11+
__version__ = "2.0.0"
1212

1313
MODE_IN = "IN"
1414
MODE_OUT = "OUT"
@@ -221,12 +221,12 @@ def tree(self, graph: Graph, clear: Optional[bool] = None) -> Graph:
221221
return graph
222222

223223

224-
def load(collection: CachedCollection) -> Iterator[Graph]:
224+
def load(collection: Collection) -> Iterator[Graph]:
225225
"""
226226
Takes in a collection of bibliographic records and gets out all the
227227
connected components of their citation graph.
228228
229-
:param CachedCollection collection: bibliographic collection
229+
:param Collection collection: bibliographic collection
230230
:return: iterator over the connected components
231231
"""
232232
metadata = {}
@@ -251,17 +251,18 @@ def load(collection: CachedCollection) -> Iterator[Graph]:
251251
).indices
252252
graph = graph.subgraph(valid_vs)
253253
graph = _break_loops(graph)
254+
yield graph
254255
for subgraph in graph.decompose(MODE_WEAK, minelements=2):
255256
if len(subgraph.vs.select(_indegree_gt=0, _outdegree_gt=0)) > 0:
256257
yield subgraph
257258

258259

259-
def giant(collection: CachedCollection) -> Graph:
260+
def giant(collection: Collection) -> Graph:
260261
"""
261262
Takes in a collection of bibliographic records and gets out the giant pre
262263
processed connected component.
263264
264-
:param CachedCollection collection: bibliographic collection
265+
:param Collection collection: bibliographic collection
265266
:return: connected component graph
266267
"""
267268
return next(load(collection), None)

src/sap/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import click
55

6-
from sap import CachedCollection, Sap, giant, load
6+
from sap import Collection, Sap, giant, load
77

88
logger = logging.getLogger(__name__)
99

@@ -70,7 +70,7 @@ def export(ctx, sources, output):
7070
Creates a tree from a set of files and stores it in graphml format.
7171
"""
7272
sapper = ctx.obj["sapper"]
73-
graph = giant(CachedCollection(*sources))
73+
graph = giant(Collection(*sources))
7474
graph = sapper.tree(graph)
7575
graph.write(output, format="graphml")
7676

@@ -84,7 +84,7 @@ def describe(ctx, sources, output):
8484
Describe every graph in a given bibliography collection.
8585
"""
8686
sapper = ctx.obj["sapper"]
87-
for graph in load(CachedCollection(*sources)):
87+
for graph in load(Collection(*sources)):
8888
try:
8989
graph = sapper.tree(graph)
9090
click.echo(graph.summary() + "\n")
@@ -150,7 +150,7 @@ def root(ctx, sources, output, _open):
150150

151151

152152
def show(part, sapper, sources, output, _open):
153-
for graph in load(CachedCollection(*sources)):
153+
for graph in load(Collection(*sources)):
154154
tree = sapper.tree(graph)
155155
items = sorted(
156156
[

0 commit comments

Comments
 (0)