<commit_before>import store from '@/store'
import _ from 'lodash'
import os from 'os'

const _errorsTitle = `#### Known Data Errors`
const _errorsPreText = `
This data is published with the following data errors:

`

export function compileAndStringifyProvenance() {
  const mainText = store.getters.getProvenance.markdown
  const allHotErrors = store.getters.getProvenance.hotErrors
  let stringified = ''
  _.forEach(allHotErrors, function(errors, hotId) {
    let hotErrors = compileHotErrors(errors, hotId)
    stringified += `${hotErrors}\n`
  })
  return `${mainText}${os.EOL}${stringified}`
}

export function compileHotErrors(errors, hotId) {
  const tabTitle = getTabTitleFromHotId(hotId)
  return compileErrors(errors, tabTitle)
}

export function stringifyProvenance(mainText, allHotErrors) {
  let stringified = ''
  _.forEach(allHotErrors, function(errors, hotId) {
    stringified += `${errors}\n`
  })
  return `${mainText}${os.EOL}${stringified}`
}

function getTabTitleFromHotId(hotId) {
  const tabId = store.getters.getTabIdFromHotId(hotId)
  return store.getters.tabTitle(tabId)
}

function compileErrors(errors, tabTitle) {
  let compiled = _.template(`${_errorsTitle} - ${tabTitle}${_errorsPreText}<%= errorsList %>`)
  return compiled({ 'errorsList': errorsListToString(errors) })
}

function errorsListToString(errors) {
  return _.map(errors, function(error) {
    return `${error.message}`
  }).join(os.EOL)
}
<commit_msg>Fixes #618.<commit_after>import store from '@/store'
import _ from 'lodash'
import os from 'os'

const _errorsTitle = `#### Known Data Errors`
const _errorsPreText = `
This data is published with the following data errors:

`

export function compileAndStringifyProvenance() {
  const mainText = store.getters.getProvenance.markdown
  const allHotErrors = store.getters.getProvenance.hotErrors
  let stringified = ''
  _.forEach(allHotErrors, function(errors, hotId) {
    let hotErrors = compileHotErrors(errors, hotId)
    stringified += `${hotErrors}\n`
  })
  return `${mainText}${os.EOL}${stringified}`
}

export function compileHotErrors(errors, hotId) {
  const tabTitle = getTabTitleFromHotId(hotId)
  return compileErrors(errors, tabTitle)
}

export function stringifyProvenance(mainText, allHotErrors) {
  let stringified = ''
  _.forEach(allHotErrors, function(errors, hotId) {
    stringified += `${errors}\n`
  })
  return `${mainText}${os.EOL}${stringified}`
}

function getTabTitleFromHotId(hotId) {
  const tabId = store.getters.getTabIdFromHotId(hotId)
  return store.getters.tabTitle(tabId)
}

function compileErrors(errors, tabTitle) {
  let compiled = _.template(`${_errorsTitle} - ${tabTitle}${_errorsPreText}<%= errorsList %>`)
  return compiled({ 'errorsList': errorsListToString(errors) })
}

function errorsListToString(errors) {
  let counter = 1
  return _.map(errors, function(error) {
    return `${counter++}. ${error.message}`
  }).join(os.EOL)
}

{'fraction_non_alphanumeric': 0.13157894736842105, 'fraction_numerical': 0.001367053998632946, 'mean_word_length': 5.490022172949002, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3485984', 'n_tokens_mistral': 945, 'n_tokens_neox': 945, 'n_words': 203}