Code Monkey home page Code Monkey logo

pycite's Introduction

pycite: Python Citations Generator

DOI PyPI version fury.io Project Status Codecov Test-Package PyPI license Documentation Status Total Downloads Monthly Downloads Weekly Downloads Maintenance GitHub last commit GitHub issues GitHub issues-closed

pycite is a simple to use python citations generator.

Supported Reference Styles

  • Harvard

Supported Paper Sources

  • NCBI

  • Pubmed

  • ScienceDirect

  • JSTOR (Support dropped on 5th November 2021 Why? Uses dynamic JS that we do not want to work with for now.)

Supported file formats

pycite generates citations given a file of the following types:

  • Text files (.txt)

Installation

The simplest way to install the latest release is as follows:

pip install pycite

To install the development version:

Open the Terminal/CMD/Git bash/shell and enter

pip install git+https://github.com/Nelson-Gon/pycite.git

# or for the less stable dev version
pip install git+https://github.com/Nelson-Gon/pycite.git@dev

Otherwise:

# clone the repo
git clone [email protected]:Nelson-Gon/pycite.git
cd pycite
pip install .  

Usage

Script Mode

To use at the command line, please use:

python -m pycite -i testfiles/testlinks.txt -o testfiles/citations.txt

To get help:

python -m pycite --help
#usage: __main__.py [-h] -i INPUT_FILE -o OUTPUT_FILE
#
#optional arguments:
#  -h, --help            show this help message and exit
#  -i INPUT_FILE, --input-file INPUT_FILE
#                        Path to an input file
#  -o OUTPUT_FILE, --output-file OUTPUT_FILE
#                        Path to an output file

Programming Mode

First, one needs to create an object of class PyCite

from pycite.pycite import PyCite
# Need an input-output file pair 
my_citations = PyCite(input_file="testfiles/testlinks.txt", output_file="testfiles/citations.txt")

To generate citations, one simply calls the cite method.

# This will write citations in the provided output file 
my_citations.cite()

The above creates citations as required (only the first line shown here). See citations.txt for the full file.

Pohorille A, Wilson MA, & Shannon G (2017)  Flexible Proteins at the Origin of Life Life (Basel), 7(2),  23.  [Accessed 16/Sep/2021]

Note

pycite is free software that the author hopes could be of use to someone else and enable them to perform reproducible science.

If you have any concerns, especially regarding the papers used to test that the software works, please contact the author. In the event that you notice that any of the papers used in the tests has been retracted, please immediately inform the author to remove that paper.

Thank you very much and keep building,

For Science!

To report any issues, suggestions or improvement, please do so at issues.

“Before software can be reusable it first has to be usable.” – Ralph Johnson

pycite's People

Contributors

leevic31 avatar nelson-gon avatar swanand01 avatar theanshul756 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

pycite's Issues

Automated documentation and release

Description

I would like to automate the doc generation and release process.

Similar Features

This is similar to scripts/mkdocs.sh and scripts/release.sh.

Feature Details

Sufficiently described.

Proposed Implementation

Use an Actions run to automate these e.g. "on release" to run "release.sh". Should also set environmental variables i.e. PyPI username and password.

Science Direct citations mix up years, volumes, and pages

Describe the bug

For papers from sciencedirect.com, sometimes year is in place of volume and volume in place of year.

To Reproduce

Run tests/workflows for https://github.com/Nelson-Gon/pycite/tree/b116046ddf7f316eff4e6a4bc5aaad899bc11cda and look at the last two citations.

Expected behavior

Expected a consistent output regardless of paper since it is the same website.

Unexpected behavior

Got differing citations based on link/paper.

System Details

Dev version: https://github.com/Nelson-Gon/pycite/tree/b116046ddf7f316eff4e6a4bc5aaad899bc11cda
Windows 10, Ubuntu 18.04

Sort generated citations alphabetically

Description

As per Harvard citation standards, the citation list should be ordered alphabetically.

Similar Features

Related to pycite.cite() and/or the individual *_final_citation

Feature Details

Sufficiently described.

Proposed Implementation

A simple name based sort of the generated citation list?

Single Author Citations Start Author Name with an "&"

Describe the bug

In the final citation, if there is only one author, the citation begins with an &.

To Reproduce

