Citation(Hashable)

class metaknowledge.citation.Citation(cite, scopusMode=False)

A class to hold citation strings and allow for comparison between them.

The initializer takes in a string representing a WOS citation in the form:

Author, Year, Journal, Volume, Page, DOI
Author is the author’s name in the form of first last name first initial sometimes followed by a period.
Year is the year of publication.
Journal being the 29-Character Source Abbreviation of the journal.
Volume is the volume number(s) of the publication preceded by a V
Page is the page number the record starts on
DOI is the DOI number of the cited record preceeded by the letters 'DOI'
Combined they look like:
Nunez R., 1998, MATH COGNITION, V4, P85, DOI 10.1080/135467998387343

Note: any of the fields have been known to be missing and the requirements for the fields are not always met. If something is in the source string that cannot be interpreted as any of these it is put in the misc attribute. That is the reason to use this class, it gracefully handles missing information while still allowing for comparison between WOS citation strings.

Customizations

Citation’s hashing and equality checking are based on ID() and use the values of author, year and journal.

When converted to a string a Citation will return the original string.

Attributes

As noted above, citations are considered to be divided into six distinct fields (Author, Year, Journal, Volume, Page and DOI) with a seventh misc for anything not in those. Records thus have an attribute with a name corresponding to each author, year, journal, V, P, DOI and misc respectively. These are created if there is anything in the field. So a Citation created from the string: 'Nunez R., 1998, MATH COGNITION' would have author, year and journal defined. While one from 'Nunez R.' would have only the attribute misc.

If the parsing of a citation string fails the attribute bad is set to True and the attribute error is created to contain said error, which is a BadCitation object. If no errors occur bad is False.

The attribute original is the unmodified string (cite) given to create the Citation, it can also be accessed by converting to a string, e.g. with str().

__Init__

Citations can be created by Records or by giving the initializer a string containing a WOS style citation.

Parameters

cite : str

A str containing a WOS style citation.
Extra()

Returns any V, P, DOI or misc values as a string. These are all the values not returned by ID(), they are separated by ' ,'.

FullJournalName()

Returns the full name of the Citation’s journal field. Requires the j9Abbreviations database file.

Note: Requires the j9Abbreviations database file and will raise an error if it cannot be found.

ID()

Returns all of author, year and journal available separated by ' ,'. It is for shortening labels when creating networks as the resultant strings are often unique. Extra() gets everything not returned by ID().

This is also used for hashing and equality checking.

__eq__(other)

First checks DOI for equality then checks each attribute if any are not equal False is returned

__hash__()

A hash for Citation that should be equal to the hash of other citations that are equal to it. Based on the values returned by ID().

__init__(cite, scopusMode=False)

Initialize self. See help(type(self)) for accurate signature.

__repr__()

the representation of the Citation is its original form

__str__()

returns the original string

__weakref__

list of weak references to the object (if defined)

addToDB(manualName=None, manualDB='manualj9Abbreviations', invert=False)

Adds the journal of this Citation to the user created database of journals. This will cause isJournal() to return True for this Citation and all others with its journal.

Note: Requires the j9Abbreviations database file and will raise an error if it cannot be found.

allButDOI()

Returns a string of the normalized values from the Citation excluding the DOI number. Equivalent to getting the ID with ID() then appending the extra values from Extra() and then removing the substring containing the DOI number.

isAnonymous()

Checks if the author is given as '[ANONYMOUS]' and returns True if so.

isJournal(dbname='j9Abbreviations', manualDB='manualj9Abbreviations', returnDict='both', checkIfExcluded=False)

Returns True if the Citation’s journal field is a journal abbreviation from the WOS listing found at http://images.webofknowledge.com/WOK46/help/WOS/A_abrvjt.html, i.e. checks if the citation is citing a journal.

Note: Requires the j9Abbreviations database file and will raise an error if it cannot be found.

Note: All parameters are used for getting the data base with getj9dict.

metaknowledge.citation.filterNonJournals(citesLst, invert=False)

Removes the Citations from citesLst that are not journals

Parameters

citesLst : list [Citation]

A list of citations to be filtered

invert : optional [bool]

Default False, if True non-journals will be kept instead of journals

Returns

list [Citation]

A filtered list of Citations from citesLst