<commit_before>// Assert verifies various conditions within functions
// Calls to assert are optional but good practice
function assert(claim,warning) {
    if (!claim) console.log(warning);
}

// Solution:
var people = {};  //master object: stores both data and methods

people.index = {}; //data object: stores known names and corresponding objects

// ---- helper functions ----

// Retrieve the object for a particular person, which might be null
people.findPerson = function(name) {
    assert(typeof name === 'string','ensurePerson:name should be string');
    return this.index[name]; // object or undefined
}

// Retrieve the object for a particular person *ALWAYS*, creating it if needed
people.ensurePerson = function(name) {
    // return existing person, or else create them
    return this.findPerson(name) ||
        ( this.index[name] = {name:name, friends:{}} ); //if not found, make person
}

// ---- functions needed for part a) ----<commit_msg>Updated solutions<commit_after>// Assert verifies various conditions within functions
// Calls to assert are optional but good practice
function assert(claim,warning) {
    if (!claim) console.log(warning);
}

// Solution:
var people = {};  //master object: stores both data and methods

people.index = {}; //data object: stores known names and corresponding objects

// ---- Helper functions ----

// Retrieve the object for a particular person, which might be null
people.findPerson = function(name) {
    assert(typeof name === 'string','ensurePerson:name should be string');
    return this.index[name]; // object or undefined
}

// Retrieve the object for a particular person *ALWAYS*, creating it if needed
people.ensurePerson = function(name) {
    // return existing person, or else create them
    return this.findPerson(name) ||
        ( this.index[name] = {name:name, friends:{}} ); //if not found, make person
}

// ---- Functions needed for part a) ----
{'fraction_non_alphanumeric': 0.12538860103626942, 'fraction_numerical': 0.0, 'mean_word_length': 3.5542452830188678, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2717422', 'n_tokens_mistral': 504, 'n_tokens_neox': 492, 'n_words': 203}