Using latest dev version on a paper like https://www.sciencedirect.com/science/article/pii/S138824571730055X, one will get something like:

'& Hallett M (2017) Smart brain stimulation. Clinical Neurophysiology, 128(5), 839-840'

Expected behavior

Expected 'Hallett M (2017) Smart brain stimulation. Clinical Neurophysiology, 128(5), 839-840'

Unexpected behavior

Described above.

System Details

Dev version https://github.com/Nelson-Gon/pycite/tree/b116046ddf7f316eff4e6a4bc5aaad899bc11cda

Script Generator Fails on Linux Systems

Describe the bug

When running bash scripts/mkdocs.sh, I received errors.

To Reproduce

On a Linux system while in the directory's root, run bash scripts/mkdocs.sh.

Expected behavior

I expected to have documentation build flawlessly or at least attempt to build.

Unexpected behavior
I received the following errors:

/usr/bin/python3: No module named m2r
mv: cannot stat '.github/CONTRIBUTING.rst': No such file or directory
mv: cannot stat 'README.rst': No such file or directory
mv: cannot stat 'changelog.rst': No such file or directory
Building docs for pycite
scripts/mkdocs.sh: line 23: ./make.bat: Permission denied

System Details

OS: Linux 5.8.0-55-generic #62~20.04.1-Ubuntu

Package hash: https://github.com/Nelson-Gon/pycite/tree/914367ac61bd11d2e7ed4bb84e716cc45392ea38

Use logging for verbose console messages

Description

I would like to have a log file that shows me all the messages that are produced on the console.

Similar Features

This is currently done by writing messages to the console. However, for future reference, it would be great to provide a log file that holds all these messages.

Feature Details

Sufficiently described above.

Proposed Implementation

Use the logging module. In addition, it would be great to have some sort of control over this logging process and/or disable it optionally.

Support JSTOR papers

Description

I would like to cite papers from JSTOR

Similar Features

Similar to NCBI and other sources.

Feature Details

Full Harvard citation as required.

Proposed Implementation

  • Access dynamically loaded elements e.g. journal volume, journal pages. Use selenium/webdriver
  • Create citation as required.
  • Fix 403s in jstor tests

Support for PubMed papers

Description

I would like to generate citations for papers obtained from PubMed.

Similar Features

Similar to PyCite.cite

Feature Details

Sufficiently described. Need to generate citations for websites like https://pubmed.ncbi.nlm.nih.gov/paperidhere

Proposed Implementation

Probably need to rethink the selectors.

Post Proposal Edits

  • Fix inconsistent year_journal_volume lengths
  • Convert the last author to & instead of ,
  • Add Page numbers where applicable.

Error message when running program based on README.rst instructions

Describe the bug

When running the program per the directions in README.rst, the program errors out

To Reproduce

Go to line 162 of README.rst and do as follows:

from pycite.pycite import PyCite
my_citations = PyCite(input_file="testfiles/testlinks.txt", output_file="testfiles/citations.txt")
my_citations.cite()

my_citations.cite() will run correctly for a short time and then give the following error message when trying to cite this (https://www.sciencedirect.com/science/article/pii/S0301051117302314) article:

(Traceback (most recent call last):
File "", line 1, in
File "/home/hudsonlanier/.virtualenvs/pycite/lib/python3.9/site-packages/pycite/pycite.py", line 132, in cite
title = bs4_link.find_all("h1", {"class": "content-title"})[0].text
IndexError: list index out of range)

Expected behavior
The expectation is that this will either correctly cite the article or at least not error out the program as a result of not being able to cite the article.

Unexpected behavior

Traceback (most recent call last):
File "", line 1, in
File "/home/hudsonlanier/.virtualenvs/pycite/lib/python3.9/site-packages/pycite/pycite.py", line 132, in cite
title = bs4_link.find_all("h1", {"class": "content-title"})[0].text
IndexError: list index out of range

System Details


Support ScienceDirect as a paper source

Description

I would like to build citations for papers that come from Science Direct.

Similar Features

Similar to functions in ncbi.py and pubmed.py.

Feature Details

Same as above.

Proposed Implementation

None for now. A checklist

  • Minimal Working Citations
  • Fully working citations with authors, year, title, volume, pages, and an optional DOI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.