Determining tag frequency of use, and autotagging items with collection name


After spending a lot of time searching without any luck, I've decided to ask:

I was wondering if there is any way for me to easily determine the frequency that all of my tags are used. Additionally, if possible, is there a way to sort the tags selector by frequency instead of alphabetically?

Finally, I was wondering if there's a way to automatically add as a tag every collection and subcollection that a particular item is in? For example, if I have three nested collections: science -> health -> obesity, I'd like Zotero to automatically tag an article with "science", "health," and "obesity" if I add the article to the obesity subcollection. I like the folder structure of collections - it helps me visualize how my research is organized - but I'd also like to search and cross-reference for particular collections.

  • definitely no for the second one.
    For the first one, it depends on "easily". You can filter by each individual tag and then select all in the middle panel for a count.

    You can also export to CSV and then copy out the tag column and then count tags more easily. Not super easy, either.
  • Hmm, interesting. Does there also not exist an addon for this same functionality? Because it'd be incredibly useful.

  • no add-on I'm aware of no. I think Papermachines may give you a tag cloud instead of the regular tag selector, but not sure:
  • Hi rangerunseen,

    If you have access to sqlite3 in the command line this is what I advise you to do.

    sqlite3 /home/<youruser>/.mozilla/firefox/<yourprofile>/zotero/zotero.sqlite

    (the path is for GNU/Linux, but I am sure you will be able to find your zotero.sqlite database path for your architecture; also you can make a copy of your database and run the following commands on it instead if you feel more comfortable, though we are only reading and not writing).

    Type .headers ON to see the headers of the tables and get oriented (.tables gives you the complete list of tables if you want to explore).

    Then issue the query:

    SELECT name, count(tagID) FROM tags JOIN itemTags USING (tagID)
    GROUP BY tagID ORDER BY count(tagID) DESC;

    You can add LIMIT 5 at the end to be sure that you see an example of the output limited to 5 rows. Also consider removing DESC to see the most used tags first.

    Now you are ready to export:

    .mode csv
    .output /home/<yourusername>/Desktop/tagcounts.csv

    Then re-issue the query (remove any LIMITs and order as desired) and you should be able to load the resulting file in any editor or spreadsheet software. Check any sqlite / SQL language tutorial if you want to only output tags with frequencies above or below a certain limit, etc.
  • For Stata users, here's a do-file that extracts the tags and a count of each tag. You have to export your library in .csv format first.
  • An other simple way to have a list of tags : export all your library in unicode, then open the file with excel.
    Then sort the column by name, and only keep the "K1" entries. You can delete all the others lines.

    So you have now in column A all your tags...

    - To have the frenquency of each :
    In column B, you can use this fonction =NB.SI($A$1:$A$8;A1). It counts the frequency of each "tag". Pay attention that this fonction "=NB.SI" is the french one, so it may be a little different in english (I think it should be "=COUNTIF"...).
    You can copy the B column and paste "only value" (in the B column always), then select A+B, and...

    - To have just a list :
    ...use the tool "Unique Records Only" to delete the doubloon lines.

    I hope this is unterstandable, as my english is not very well, especially for this kind of "technical" device !

Sign In or Register to comment.