{
"translatorID": "594ebe3c-90a0-4830-83bc-9502825a6810",
"label": "Web of Science Tagged",
"creator": "Michael Berkowitz, Avram Lyon",
"target": "txt",
"minVersion": "2.1",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 1,
"lastUpdated": "2020-03-28 22:56:16"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2015-2019 Michael Berkowitz, Avram Lyon
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see .
***** END LICENSE BLOCK *****
*/
function detectImport() {
var line;
var i = 0;
while ((line = Zotero.read()) !== false) {
line = line.replace(/^\s+/, "");
if (line != "") {
if (line.substr(0, 4).match(/^PT [A-Z]/)) {
return true;
} else {
if (i++ > 3) {
return false;
}
}
}
}
}
function processTag(item, field, content) {
var map = {
"J": "journalArticle",
"S": "bookSection", // Not sure
"P": "patent",
"B": "book"
};
if (field == "PT") {
item.itemType = map[content];
if (item.itemType === undefined) {
item.itemType = "journalArticle";
Zotero.debug("Unknown type: " + content);
}
} else if ((field == "AF" || field == "AU")) {
//Z.debug("author: " + content);
const authors = content.split("\n");
for (var i=0; i "+content);
}
}
function completeItem(item) {
var i;
var creators = [];
// If we have full names, drop the short ones
if (item.creators[0]["AF"].length) {
creators = item.creators[0]["AF"];
} else {
creators = item.creators[0]["AU"];
}
// Add other creators
if (item.creators[1])
item.creators = creators.concat(item.creators[1]);
else
item.creators = creators;
// If we have a patent, change author to inventor
if (item.itemType == "patent") {
for (i in item.creators) {
if (item.creators[i].creatorType == "author") {
item.creators[i].creatorType = "inventor";
}
}
}
if (item.articleNumber){
if (!item.pages) item.pages = item.articleNumber;
delete item.articleNumber;
}
// Fix caps, trim in various places
for (i in item.tags) {
item.tags[i] = item.tags[i].trim();
if (item.tags[i].toUpperCase() == item.tags[i])
item.tags[i]=item.tags[i].toLowerCase();
}
var toFix = ["publisher", "publicationTitle", "place"];
for (i in toFix) {
var field = toFix[i];
if (item[field] && item[field].toUpperCase() == item[field])
item[field]=ZU.capitalizeTitle(item[field].toLowerCase(),true);
}
item.complete();
}
function doImport(text) {
var tag = data = false;
var debugBuffer = ''; //in case nothing is found
var linesRead = 0, bufferMax = 100;
var line = Zotero.read();
// first valid line is type
while (line !== false && line.replace(/^\s+/, "").substr(0, 6).search(/^PT [A-Z]/) == -1) {
if (linesRead < bufferMax) debugBuffer += line + '\n';
linesRead++;
line = Zotero.read();
}
if (line === false) {
Z.debug("No valid data found\n" +
"Read " + linesRead + " lines.\n" +
"Here are the first " + (linesRead