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

Submission for Issue #79 #150

Merged
Merged
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
Binary file added papers/.DS_Store
Binary file not shown.
Binary file added papers/LCAX-HyxnZh0ct7/LCAX.pdf
Binary file not shown.
Binary file added papers/LCAX-HyxnZh0ct7/LCAX_camera_ready.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions papers/LCAX-HyxnZh0ct7/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
codebase:
https://github.com/ArnoutDevos/r2d2

issue:
https://github.com/reproducibility-challenge/iclr_2019/issues/79
Binary file not shown.
Binary file added papers/LCAX-HyxnZh0ct7/ReScience_src/Archi.pdf
Binary file not shown.
Binary file added papers/LCAX-HyxnZh0ct7/ReScience_src/BT.pdf
Binary file not shown.
Binary file added papers/LCAX-HyxnZh0ct7/ReScience_src/CIFAR-FS.pdf
Binary file not shown.
Binary file added papers/LCAX-HyxnZh0ct7/ReScience_src/MT.pdf
Binary file not shown.
41 changes: 41 additions & 0 deletions papers/LCAX-HyxnZh0ct7/ReScience_src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# From https://tex.stackexchange.com/questions/40738/how-to-properly-make-a-latex-project
# -----------------------------------------------------------------------------
# You want latexmk to *always* run, because make does not have all the info.
# Also, include non-file targets in .PHONY so they are run regardless of any
# file of the given name existing.
.PHONY: clean

# The first rule in a Makefile is the one executed by default ("make"). It
# should always be the "all" rule, so that "make" and "make all" are identical.

all: draft
draft: draft.pdf
final: final.pdf


# CUSTOM BUILD RULES
# -----------------------------------------------------------------------------
metadata-draft.tex: metadata-draft.yaml
./yaml-to-latex.py -i $< -o $@

metadata-final.tex: metadata-final.yaml
./yaml-to-latex.py -i $< -o $@


# MAIN LATEXMK RULE
# -----------------------------------------------------------------------------
# -pdf tells latexmk to generate PDF directly (instead of DVI).
# -pdflatex="" tells latexmk to call a specific backend with specific options.
# -use-make tells latexmk to call make for generating missing files.
# -interaction=nonstopmode keeps the pdflatex backend from stopping at a
# missing file reference and interactively asking you for an alternative.
draft.pdf: draft.tex content.tex metadata-draft.tex
latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make draft.tex

final.pdf: final.tex content.tex metadata-final.tex
latexmk -pdf -pdflatex="xelatex -interaction=nonstopmode" -use-make final.tex

clean:
@latexmk -CA
@rm -f *.bbl
@rm -f *.run.xml
34 changes: 34 additions & 0 deletions papers/LCAX-HyxnZh0ct7/ReScience_src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
### [ReScience C](https://rescience-c.github.io/) article template

This repository contains the Latex (optional) template for writing a ReScience
C article and the (mandatory) YAML metadata file. For the actual article,
you're free to use any software you like as long as you enforce the proposed
PDF style. For the fonts, you'll need:

