Idea / Proposition: Relevance Score in addition to count
Opened this issue · 1 comments
First of all: Thank you so much for providing this plugin and keeping it up-to-date!
I have edited this plugin to include a time-relative score ("relevance") in addition to the Google Scholar citation count. The idea is to allow sorting not by absolute citations, but by relevance. I thought this might help other people, though I'm unsure if it's a good idea to include this in the plugin in general. Perhaps you can consider it or some similar alternative.
I based the score on the number of citations since publication (citations / weeksSincePublication) and rounded to two decimals.
The new format in the 'Extra'-column is: GSCC: 2.22 (000020)
, where 2.22
is the calculated score and 000020
is the absolute citation count.
Code Changes
The changes are made in \chrome\content\gscc.js
- buildCiteCountString
/**
* Create the citation string for use on the item record
* @param {number} citeCount
* @param {ZoteroGenericItem} item
* @returns string
*/
buildCiteCountString: function (citeCount, item) {
let data;
if (citeCount < 0) {
data = this.__noData;
} else {
const formattedCiteCount = $__gscc.util.padCountWithZeros(
citeCount.toString(),
this.__citeCountStrLength
);
// Calculate relative importance score
const publicationDate = item.getField('date');
const weeksSincePublication = Math.ceil((new Date() - new Date(publicationDate)) / (1000 * 60 * 60 * 24 * 7));
const citationRatio = citeCount / weeksSincePublication;
let formattedRatio = citationRatio.toFixed(2);
if (isNaN(formattedRatio)) {
formattedRatio = '0.00';
}
data = `${formattedRatio} (${formattedCiteCount})`;
}
return `${this.__extraEntryPrefix}: ${data}`;
},
- updateItem:
updateItem: function (item, citeCount) {
const fieldExtra = item.getField('extra');
const buildNewCiteCount = this.buildCiteCountString(citeCount, item);
let revisedExtraField;
const regex = new RegExp(`${this.__extraEntryPrefix}: \\d+\\.\\d{2} \\(\\d{7}\\)`, 'g');
if (regex.test(fieldExtra)) {
revisedExtraField = fieldExtra.replace(
regex,
buildNewCiteCount
);
[...]
Hummmm, interesting, I dig it. Let me see about adding this in and I'll drop a few tests in to verify the new functionality. 👍