<commit_before>package org.sameersingh.bibere

import java.io.{PrintWriter, FileOutputStream, OutputStreamWriter}

/**
 * @author sameer
 */
class BibtexWriter extends Writer {

  def filename = "papers.bib"

  def write(pubs: Publications, path: String) {
    val file = new OutputStreamWriter(
      new FileOutputStream(path + "/" + filename), "UTF-8")
    val writer = new PrintWriter(file)
    for (p <- pubs.papersByYear) {
      writer.println(bibtex(p, pubs))
      writer.flush()
    }
    writer.close()
  }

  def bibtex(p: Paper, pubs: Publications): String = {
    val sb = new StringBuffer
    val vt = BibtexHelper.entryType(p.pubType)
    sb append ("@" + vt + "{")
    sb.append(p.id + ",\n")
    sb.append(" %s = {%s},\n" format("author", p.authorIds.map(pubs author _)
          .map(a => if(mainAuthorId == Some(a.id)) "\\textbf{" + a.name.full + "}" else a.name.full)
          .mkString(" and ")))
    sb.append(" %s = {%s},\n" format("title", p.title))
    sb.append(" %s = {%s},\n" format(BibtexHelper.venueTitle(p.pubType), pubs.venue(p.venueId).name))
    sb.append(" %s = {%d}\n" format("year", p.year))
    sb append "}"
    sb.toString
  }
}

object BibtexWriter extends BibtexWriter

object BibtexHelper {

  import PubType._

  def entryType(v: Value): String = v match {
    case Conference => "inproceedings"
    case Workshop => "inproceedings"
    case Demo => "inproceedings"
    case TechReport => "techreport"
    case Patent => "techreport"
    case Thesis => "phdthesis"
    case _ => "misc"
  }

  def venueTitle(v: Value): String = v match {
    case Conference => "booktitle"
    case Workshop => "booktitle"
    case Demo => "booktitle"
    case TechReport => "institution"
    case Patent => "institution"
    case Thesis => "school"
    case _ => "series"
  }
}<commit_msg>better bolding of mainAuthor names<commit_after>package org.sameersingh.bibere

import java.io.{PrintWriter, FileOutputStream, OutputStreamWriter}

/**
 * @author sameer
 */
class BibtexWriter extends Writer {

  def filename = "papers.bib"

  def write(pubs: Publications, path: String) {
    val file = new OutputStreamWriter(
      new FileOutputStream(path + "/" + filename), "UTF-8")
    val writer = new PrintWriter(file)
    for (p <- pubs.papersByYear) {
      writer.println(bibtex(p, pubs))
      writer.flush()
    }
    writer.close()
  }

  def bibtex(p: Paper, pubs: Publications): String = {
    val sb = new StringBuffer
    val vt = BibtexHelper.entryType(p.pubType)
    sb append ("@" + vt + "{")
    sb.append(p.id + ",\n")
    sb.append(" %s = {%s},\n" format("author", p.authorIds.map(pubs author _)
          .map(a => if(mainAuthorId == Some(a.id)) a.name.full.split(" ").map(s => "{\\bf " + s  + "}").mkString(" ") else a.name.full)
          .mkString(" and ")))
    sb.append(" %s = {%s},\n" format("title", p.title))
    sb.append(" %s = {%s},\n" format(BibtexHelper.venueTitle(p.pubType), pubs.venue(p.venueId).name))
    sb.append(" %s = {%d}\n" format("year", p.year))
    sb append "}"
    sb.toString
  }
}

object BibtexWriter extends BibtexWriter

object BibtexHelper {

  import PubType._

  def entryType(v: Value): String = v match {
    case Conference => "inproceedings"
    case Workshop => "inproceedings"
    case Demo => "inproceedings"
    case TechReport => "techreport"
    case Patent => "techreport"
    case Thesis => "phdthesis"
    case _ => "misc"
  }

  def venueTitle(v: Value): String = v match {
    case Conference => "booktitle"
    case Workshop => "booktitle"
    case Demo => "booktitle"
    case TechReport => "institution"
    case Patent => "institution"
    case Thesis => "school"
    case _ => "series"
  }
}
{'fraction_non_alphanumeric': 0.160530590146183, 'fraction_numerical': 0.0005414185165132648, 'mean_word_length': 3.0964523281596454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7321622', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1237, 'n_words': 307}