Skip to content

Commit

Permalink
Release 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalmhjn committed Oct 18, 2023
1 parent 033e491 commit c361b8e
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 44 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
make install
- name: Lint
run: |
make lint
- name: Test
env:
API_KEY: ${{ secrets.API_KEY }}
run: |
make test
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
make install
- name: Lint
run: |
make lint
- name: Test
env:
API_KEY: ${{ secrets.API_KEY }}
run: |
make test
32 changes: 16 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
make install
- name: Lint
run: |
make lint
- name: Test
env:
API_KEY: ${{ secrets.API_KEY }}
run: |
make test
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
make install
- name: Lint
run: |
make lint
- name: Test
env:
API_KEY: ${{ secrets.API_KEY }}
run: |
make test
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
install:
pip install --upgrade pip &&\
pip install -r requirements.txt

lint:
pylint --disable=R,C scopus_caller/call_scopus.py
pylint --disable=R,C scopus_caller/call_semanticscholar.py
pylint --disable=R,C scopuscaller/call_scopus.py
pylint --disable=R,C scopuscaller/call_semanticscholar.py

format:
black *.py
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ specifying the DOI of the article. Abstracts for all SCOPUS database articles ar

## Usage

Import the library and paste the API key.
Import the library and paste the API key. Then run the following code in **Python3** terminal or Jupyter notebook.

```sh
# import the module
import scopus_caller as sc
import scopuscaller as sc

# paste the api here
api_key = ""
Expand Down
18 changes: 11 additions & 7 deletions scopuscaller/call_semanticscholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def call_api_async(session, doi):

async def fetch_articles_async(df):
timeout = aiohttp.ClientTimeout(total=10 * 60)
connector = aiohttp.TCPConnector(limit=5)
connector = aiohttp.TCPConnector(limit=1)

list_doi = list(df["doi"])
list_abstracts = []
Expand All @@ -38,11 +38,15 @@ async def fetch_articles_async(df):
connector=connector, headers=random_headers(), timeout=timeout
) as session: #
tasks = [call_api_async(session, doi) for doi in list_doi]
results = await asyncio.gather(*tasks, return_exceptions=True)
results = await asyncio.gather(*tasks, return_exceptions=False)

for content in results:
list_abstracts.append(content["abstract"])
list_topics.append(content["topics"])
try:
list_abstracts.append(content["abstract"])
list_topics.append(content["topics"])
except:
list_abstracts.append("None")
list_topics.append("None")

return list_abstracts, list_topics

Expand All @@ -64,13 +68,13 @@ def get_abstracts(df):
# Filter out articles with no DOI
df = df[df.doi != "No Doi"]

# Print the number of articles with abstracts
print(f"Articles with abstracts: {len(df)}")

# Run the asyncio event loop to fetch abstracts and topics asynchronously
loop = asyncio.get_event_loop()
list_abstracts, list_topics = loop.run_until_complete(fetch_articles_async(df))

# Print the number of articles with abstracts
print(f"Articles with abstracts: {len(list_abstracts)}")

# Add abstracts and topics to the DataFrame
df["abstract"] = list_abstracts
df["topics"] = list_topics
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = scopus_caller
version = 0.1.2
version = 0.1.3
author = Vishal Mahajan
author_email = vishal.mahajan@tum.de
url = https://github.com/vishalmhjn/scopus_caller
Expand Down

0 comments on commit c361b8e

Please sign in to comment.