rmzelle / ref-extractor

Reference Extractor - Extract Zotero/Mendeley references from Microsoft Word files
https://rintze.zelle.me/ref-extractor/
MIT License
328 stars 20 forks source link

Citations by count #45

Closed mbroedl closed 2 months ago

mbroedl commented 3 months ago

Hej, There is the scenario of reducing the word count by removing little used references. I use the tool quite often to count references for this purpose, and then I have to look in the JSON for items cited once or twice.

I suggest including an option to sort references by cite count into the bibliography to make this easier and accessible for my non tech-savvy colleagues. In this fork, the citation count is added in front of each item in the APA bibliography and it is sorted ascendingly, so that little used items are on top of the list. Technically, I transferred the count into APA by moving it from the notes to the title, then once the bibliography is rendered to the front. To not destroy the usability of the CSL JSON, this all happens in the convertOutput-function by parsing and then re-stringifying the JSON.

It works well locally on two examples. It would only fail if the tick box for counting is not pressed, or when an item has no title.

I hope you can consider it for merging and including in the website. With best wishes, Malte

rmzelle commented 2 months ago

@mbroedl, thanks, interesting idea. Maybe it would be handier to provide a CSV or TSV output format option for more robust sorting/analysis? This could be as simple as a two-column file with the citation count in one column and the formatted citation in the other.

mbroedl commented 2 months ago

@rmzelle Excellent idea! I've implemented and troubleshooted this now. The text field (and export) is now a two-column tsv with cite_count and reference as the column headers.

rmzelle commented 2 months ago

Hi @mbroedl, I adjusted your code a little and removed the "Store cite counts" toggle in favor of more output options, which I think makes the tool simpler to use. I think it works but I'd welcome any testing and/or code review before I merge.

mbroedl commented 2 months ago

Hej @rmzelle — It looks good and feels much more intuitive now! Made two small changes:

Looks good to me now!

rmzelle commented 2 months ago

Thanks so much for the PR, and having patience :).

mbroedl commented 2 months ago

Thank you for being so kind and responsive. :)