<commit_before>(function(utils, undefined){

  /**
   * Setup the widget when the page loads.
   */
  $(document).ready(function(){
    try {
      setup();
    } catch(e) {
      utils.reportError(e, window.location.href);
    }
  });
  
  function setup() {
    
    /**
     * Get the name
     */
    var nameParts = utils.splitName( $('.pInfo h2').html() );
    
    var personData = {
      'givenName': nameParts[0],
      'familyName': nameParts[1],
      'birthDate': $('.pInfo .birth .date').text(),
      'birthPlace': $('.pInfo .birth .place .placeLink').text(),
    };
    
    // Parse death info if the person isn't living
    var deathDetails = $('.pInfo .death:visible');
    if( $('a.livingTag', deathDetails).length == 0 ) {
      personData['deathDate'] = $('.date', deathDetails).text();
      personData['deathPlace'] = $('.place .placeLink', deathDetails).text();
    }
    
    //
    // Process relationships
    //
    
    var parentsBlock = $('.famMem .section').eq(0);
    
    // Father's name
    if( $('.male.add').length == 0 ) {
      var fatherNameParts = utils.splitName( $('.male .details .name', parentsBlock).text() );
      personData['fatherGivenName'] = fatherNameParts[0];
      personData['fatherFamilyName'] = fatherNameParts[1];
    }
    
    // Mother's name
    if( $('.female.add').length == 0 ) {
      var motherNameParts = utils.splitName( $('.female .details .name', parentsBlock).text() );
      personData['motherGivenName'] = motherNameParts[0];
      personData['motherFamilyName'] = motherNameParts[1];
    }
    
    // Spouse's name
    var spouseBlock = $('.famMem .section').eq(1);
    var spouseNameParts = utils.splitName( $('.main li .details .name', spouseBlock).text() );
    personData['spouseGivenName'] = spouseNameParts[0];
    personData['spouseFamilyName'] = spouseNameParts[1];
     
    /**
     * Now we send the data to the background script that
     * will activate the popup icon in the address bar
     */
     
    chrome.extension.sendRequest({
      'type': 'person_info',
      'data': personData
    });
     
    /**
     * We recommend examining other widgets to get a better idea of how things work.
     */
  }

}(utils));<commit_msg>Fix ancestry bugs<commit_after>(function(utils, undefined){

  /**
   * Setup the widget when the page loads.
   */
  $(document).ready(function(){
    try {
      setup();
    } catch(e) {
      utils.reportError(e, window.location.href);
    }
  });
  
  function setup() {
    
    /**
     * Get the name
     */
    var nameParts = utils.splitName( $('.pInfo h1').html() );
    
    var personData = {
      'givenName': nameParts[0],
      'familyName': nameParts[1]
    };
    
    var events = {};
    
    // Gather events
    $('.eventList .eventDefinition').each(function(){
      var event = $(this),
          type = event.find('dt').text().trim().toLowerCase(),
          day = event.find('.eventDay').text().trim(),
          year = event.find('.eventYear').text().trim(),
          place = event.find('.eventPlace').text().trim();
      events[type] = {
        date: day + ' ' + year,
        place: place
      };      
    });
    
    // Birth
    var birth = events.birth || events.christening || null;
    if(birth) {
      personData['birthDate'] = events.birth.date;
      personData['birthPlace'] = events.birth.place;
    }
    
    // Death
    var death = events.death || events.burial || null;
    if(death) {
      personData['deathDate'] = events.death.date;
      personData['deathPlace'] = events.death.place;
    }
    
    // TODO get the marriage info
    
    //
    // Process relationships
    //
    
    var parentsBlock = $('.famMem .section').eq(0);
    
    // Father's name
    if($('.iconMale.add', parentsBlock).length == 0) {
      var fatherNameParts = utils.splitName( $('.iconMale + .nameandyears a', parentsBlock).text() );
      personData['fatherGivenName'] = fatherNameParts[0];
      personData['fatherFamilyName'] = fatherNameParts[1];
    }
    
    // Mother's name
    if($('.iconFemale.add', parentsBlock).length == 0) {
      var motherNameParts = utils.splitName( $('.iconFemale + .nameandyears a', parentsBlock).text() );
      personData['motherGivenName'] = motherNameParts[0];
      personData['motherFamilyName'] = motherNameParts[1];
    }
    
    // Spouse's name
    var spouseBlock = $('.famMem .section').eq(1);
    if($('.add', spouseBlock).length == 0){
      var spouseNameParts = utils.splitName( $('.main .nameandyears a', spouseBlock).text() );
      personData['spouseGivenName'] = spouseNameParts[0];
      personData['spouseFamilyName'] = spouseNameParts[1];
    }
     
    /**
     * Now we send the data to the background script that
     * will activate the popup icon in the address bar
     */
     
    chrome.extension.sendRequest({
      'type': 'person_info',
      'data': personData
    });
     
    /**
     * We recommend examining other widgets to get a better idea of how things work.
     */
  }

}(utils));
{'fraction_non_alphanumeric': 0.16491158354857938, 'fraction_numerical': 0.005563282336578581, 'mean_word_length': 2.4198369565217392, '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': '4873168', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1496, 'n_words': 337}