Skip to content

Commit 64510bb

Browse files
committed
Refactor BibTeX handling and update mock papers
- Renamed `getAbstract` to `getBibTeX` for clarity and updated its implementation to return the BibTeX entry. - Introduced a new function `getAbstract` to extract the abstract from a BibTeX entry. - Added `getBibTeXFromDict` to retrieve BibTeX from a dictionary containing repository objects. - Updated `getAbstractFromDict` to utilize the new BibTeX handling functions. - Enhanced the `publications.ejs` template to generate BibTeX entries directly from the item data.
1 parent a3aa5b8 commit 64510bb

File tree

4 files changed

+634
-20
lines changed

4 files changed

+634
-20
lines changed

getcomputo-pub.fsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type RepoError =
7676

7777
let redirectStringRe = Regex(@"URL='(.*)'")
7878

79-
let getAbstract (page: string) =
79+
let getBibTeX (page: string) =
8080

8181
let htmlFirst = HtmlDocument.Load(page)
8282

@@ -100,16 +100,29 @@ let getAbstract (page: string) =
100100
try
101101
html.CssSelect(".bibtex").Head.InnerText()
102102
|> DirtyParser.bibTeXFromString
103-
|> _.Head.Properties["abstract"]
103+
|> _.Head
104104
|> Result.Ok
105105
with e ->
106-
printfn "Error getting abstract from %s: %s" page e.Message
106+
printfn "Error getting BibTeX from %s: %s" page e.Message
107107
Result.Error e.Message
108108

109+
let getAbstract (entry: BibTeXEntry) = entry.Properties["abstract"]
110+
111+
let getBibTeXFromDict (d: Dictionary<obj, obj>) =
112+
d["repoObj"] :?> Repository
113+
|> _.Homepage
114+
|> getBibTeX
115+
|> function
116+
| Ok a -> DrBiber.DirtyParser.bibTeXToString [ a ]
117+
| Error e ->
118+
printfn "Error getting BibTeX from %s: %s" (d["repoObj"] :?> Repository).Name e
119+
""
120+
109121
let getAbstractFromDict (d: Dictionary<obj, obj>) =
110122
d["repoObj"] :?> Repository
111123
|> _.Homepage
112-
|> getAbstract
124+
|> getBibTeX
125+
|> Result.map (fun bibTeX -> getAbstract bibTeX)
113126
|> function
114127
| Ok a -> a
115128
| Error e ->
@@ -159,6 +172,7 @@ let extractCitation (d: Dictionary<obj, obj>) =
159172
description = d |> getSomeString "description"
160173
abstract' = d |> getAbstractFromDict
161174
repo = d |> getSomeString "repo"
175+
bibtex = d |> getBibTeXFromDict
162176
pdf = d |> getAnotherThing "citation" |> getSomeString "pdf-url"
163177
url = d |> getAnotherThing "citation" |> getSomeString "url"
164178
draft = d |> getSomeString "draft" |}

