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

Add a translator for four conferences (CVPR etc.) #3273

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions ICLR.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"translatorID": "2ffde8fb-56d7-478d-9d83-8ad22ba37796",
"label": "ICLR",
"creator": "WEI Qisheng",
"target": "iclr.cc",
"minVersion": "",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-09-09 14:09:20"
}

/*

*/

function detectWeb(doc, url) {
Zotero.debug("【当前url】" + url);

let yearMatch = url.match(/https:\/\/iclr\.cc\/virtual\/(\d{4})\/papers\.html/);
if (yearMatch) {
Zotero.debug("【Year detected】" + yearMatch[1]); // 打印年份
return "multiple";
}
Zotero.debug("【No year detected in the URL】" + url);
return false;
}

function scrape(uid, info) {
if (info === undefined) {
// error!
return;
}

// year
let year = 0;
let yearMatch = info.virtualsite_url.match(/virtual\/(\d{4})\//);
if (yearMatch) {
year = yearMatch[1];
} else {
return; // 或者处理没有找到年份的情况
}

// url
let url;
if (info.paper_url) {
url = info.paper_url;
} else if (info.url) {
url = info.url;
} else {
// TODO
}

// 创建一个新的条目
let item = new Zotero.Item('conferencePaper');
item.title = info.name;
item.abstractNote = info.abstract;
item.url = url;
item.creators = info.authors.map(author => ({
lastName: author.fullname,
creatorType: "author"
}));
item.date = year; // 使用动态年份
item.conferenceName = `${year} International Conference on Learning Representations (ICLR)`;
item.attachments.push({
title: "Full Text PDF",
// url: info.paper_pdf_url,
mimeType: "application/pdf"
});
item.complete();
}

function doWeb(doc, url) {
let yearMatch = url.match(/https:\/\/iclr\.cc\/virtual\/(\d{4})\/papers\.html/);
if (!yearMatch) {
Zotero.debug("Year not found in URL: " + url);
return;
}

let year = yearMatch[1];
Zotero.debug("Processing papers for the year: " + year);

let jsonURL = `https://iclr.cc/static/virtual/data/iclr-${year}-orals-posters.json`;



ZU.doGet(jsonURL, function (text) {
Zotero.debug("Fetched JSON data: " + text.substring(0, 100)); // 打印前100字符以查看结构
let data = JSON.parse(text);
let items = {};
let items_info = {};

let uid;

for (let paper_info of data.results) {
/*
大致分为4类:
1、pdf链接在paper_url
2、pdf链接在url
3、pdf链接在 eventmedia - uri
4、就一篇论文特殊,既不在openreview,又不在jmlr,但是他可以自动走第一类,解析成功
*/
uid = paper_info.uid;
items[uid] = paper_info.name;
items_info[uid] = paper_info;
}

Zotero.selectItems(items, function (selectedItems) {
if (!selectedItems) {
return;
}

let uids = Object.keys(selectedItems);

Zotero.debug("total_number: " + uids.length);

for (let uid of uids) {
scrape(uid, items_info[uid]);
}
})

});


}




/** BEGIN TEST CASES **/
var testCases = [
]
/** END TEST CASES **/

/** BEGIN TEST CASES **/
var testCases = [
]
/** END TEST CASES **/
155 changes: 155 additions & 0 deletions The Computer Vision Foundation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"translatorID": "cf64e005-38f4-4698-82bb-c8b67ffcf05e",
"label": "The Computer Vision Foundation",
"creator": "WEI Qisheng",
"target": "https://openaccess.thecvf.com",
"minVersion": "5.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2024-03-17 11:29:33"
}

/*
Not all CVPR meetings are supported by The CVF, so some papers are not in "openaccess.thecvf.com" (for example, CVPR2012).
*/

function detectWeb(doc, url) {
if (getSearchResults(doc, true) == "multiple") {
return "multiple";
}
else if (getSearchResults(doc, true) == "single") {
return "conferencePaper";
}
return false;
}

function scrape(doc, url) {
let translator = Zotero.loadTranslator('web');
// Embedded Metadata
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');
translator.setDocument(doc);

translator.setHandler('itemDone', (_obj, item) => {
item.complete();
});

translator.getTranslatorObject(function (trans) {
trans.itemType = "conferencePaper";
trans.doWeb(doc, url);
});
}

function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
let items = getSearchResults(doc, false);
Zotero.selectItems(items, function (items) {
if (!items) {
return;
}
ZU.processDocuments(Object.keys(items), scrape);
});
}
else {
scrape(doc, url);
}
}

function getSearchResults(doc, checkOnly) {
let items = {};
let found = false;

let rows_multiple = doc.querySelectorAll('dt a[href*="_paper.html"]');
let rows_single = doc.querySelectorAll('dd a[href*="_paper.pdf"]');

if (rows_multiple.length > 0) {
if (checkOnly) return "multiple";

for (let row of rows_multiple) {
let href = row.href;
let title = ZU.trimInternal(row.textContent);
if (!href || !title) continue;
found = true;
items[href] = title;
}
return found ? items : false;
}
else if (rows_single.length > 0) {
if (checkOnly) return "single";
}

return false;
}/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://openaccess.thecvf.com/CVPR2023?day=all",
"items": "multiple"
},
{
"type": "web",
"url": "https://openaccess.thecvf.com/content/CVPR2023/html/Ci_GFPose_Learning_3D_Human_Pose_Prior_With_Gradient_Fields_CVPR_2023_paper.html",
"items": [
{
"itemType": "conferencePaper",
"title": "GFPose: Learning 3D Human Pose Prior With Gradient Fields",
"creators": [
{
"firstName": "Hai",
"lastName": "Ci",
"creatorType": "author"
},
{
"firstName": "Mingdong",
"lastName": "Wu",
"creatorType": "author"
},
{
"firstName": "Wentao",
"lastName": "Zhu",
"creatorType": "author"
},
{
"firstName": "Xiaoxuan",
"lastName": "Ma",
"creatorType": "author"
},
{
"firstName": "Hao",
"lastName": "Dong",
"creatorType": "author"
},
{
"firstName": "Fangwei",
"lastName": "Zhong",
"creatorType": "author"
},
{
"firstName": "Yizhou",
"lastName": "Wang",
"creatorType": "author"
}
],
"date": "2023",
"conferenceName": "Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition",
"language": "en",
"libraryCatalog": "openaccess.thecvf.com",
"pages": "4800-4810",
"shortTitle": "GFPose",
"url": "https://openaccess.thecvf.com/content/CVPR2023/html/Ci_GFPose_Learning_3D_Human_Pose_Prior_With_Gradient_Fields_CVPR_2023_paper.html",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/
Loading