summaryrefslogtreecommitdiff
path: root/Neural Information Processing Systems.js
blob: 704849b942eee9baeaa4db0260bf6a3241f5c945 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
	"translatorID": "c816f8ad-4c73-4f6d-914e-a6e7212746cf",
	"label": "Neural Information Processing Systems",
	"creator": "Fei Qi, Sebastian Karcher",
	"target": "^https?://(?:books|papers)\\.nips\\.cc/",
	"minVersion": "3.0",
	"maxVersion": "",
	"priority": 100,
	"inRepository": true,
	"translatorType": 4,
	"browserSupport": "gcsibv",
	"lastUpdated": "2014-03-11 19:45:28"
}

function detectWeb(doc, url) {
	var contRe = /\/book\//;
	var m = contRe.exec( url );
	if (m && ZU.xpathText(doc, '//ul/li/a[contains(@href, "paper")]')) return "multiple";
	else if (url.indexOf("/paper/") && ZU.xpathText(doc, '//meta[@name="citation_title"]/@content')) return "bookSection";
	return false;
}

function scrape(doc, url) {
		var pdfurl = url + ".pdf";
		var bibtexurl = url+ "/bibtex"
		Zotero.Utilities.HTTP.doGet(bibtexurl, function( text ) {
			var translator = Zotero.loadTranslator("import");
			translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
			// Zotero.debug( text );
			translator.setString( text );
			translator.setHandler( "itemDone", function( obj, item ) {
				item.attachments = [{url: pdfurl, title:"NIPS Full Text PDF", mimeType:"application/pdf"},
									{document: doc, title: "NIPS Snapshort", mimeTYpe: "text/html"}];
				item.complete();
			});
			translator.translate();
		});
}

function doWeb( doc, url ) {
	var titleRe = '//ul/li/a[contains(@href, "paper")]';
	if (detectWeb(doc, url) == "multiple") {
		// Retrive items
		var items = new Object();
		var arts = new Array();
		var titles =  doc.evaluate( titleRe, doc, null, XPathResult.ANY_TYPE, null);
		while( title = titles.iterateNext()) {
			var art = new Object;
			items[title.href] = title.textContent;
		}
		Zotero.selectItems(items, function (items) {
			if (!items) {
				return true;
			}
			for (var i in items) {
				arts.push(i);
			}
			ZU.processDocuments(arts, scrape)
		});
	}
	else{
		scrape(doc, url)
	}
}
/** BEGIN TEST CASES **/
var testCases = [
	{
		"type": "web",
		"url": "http://papers.nips.cc/paper/3689-information-theoretic-lower-bounds-on-the-oracle-complexity-of-convex-optimization",
		"items": [
			{
				"itemType": "bookSection",
				"creators": [
					{
						"firstName": "Alekh",
						"lastName": "Agarwal",
						"creatorType": "author"
					},
					{
						"firstName": "Martin J",
						"lastName": "Wainwright",
						"creatorType": "author"
					},
					{
						"firstName": "Peter L.",
						"lastName": "Bartlett",
						"creatorType": "author"
					},
					{
						"firstName": "Pradeep K.",
						"lastName": "Ravikumar",
						"creatorType": "author"
					},
					{
						"firstName": "Y.",
						"lastName": "Bengio",
						"creatorType": "editor"
					},
					{
						"firstName": "D.",
						"lastName": "Schuurmans",
						"creatorType": "editor"
					},
					{
						"firstName": "J. D.",
						"lastName": "Lafferty",
						"creatorType": "editor"
					},
					{
						"firstName": "C. K. I.",
						"lastName": "Williams",
						"creatorType": "editor"
					},
					{
						"firstName": "A.",
						"lastName": "Culotta",
						"creatorType": "editor"
					}
				],
				"notes": [],
				"tags": [],
				"seeAlso": [],
				"attachments": [
					{
						"title": "NIPS Full Text PDF",
						"mimeType": "application/pdf"
					},
					{
						"title": "NIPS Snapshort",
						"mimeTYpe": "text/html"
					}
				],
				"itemID": "NIPS2009_3689",
				"title": "Information-theoretic lower bounds on the oracle complexity of convex optimization",
				"pages": "1–9",
				"date": "2009",
				"publisher": "Curran Associates, Inc.",
				"url": "http://papers.nips.cc/paper/3689-information-theoretic-lower-bounds-on-the-oracle-complexity-of-convex-optimization.pdf",
				"libraryCatalog": "Neural Information Processing Systems",
				"bookTitle": "Advances in Neural Information Processing Systems 22"
			}
		]
	},
	{
		"type": "web",
		"url": "http://papers.nips.cc/book/advances-in-neural-information-processing-systems-22-2009",
		"items": "multiple"
	}
]
/** END TEST CASES **/