<commit_before>const data = require('../../data/hacker.json');

function parse(hacker, format) {
  return format
    .replace(/\{abbreviation\}/g, hacker.abbreviation())
    .replace(/\{adjective\}/g, hacker.adjective())
    .replace(/\{noun\}/g, hacker.noun())
    .replace(/\{verb\}/g, hacker.verb())
    .replace(/\{ingverb\}/g, hacker.ingverb())
    .replace(/^(\w)/, m => m[0].toUpperCase());
}

export default class Hacker {
  constructor(faker) {
    this.faker = faker;
  }

  saySomethingSmart() {
    return parse(this, this.faker.Random.element(data['phrases']));
  }

  abbreviation() {
    return this.faker.Random.element(data['abbreviations']);
  }

  adjective() {
    return this.faker.Random.element(data['adjectives']);
  }

  noun() {
    return this.faker.Random.element(data['nouns']);
  }

  verb() {
    return this.faker.Random.element(data['verbs']);
  }

  ingverb() {
    return this.faker.Random.element(data['ingverbs']);
  }
}
<commit_msg>Using the Fake faker to parse placeholders.<commit_after>const data = require('../../data/hacker.json');

function parse(faker, format) {
  const text = format.replace(/\{(\w+)\}/g, m => `{Hacker.${m.substring(1)}`);
  return faker.Fake.f(text).replace(/^(\w)/, m => m[0].toUpperCase());
}

export default class Hacker {
  constructor(faker) {
    this.faker = faker;
  }

  saySomethingSmart() {
    return parse(this.faker, this.faker.Random.element(data['phrases']));
  }

  abbreviation() {
    return this.faker.Random.element(data['abbreviations']);
  }

  adjective() {
    return this.faker.Random.element(data['adjectives']);
  }

  noun() {
    return this.faker.Random.element(data['nouns']);
  }

  verb() {
    return this.faker.Random.element(data['verbs']);
  }

  ingverb() {
    return this.faker.Random.element(data['ingverbs']);
  }
}

{'fraction_non_alphanumeric': 0.20339912280701755, 'fraction_numerical': 0.001644736842105263, 'mean_word_length': 3.5285359801488836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '7088081', 'n_tokens_mistral': 684, 'n_tokens_neox': 652, 'n_words': 94}