lisc.data.Articles

class lisc.data.Articles(term)[source]

An object to hold collected ‘words’ data for a specified term.

Attributes
labelstr

The label for the current term.

termTerm

Definition of the search term, with inclusion and exclusion words.

has_databool

Whether the current object contains data.

n_articlesint

The number of articles included in the object.

idslist of int

Article ids for all articles.

titleslist of str

Titles of all articles.

journalslist of tuple of (str, str)

Journals that the articles come from, as (Journal Name, ISO abbreviation).

authorslist of list of str

Authors of all articles, as (Last Name, First Name, Initials, Affiliation).

wordslist of list of str

Words extracted from the abstract of each article.

keywordslist of list of str

Keywords from each article.

yearslist of int

Publication year of each article.

doislist of str

DOIs of each article.

processedbool

Whether the article data has been processed.

__init__(term)[source]

Initialize Articles object.

Parameters
termTerm or str

Search term definition. If input is a string, it is used as the label for the term.

Examples

Initialize an Articles object, with a label for the search term it represents:

>>> articles = Articles('frontal lobe')

Methods

__init__(term)

Initialize Articles object.

add_data(field, new_data)

Add data to object.

clear()

Clear all data attached to object.

load([directory])

Load raw data from json file.

process([process_func])

Process the data stored in the current object.

save([directory])

Save out a json file with all attached data.

save_and_clear([directory])

Save out the attached data and clear the object.

Attributes

has_data

Whether the current object contains data.

label

The label for the current term.

n_articles

The number of articles included in the object.

add_data(field, new_data)[source]

Add data to object.

Parameters
fieldstr

The attribute of the object to add data to.

new_datastr or int or list

Data to add to object.

Examples

Add a journal to an Articles object:

>>> articles = Articles('frontal lobe')
>>> articles.add_data('journals', 'Nature')
clear()

Clear all data attached to object.

property has_data

Whether the current object contains data.

property label

The label for the current term.

load(directory=None)[source]

Load raw data from json file.

Parameters
directorystr or SCDB, optional

Folder or database object specifying the save location.

Examples

Load an Articles object, assuming an SCDB organization named ‘lisc_db’:

>>> from lisc.utils import SCDB
>>> articles = Articles('frontal lobe')
>>> articles.load(SCDB('lisc_db')) 
property n_articles

The number of articles included in the object.

process(process_func=None)[source]

Process the data stored in the current object.

Parameters
process_funccallable, optional

A function to process the articles. Must take as input an Articles object. If not provided, applies the default process_articles function.

save(directory=None)[source]

Save out a json file with all attached data.

Parameters
directorystr or SCDB, optional

Folder or database object specifying the save location.

Examples

Save an Articles object, using a temporary directory:

>>> from tempfile import TemporaryDirectory
>>> articles = Articles('frontal lobe')
>>> with TemporaryDirectory() as dirpath:
...     articles.save(directory=dirpath)
save_and_clear(directory=None)[source]

Save out the attached data and clear the object.

Parameters
directorystr or SCDB, optional

Folder or database object specifying the save location.

Examples

Save and clear data from an Articles object:

>>> from tempfile import TemporaryDirectory
>>> articles = Articles('frontal lobe')
>>> with TemporaryDirectory() as dirpath:
...     articles.save_and_clear(directory=dirpath)

Examples using lisc.data.Articles

Words with Functions

Words with Functions

Tutorial 02: Words Analysis

Tutorial 02: Words Analysis