Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea / Proposition: Relevance Score in addition to count #28

Open
c-hoffmann opened this issue Sep 11, 2024 · 1 comment
Open

Idea / Proposition: Relevance Score in addition to count #28

c-hoffmann opened this issue Sep 11, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@c-hoffmann
Copy link

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

  1. 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}`;
  },
  1. 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
      );
[...]
@justinribeiro justinribeiro added the enhancement New feature or request label Sep 11, 2024
@justinribeiro justinribeiro self-assigned this Sep 11, 2024
@justinribeiro
Copy link
Owner

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. 👍

@justinribeiro justinribeiro added this to the v4.2.0 milestone Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants