<jupyter_start><jupyter_text>Convert TSV of publication data into markdown for Github Pages<jupyter_code>import pandas as pd
articles = pd.read_csv("publications.tsv", sep="\t", header=0)
articles
html_escape_table = {
    "&": "&amp;",
    '"': "&quot;",
    "'": "&apos;",
    ">": "&gt;",
    "<": "&lt;",
    }

def html_escape(text):
    """Produce entities within text."""
    return "".join(html_escape_table.get(c,c) for c in text)
import os
for row, item in articles.iterrows():
    md_filename = str(item.pub_date) + "-" + item.slug + ".md"
    html_filename = str(item.pub_date) + "-" + item.slug 
    year = item.pub_date[:4]
    md = "---\ntitle: \""   + item.title + '"\n'
    
    md += """collection: publication\npermalink: /publication/""" + html_filename
    #md += "\nexcerpt: '<i>Published in " + item.venue + ", " + str(year) + "</i><br/>" + html_escape(item.summary) + "'"
    md += "\ndate: " + str(item.pub_date) 
    md += "\nvenue: '" + html_escape(item.venue) + "'"
    if type(item.journalurl) is str:
        md += "\njournalurl: '" + item.journalurl + "'"
    if type(item.pdfurl) is str:
        md += "\npdfurl: '" + item.pdfurl + "'"
    if type(item.arxivurl) is str:
        md += "\narxivurl: '" + item.arxivurl + "'"
    if type(item.citation) is str:
        md += "\ncitation: '" + html_escape(item.citation) + "'"
    md += "\n---"
    #md += "\n\n<a href='" + item.url + "'>Download PDF here</a>\n" 
    md += "\nAbstract: " + html_escape(item.description) + "\n"
    #md += "\n Recommended citation: " + item.citation
    md_filename = os.path.basename(md_filename)
    with open(md_filename, 'w') as f:
        f.write(md)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20813679245283018, 'fraction_numerical': 0.0011792452830188679, 'mean_word_length': 3.0118203309692673, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '575986', 'license': 'MIT', 'n_tokens_mistral': 642, 'n_tokens_neox': 625, 'n_words': 129, 'path': 'markdown_generator/.ipynb_checkpoints/publications-checkpoint.ipynb', 'repo_name': 'fontclos/fontclos.github.io', 'size': '1696'}