* [Source Serif Pro (Adobe Systems)](https://github.com/adobe-fonts/source-serif-pro) by F. Grießhammer.
* [The Roboto family of fonts (Google)](https://github.com/google/roboto) by C. Robertson.
* [Source Code Pro (Adobe Systems)](https://github.com/adobe-fonts/source-code-pro) by P.D. Hunt.

The fonts are available for [download from Google Fonts](https://fonts.google.com/selection?selection.family=Roboto|Roboto+Condensed|Roboto+Mono|Roboto+Slab|Source+Code+Pro|Source+Serif+Pro&query=source+code+pro).

A tool is available for the latex template that produces latex definitions from
the metadata file. If you use another software, make sure that metadata and PDF
are always synced.


#### Usage

For a submission, fill in information in
[metadata-draft.yaml](./metadata-draft.yaml), modify [content.tex](content.tex)
and type:

```bash
$ make draft
```

After acceptance, fill in [metadata-final.yaml](./metadata-final.yaml) and type:

```bash
$ make final
```

296 changes: 296 additions & 0 deletions papers/LCAX-HyxnZh0ct7/ReScience_src/article.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
# ReScience yaml parser
# Released under the BSD two-clauses licence

import yaml

class Contributor:
def __init__(self, role, name, orcid="", email="", affiliations=[]):
self.role = role
self.name = name
self.fullname = name
self.lastname = self.get_lastname(name)
self.abbrvname = self.get_abbrvname(name)
self.orcid = orcid
self.email = email
self.affiliations = affiliations

def get_abbrvname(self, name):
if not name: return ""

if ',' in name:
lastname = name.split(",")[0]
firstnames = name.split(",")[1].strip().split(" ")
else:
lastname = name.split(" ")[-1]
firstnames = name.split(" ")[:-1]
abbrvname = ""
for firstname in firstnames:
if "-" in firstname:
for name in firstname.split("-"):
abbrvname += name[0].strip().upper() + '.-'
abbrvname = abbrvname[:-1]
else:
abbrvname += firstname[0].strip().upper() + '.'
return abbrvname + " " + lastname


def get_lastname(self, name):
if not name: return ""
# Rougier, Nicolas P.
if ',' in name:
lastname = name.split(",")[0].strip()
firstname = name.split(",")[1].strip()
# Nicolas P. Rougier
else:
lastname = name.split(" ")[-1]
firstname = name.split(" ")[:-1]
return lastname


class Affiliation:
def __init__(self, code, name, address=""):
self.code = code
self.name = name
self.address = address

class Repository:
def __init__(self, name, url, doi):
self.name = name
self.url = url
self.doi = doi

class Replication:
def __init__(self, cite, bib, url, doi):
self.cite = cite
self.bib = bib
self.url = url
self.doi = doi

class Review:
def __init__(self, url, doi):
self.url = url
self.doi = doi

class Date:
def __init__(self, date):
try:
import dateutil.parser

date = dateutil.parser.parse(date)
self.date = date
self.year = date.year
self.month = date.month
self.day = date.day
self.textual = self.date.strftime("%d %B %Y")
except:
import datetime
now = datetime.datetime.now()
self.date = now
self.year = now.year
self.month = now.month
self.day = now.day
self.textual = ""

def __str__(self):
return self.textual
#return self.date.strftime("%d %B %Y")

def __repr__(self):
return self.textual
# return self.date.strftime("%d %B %Y")


class Article:
def __init__(self, data):
self.title = ""
self.absract = ""
self.type = ""
self.domain = ""
self.language = ""
self.bibliography = ""
self.keywords = []
self.authors = []
self.editors = []
self.reviewers = []
self.affiliations = []
self.code = ""
self.data = ""
self.contact = ""

self.review = ""
self.replication = ""

self.date_received = ""
self.date_accepted = ""
self.date_published = ""

self.journal_name = ""
self.journal_issn = ""
self.journal_volume = ""
self.journal_issue = ""
self.article_number = ""
self.article_doi = ""
self.article_url = ""

self.parse(data)

# Build authors list
self.authors_short = "" # Family names only
self.authors_abbrv = "" # Abbreviated firsnames + Family names
self.authors_full = "" # Full names

n = len(self.authors)
if n > 3:
self.authors_short = self.authors[0].lastname + " et al."
self.authors_abbrv = self.authors[0].abbrvname + " et al."
self.authors_full = self.authors[0].fullname + " et al."
elif n==1:
self.authors_short += self.authors[0].lastname
self.authors_abbrv += self.authors[0].abbrvname
self.authors_full += self.authors[0].fullname
else:
for i in range(n-2):
self.authors_short += self.authors[i].lastname + ", "
self.authors_abbrv += self.authors[i].abbrvname + ", "
self.authors_full += self.authors[i].fullname + ", "

if n >= 2:
self.authors_short += self.authors[n-2].lastname + " and "
self.authors_short += self.authors[n-1].lastname

self.authors_abbrv += self.authors[n-2].abbrvname + " and "
self.authors_abbrv += self.authors[n-1].abbrvname

self.authors_full += self.authors[n-2].fullname + " and "
self.authors_full += self.authors[n-1].fullname



def parse(self, data):
document = yaml.load(data)

self.title = document.get("title", "")
self.abstract = document.get("abstract","") or ""
self.keywords = document["keywords"] or ""
self.type = document["type"] or ""
self.domain = document["domain"] or ""
self.language = document["language"] or ""
self.bibliography = document["bibliography"] or ""

# Miscellaneous dates
dates = {key:value for data in document["dates"]
for key, value in data.items()}
self.date_received = Date(dates["received"] or "")
self.date_accepted = Date(dates["accepted"] or "")
self.date_published = Date(dates["published"] or "")

# Add authors
for item in document["authors"]:
role = "author"
name = item["name"] or ""
orcid = item.get("orcid","") or ""
email = item.get("email","") or ""
if item["affiliations"] is not None:
if len(str(item["affiliations"])) > 1:
affiliations = item["affiliations"].split(",")
if "*" in affiliations:
affiliations.remove("*")
author = Contributor(role, name, orcid, email, affiliations)
self.add_contributor(author)
self.contact = author
else:
author = Contributor(role, name, orcid, email, affiliations)
self.add_contributor(author)
else:
affiliations = list(str(item["affiliations"]))
author = Contributor(role, name, orcid, email, affiliations)
self.add_contributor(author)


# Add author affiliations
for item in document["affiliations"]:
self.affiliations.append(
Affiliation(item["code"],
item["name"],
item.get("address", "")))


# Add editor & reviewers
for item in document["contributors"]:
role = item["role"]
name = item["name"] or ""
orcid = item.get("orcid","") or ""
contributor = Contributor(role, name, orcid)
self.add_contributor(contributor)


# Code repository (mandatory)
if "code" in document.keys():
code = {key:value for data in document["code"]
for key, value in data.items()}
self.code = Repository("code",
code.get("url","") or "",
code.get("doi","") or "")
else:
raise IndexError("Code repository not found")

# Data repository (optional)
if "data" in document.keys():
data = {key:value for data in document["data"]
for key, value in data.items()}
self.data = Repository("data",
data.get("url","") or "",
data.get("doi","") or "")
else:
self.data = Repository("data", "", "")

# Review
review = {key:value for review in document["review"]
for key, value in review.items()}
self.review = Review(review.get("url","") or "",
review.get("doi","") or "")

# Replication
replication = {key:value for replication in document["replication"]
for key, value in replication.items()}
self.replication = Replication(replication["cite"] or "",
replication["bib"] or "",
replication["url"] or "",
replication["doi"] or "")

# Article number & DOI
article = {key:value for article in document["article"]
for key, value in article.items()}
self.article_number = article["number"] or ""
self.article_doi = article["doi"] or ""
self.article_url = article["url"] or ""

# Journal volume and issue
journal = {key:value for journal in document["journal"]
for key, value in journal.items()}
self.journal_name = str(journal.get("name",""))
self.journal_issn = str(journal.get("issn", ""))
self.journal_volume = journal["volume"] or ""
self.journal_issue = journal["issue"] or ""


def add_contributor(self, contributor):
if contributor.role == "author":
self.authors.append(contributor)
elif contributor.role == "editor":
self.editors.append(contributor)
elif contributor.role == "reviewer":
self.reviewers.append(contributor)
else:
raise(IndexError)



# -----------------------------------------------------------------------------
if __name__ == '__main__':

with open("metadata.yaml") as file:
article = Article(file.read())
print(article.authors_full)
print(article.authors_abbrv)
print(article.authors_short)
Loading