site/mock-papers.yml

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,39 @@
2020
t-SNE are significantly better than those produced by other
2121
techniques on almost all of the data sets.
2222
authors: Laurens van der Maaten and Geoffrey Hinton
23+
bibtex: >+
24+
@article{van_der_maaten2008,
25+
author = {van der Maaten, Laurens and Hinton, Geoffrey},
26+
publisher = {Société Française de Statistique},
27+
title = {Visualizing {Data} Using {t-SNE:} A Practical Computo Example
28+
(Mock)},
29+
journal = {Computo},
30+
date = {2008-08-11},
31+
url = {https://computo.sfds.asso.fr/published-paper-tsne},
32+
issn = {2824-7795},
33+
langid = {en},
34+
abstract = {We present a new technique called “t-SNE” that visualizes
35+
high-dimensional data by giving each datapoint a location in a two
36+
or three-dimensional map. The technique is a variation of Stochastic
37+
Neighbor Embedding {[}@hinton:stochastic{]} that is much easier to
38+
optimize, and produces significantly better visualizations by
39+
reducing the tendency to crowd points together in the center of the
40+
map. t-SNE is better than existing techniques at creating a single
41+
map that reveals structure at many different scales. This is
42+
particularly important for high-dimensional data that lie on several
43+
different, but related, low-dimensional manifolds, such as images of
44+
objects from multiple classes seen from multiple viewpoints. For
45+
visualizing the structure of very large data sets, we show how t-SNE
46+
can use random walks on neighborhood graphs to allow the implicit
47+
structure of all the data to influence the way in which a subset of
48+
the data is displayed. We illustrate the performance of t-SNE on a
49+
wide variety of data sets and compare it with many other
50+
non-parametric visualization techniques, including Sammon mapping,
51+
Isomap, and Locally Linear Embedding. The visualization produced by
52+
t-SNE are significantly better than those produced by other
53+
techniques on almost all of the data sets.}
54+
}
55+
2356
date: 2008-08-11
2457
description: >
2558
This page is a reworking of the original t-SNE article using the Computo template. It aims to help authors submitting to the journal by using some advanced formatting features. We warmly thank the authors of t-SNE and the editor of JMLR for allowing us to use their work to illustrate the Computo spirit.
@@ -29,7 +62,7 @@
2962
pdf: ''
3063
repo: published-paper-tsne
3164
title: Visualizing Data using t-SNE (mock contributon)
32-
url: https://computo.sfds.asso.fr/published-paper-tsne
65+
url: https://computo-journal.org/published-paper-tsne
3366
year: 2008
3467
- abstract': >-
3568
We present a new technique called “t-SNE” that visualizes
@@ -53,6 +86,39 @@
5386
t-SNE are significantly better than those produced by other
5487
techniques on almost all of the data sets.
5588
authors: Laurens van der Maaten and Geoffrey Hinton
89+
bibtex: >+
90+
@article{van_der_maaten2008,
91+
author = {van der Maaten, Laurens and Hinton, Geoffrey},
92+
publisher = {French Statistical Society},
93+
title = {Visualizing {Data} Using {t-SNE:} A Practical {Computo}
94+
Example (Mock)},
95+
journal = {Computo},
96+
date = {2008-08-11},
97+
url = {https://computo-journal.org/published-paper-tsne-R},
98+
issn = {2824-7795},
99+
langid = {en},
100+
abstract = {We present a new technique called “t-SNE” that visualizes
101+
high-dimensional data by giving each datapoint a location in a two
102+
or three-dimensional map. The technique is a variation of Stochastic
103+
Neighbor Embeddi{[}@hinton:stochastic{]} that is much easier to
104+
optimize, and produces significantly better visualizations by
105+
reducing the tendency to crowd points together in the center of the
106+
map. t-SNE is better than existing techniques at creating a single
107+
map that reveals structure at many different scales. This is
108+
particularly important for high-dimensional data that lie on several
109+
different, but related, low-dimensional manifolds, such as images of
110+
objects from multiple classes seen from multiple viewpoints. For
111+
visualizing the structure of very large data sets, we show how t-SNE
112+
can use random walks on neighborhood graphs to allow the implicit
113+
structure of all the data to influence the way in which a subset of
114+
the data is displayed. We illustrate the performance of t-SNE on a
115+
wide variety of data sets and compare it with many other
116+
non-parametric visualization techniques, including Sammon mapping,
117+
Isomap, and Locally Linear Embedding. The visualization produced by
118+
t-SNE are significantly better than those produced by other
119+
techniques on almost all of the data sets.}
120+
}
121+
56122
date: 2008-08-11
57123
description: >
58124
This page is a reworking of the original t-SNE article using the Computo template. It aims to help authors submitting to the journal by using some advanced formatting features. We warmly thank the authors of t-SNE and the editor of JMLR for allowing us to use their work to illustrate the Computo spirit.
@@ -62,5 +128,5 @@
62128
pdf: ''
63129
repo: published-paper-tsne-R
64130
title: Visualizing Data using t-SNE (mock contributon)
65-
url: https://computo.sfds.asso.fr/published-paper-tsne-R
131+
url: https://computo-journal.org/published-paper-tsne-R
66132
year: 2008

site/publications.ejs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ for (const item of items) {
1010
let doiurl = item.url === "" ? "https://doi.org/" + item.doi : item.url;
1111
let bibtitle = item.title.replace(/'/g, "\\'");
1212
let bibauthors = item.authors.replace(/'/g, "\\'");
13+
let bibtex = item.bibtex.replace(/'/g, "\\'").replace(/\"/g, '&quot;').replace(/\r?\n/g, "\\n");
1314
if (item.year !== currentYear) {
1415
if (currentYear !== null) { %>
1516
</div> <!-- End previous year section -->
@@ -52,7 +53,7 @@ for (const item of items) {
5253
<a href="<%= item.pdf %>" class="btn btn-outline-secondary btn-sm" target="_blank" style="padding:0.2em 0.6em;">PDF</a>
5354
<% } %> -->
5455
<a href="https://github.com/computorg/<%- item.repo %>" class="btn btn-outline-secondary btn-sm" target="_blank" style="padding:0.2em 0.6em;">Sources (Git)</a>
55-
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="generateBibTex('<%- bibtitle %>', '<%- bibauthors %>', '<%= item.year %>', '<%= doiurl %>')" style="padding:0.2em 0.6em;"><span style="font-variant: small-caps; font-family: 'Times New Roman', Times, serif;">Bib<span style="vertical-align: -0.2em;">T</span><span style="vertical-align: 0em;">E</span>X</span></button>
56+
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="generateBibTex('<%= bibtex %>')" style="padding:0.2em 0.6em;"><span style="font-variant: small-caps; font-family: 'Times New Roman', Times, serif;">Bib<span style="vertical-align: -0.2em;">T</span><span style="vertical-align: 0em;">E</span>X</span></button>
5657
</div>
5758
</div>
5859
</div>
@@ -124,19 +125,7 @@ for (const item of items) {
124125
$('#abstractContent').text(abstract);
125126
});
126127
127-
function generateBibTex(title, authors, year, url) {
128-
// Generate a simple BibTeX key from the first author's last name and year
129-
var firstAuthor = authors.split(' and ')[0].split(' ').pop().toLowerCase();
130-
var bibKey = firstAuthor + year;
131-
132-
var bibTeX = '@article{' + bibKey + ',\n' +
133-
' title={' + title + '},\n' +
134-
' author={' + authors + '},\n' +
135-
' journal={Computo},\n' +
136-
' year={' + year + '},\n' +
137-
' url={' + url + '}\n' +
138-
'}';
139-
128+
function generateBibTex(bibTeX) {
140129
// Create a temporary textarea to copy the BibTeX to clipboard
141130
var textArea = document.createElement('textarea');
142131
textArea.value = bibTeX;

0 commit comments

Comments
 (0)