Skip to content

Commit

Permalink
Update tag parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
thebluepotato committed Oct 1, 2024
1 parent 0634264 commit 0d2fcea
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions arXiv.org.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 12,
"browserSupport": "gcsibv",
"lastUpdated": "2024-10-01 17:25:23"
"lastUpdated": "2024-10-01 18:07:21"
}

/*
Expand All @@ -36,6 +36,16 @@
*/

const arXivCategories = {
// Technically not categories, but added here to allow tags with "Archive - Sub-Field" structure
cs: "Computer Science",
econ: "Economics",
eess: "Electrical Engineering and Systems Science",
math: "Mathematics",
nlin: "Nonlinear Sciences",
physics: "Physics",
"q-fin": "Quantitative Finance",
stat: "Statistics",

"acc-phys": "Accelerator Physics",
"adap-org": "Adaptation, Noise, and Self-Organizing Systems",
"alg-geom": "Algebraic Geometry",
Expand Down Expand Up @@ -395,7 +405,15 @@ function parseSingleEntry(entry) {

let categories = Array.from(entry.querySelectorAll("category"))
.map(el => el.getAttribute("term"))
.map(sub => arXivCategories[sub])
.map((sub) => {
let mainCat = sub.split('.')[0];
if (mainCat !== sub && arXivCategories[mainCat]) {
return arXivCategories[mainCat] + " - " + arXivCategories[sub];
}
else {
return arXivCategories[sub];
}
})
.filter(Boolean);
newItem.tags.push(...categories);

Expand All @@ -404,9 +422,7 @@ function parseSingleEntry(entry) {
if (doi) {
newItem.DOI = doi;
}
else {
newItem.url = arxivURL;
}
newItem.url = arxivURL;

let articleID = arxivURL.replace(/https?:\/\/arxiv.org\/abs\//, ''); // Trim off http://arxiv.org/abs/

Expand Down Expand Up @@ -703,7 +719,7 @@ var testCases = [
"items": [
{
"itemType": "journalArticle",
"title": "Properties of the $\\delta$ Scorpii Circumstellar Disk from Continuum Modeling",
"title": "Properties of the $δ$ Scorpii Circumstellar Disk from Continuum Modeling",
"creators": [
{
"firstName": "A. C.",
Expand Down

0 comments on commit 0d2fcea

Please sign in to comment.