<commit_before>var models = require('../../src/models'),
    Record = models.Record,
    RecordType = models.RecordType;

var records = {
    mylife: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["My life in America"]}},{"section":{"children":["Greatest book ever"]}}]}},
        key: 'My life in America'
    },
    whynot: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["Why I don't eat fat"]}},{"section":{"children":["Not nearly as exciting as it sounds."]}}]}},
        key: "Why I don't eat fat"
    },
    london: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["London"]}},{"section":{"children":["In England"]}}]}},
        key: 'London'
    },
    jackspratt: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["<NAME>"]}},{"section":{"children":["A British man with strict dietary requirements."]}}]}},
        key: '<NAME>'
    },
    newyork: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["New York"]}},{"section":{"children":["In the US"]}}]}},
        key: 'New York'
    },
    billybob: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["<NAME>"]}},{"section":{"children":["A silly Southerner."]}}]}},
        key: '<NAME>'
    },
    paris: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["Paris"]}},{"section":{"children":["In France"]}}]}},
        key: 'Paris'
    },
    johnsmith: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["<NAME>"]}},{"section":{"children":["An intrepid explorer who originally lived in France"]}}]}},
        key: '<NAME>'
    },
    1580: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["1580"]}},{"section":{"children":["A good year"]}}]}},
        key: '1580'
    },
    1589: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["1589"]}},{"section":{"children":["A not-so-good year"]}}]}},
        key: '1589'
    },
    1631: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["1631"]}},{"section":{"children":["A tragic year"]}}]}},
        key: '1631'
    },
    date: {
        key: 'date',
        model: 'recordtype',
    },
    book: {
        key: 'book',
        model: 'recordtype',
    },
    person: {
        key: 'person',
        model: 'recordtype',
    },
    place: {
        key: 'place',
        model: 'recordtype',
    },
};

for (var key in records) {
    if (records[key].model === 'record') {
        records[key] = new Record(records[key]);
    } else if (records[key].model === 'recordtype') {
        records[key] = new RecordType(records[key]);
    }
    records[key].save();
}

records.mylife.link('author', records.johnsmith);
records.mylife.link('pubplace', records.newyork);
records.mylife.link('pubdate', records['1589']);
records.whynot.link('author', records.jackspratt);
records.whynot.link('pubplace', records.london);
records.whynot.link('pubdate', records['1589']);
records.jackspratt.link('birthdate', records['1580']);
records.jackspratt.link('deathdate', records['1589']);
records.johnsmith.link('birthdate', records['1580']);
records.johnsmith.link('deathdate', records['1631']);
records.mylife.link('recordtype', records.book);
records.whynot.link('recordtype', records.book);
records.jackspratt.link('recordtype', records.person);
records.johnsmith.link('recordtype', records.person);
records.billybob.link('recordtype', records.person);
records.paris.link('recordtype', records.place);
records.newyork.link('recordtype', records.place);
records.london.link('recordtype', records.place);
records['1580'].link('recordtype', records.date);
records['1589'].link('recordtype', records.date);
records['1631'].link('recordtype', records.date);
<commit_msg>Don't try to generate sample data if it already exists<commit_after>var models = require('../../src/models'),
    Record = models.Record,
    RecordType = models.RecordType;

var mylife = Record.findOne({ key: 'My life in America' });
if (typeof mylife !== 'undefined' && mylife !== null) {
    console.log('Sample data already generated!');
    return;
}
var records = {
    mylife: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["My life in America"]}},{"section":{"children":["Greatest book ever"]}}]}},
        key: 'My life in America'
    },
    whynot: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["Why I don't eat fat"]}},{"section":{"children":["Not nearly as exciting as it sounds."]}}]}},
        key: "Why I don't eat fat"
    },
    london: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["London"]}},{"section":{"children":["In England"]}}]}},
        key: 'London'
    },
    jackspratt: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["<NAME>"]}},{"section":{"children":["A British man with strict dietary requirements."]}}]}},
        key: '<NAME>'
    },
    newyork: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["New York"]}},{"section":{"children":["In the US"]}}]}},
        key: 'New York'
    },
    billybob: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["<NAME>"]}},{"section":{"children":["A silly Southerner."]}}]}},
        key: '<NAME>'
    },
    paris: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["Paris"]}},{"section":{"children":["In France"]}}]}},
        key: 'Paris'
    },
    johnsmith: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["<NAME>"]}},{"section":{"children":["An intrepid explorer who originally lived in France"]}}]}},
        key: '<NAME>'
    },
    1580: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["1580"]}},{"section":{"children":["A good year"]}}]}},
        key: '1580'
    },
    1589: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["1589"]}},{"section":{"children":["A not-so-good year"]}}]}},
        key: '1589'
    },
    1631: {
        format: 'bnjson',
        deleted: 0,
        model: 'record',
        data: {"article":{"children":[{"header":{"children":["1631"]}},{"section":{"children":["A tragic year"]}}]}},
        key: '1631'
    },
    date: {
        key: 'date',
        model: 'recordtype',
    },
    book: {
        key: 'book',
        model: 'recordtype',
    },
    person: {
        key: 'person',
        model: 'recordtype',
    },
    place: {
        key: 'place',
        model: 'recordtype',
    },
};

for (var key in records) {
    if (records[key].model === 'record') {
        records[key] = new Record(records[key]);
    } else if (records[key].model === 'recordtype') {
        records[key] = new RecordType(records[key]);
    }
    records[key].save();
}

records.mylife.link('author', records.johnsmith);
records.mylife.link('pubplace', records.newyork);
records.mylife.link('pubdate', records['1589']);
records.whynot.link('author', records.jackspratt);
records.whynot.link('pubplace', records.london);
records.whynot.link('pubdate', records['1589']);
records.jackspratt.link('birthdate', records['1580']);
records.jackspratt.link('deathdate', records['1589']);
records.johnsmith.link('birthdate', records['1580']);
records.johnsmith.link('deathdate', records['1631']);
records.mylife.link('recordtype', records.book);
records.whynot.link('recordtype', records.book);
records.jackspratt.link('recordtype', records.person);
records.johnsmith.link('recordtype', records.person);
records.billybob.link('recordtype', records.person);
records.paris.link('recordtype', records.place);
records.newyork.link('recordtype', records.place);
records.london.link('recordtype', records.place);
records['1580'].link('recordtype', records.date);
records['1589'].link('recordtype', records.date);
records['1631'].link('recordtype', records.date);

{'fraction_non_alphanumeric': 0.22520661157024793, 'fraction_numerical': 0.018051326663766853, 'mean_word_length': 3.309746954076851, 'pattern_counts': {'":': 132, '<': 15, '<?xml version=': 0, '>': 15, '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': '5540247', 'n_tokens_mistral': 3006, 'n_tokens_neox': 2772, 'n_words': 548}