-
Notifications
You must be signed in to change notification settings - Fork 0
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
collect and normalize tags #1
Comments
@SCVFlare do you want to take a look? |
Hi, added information to a readme. The problem with bulk changing the tags is possible via the api of zotero. i = zot.items()
# see above for example of returned item structure
# modify the latest item which was added to your library
i[0]['data']['title'] = 'The Sheltering Sky'
i[0]['data']['creators'][0]['firstName'] = 'Paul'
i[0]['data']['creators'][0]['lastName'] = 'Bowles'
zot.update_item(i[0]) |
@SCVFlare That will work, but I think a more efficient way to update is from a JS addon: windingwind/zotero-actions-tags#38. Zotero has "tag rename & merge" UI functionality: So far the issue asks for normalization through replacement. It would also be great to have tag enrichment: subconcept -> superconcept, eg
|
@SCVFlare https://www.wikidata.org/wiki/Wikidata:Zotero#Scripts gives as example:
How does that compare to your API research? Can you update your example to show how to edit tags? |
Hi @VladimirAlexiev, The JavaScript API is much more powerful than the web API and may have exactly what you're searching for, however, I can't find it. However, I managed to the same as I did with the web API above - find all the items with the tag and replace it. var tag = "<your tag here>";
var s = new Zotero.Search();
s.libraryID = ZoteroPane.getSelectedLibraryID();
s.addCondition('tag', 'is', tag);
var ids = await s.search();
if (!ids.length) {
return "No items found";
}
await Zotero.DB.executeTransaction(async function () {
for (let id of ids) {
let item = Zotero.Items.get(id);
item.replaceTag(tag, "<new tag name here>");
await item.save({
skipDateModifiedUpdate: true
});
}
});
return ids.length + " tag(s) updated"; This could be appropriated in the same way. by iterating through the old tags, find the item and update in the same vain as the web API. |
Update: I actually found the function rename function in the source code of the Tags object and it's even simpler: var tag = "<old tag>";
var id = new Zotero.Search();
id = ZoteroPane.getSelectedLibraryID();
Zotero.Tags.rename(id,tag,"<new tag here>"); |
zotero-tag
and function "check rarely used tags", see [Feature] tag cleanup (normalize/canonicalize tags) windingwind/zotero-actions-tags#38, but you need to do it collection by collection. add "check rarely used tags" and "export tags" on library, collection, subcollection windingwind/zotero-actions-tags#39 asks for a similar function at library leveland which still need to be normalized (the least used ones)
Copy the
original
tags to a second columnnormalized
, then use clustering to normalize thatwith format
tag: alias, alias2, alias3
eg:The text was updated successfully, but these errors were encountered: