<commit_before>var cheerio = require('cheerio'),
	Page = require('../page');

var parseLocation = function(page) {
	var location = '' + page.getText('.prominent-place .sub-place') + ', ' + page.getText('.prominent-place .place-context a');
	
	if (location === ', ') {
		location = undefined;
	}

	return location;
};

var parseVenues = function(page) {
	var addressValues = page.$('#venues p').eq(1).text().split('- ');
	var address = addressValues[0].trim();
	addressValues.shift();
	var note = addressValues.length > 0 ? addressValues.join('- ').trim() : undefined;

	return [{
		name: page.getText('#venues h3 a'),
		address: address,
		note: note,
		googleMapsUrl: page.getHref('#venues a.map-icon')
	}];
};

var parseSessions = function(page) {
	return page.map('li.session-detail', function(elem){
		var $this = page.$(elem),
			$titleLink = $this.find('h3 a'),
			$link = $this.find('p a'),
			$time = $this.find('.time');

		var session = {
			title: $titleLink.text(),
			url: page.getHref($titleLink),
			startTime: page.getText($time),
			speakers: []
		};

		var $paragraph = $this.find('p');

		// Remove 'presented by'
		$paragraph.find('strong').remove();

		// Loop through all speakers with accounts, remove tags from DOM
		$paragraph.find('a').remove().each(function(){
			var $link = page.$(this);
			
			session.speakers.push({
				name: $link.text(),
				twitterHandle: page.getTwitterHandle($link)
			});
		});

		// Convert remaining names into an array
		$paragraph.text().replace(' and ', ', ').split(', ').forEach(function(speakerName){
			speakerName = speakerName.trim();

			if (speakerName !== '') {
				session.speakers.push({
					name: speakerName
				});
			}
		});

		return session;
	});
};

var parse = function(markup, callback) {
	var $ = cheerio.load(markup),
		page = new Page($);

	callback(null, {
		title: page.getText('h1.summary'),
		tagline: page.getText('h2.tagline'),
		websiteUrl: page.getHref('.item-meta a.website'),
		scheduleUrl: page.getHref('.item-meta a.seeschedule'),
		location: parseLocation(page),
		venues: parseVenues(page),<commit_msg>Clean up event parsing logic<commit_after>var cheerio = require('cheerio'),
	Page = require('../page');

var parseLocation = function(page) {
	var location = '' + page.getText('.prominent-place .sub-place') + ', ' + page.getText('.prominent-place .place-context a');
	
	if (location === ', ') {
		location = undefined;
	}

	return location;
};

var parseVenues = function(page) {
	var addressValues = page.$('#venues p').eq(1).text().split('- ');
	var address = addressValues[0].trim();
	addressValues.shift();
	var note = addressValues.length > 0 ? addressValues.join('- ').trim() : undefined;

	return [{
		name: page.getText('#venues h3 a'),
		address: address,
		note: note,
		googleMapsUrl: page.getHref('#venues a.map-icon')
	}];
};

var parseSessions = function(page) {
	return page.map('li.session-detail', function(elem){
		var $elem = page.$(elem),
			$titleLink = $elem.find('h3 a'),
			$link = $elem.find('p a'),
			$time = $elem.find('.time'),
			$paragraph = $elem.find('p');
		
		$paragraph.find('strong:contains(presented by)').remove();

		var session = {
			title: $titleLink.text(),
			url: page.getHref($titleLink),
			startTime: page.getText($time),
			speakers: page.map($paragraph.find('a').remove(), function(link){
				return {
					name: page.$(link).text(),
					twitterHandle: page.getTwitterHandle(page.$(link))
				};
			})
		};

		// Add non-Twitter, non-linked speaker names
		var nonTwitterSpeakers = $paragraph.text().replace(' and ', ', ').split(', ');
		nonTwitterSpeakers.forEach(function(name){
			if (name.trim() !== '') {
				session.speakers.push({
					name: name.trim()
				});
			}
		});

		return session;
	});
};

var parse = function(markup, callback) {
	var $ = cheerio.load(markup),
		page = new Page($);

	callback(null, {
		title: page.getText('h1.summary'),
		tagline: page.getText('h2.tagline'),
		websiteUrl: page.getHref('.item-meta a.website'),
		scheduleUrl: page.getHref('.item-meta a.seeschedule'),
		location: parseLocation(page),
		venues: parseVenues(page),
{'fraction_non_alphanumeric': 0.19596891694997573, 'fraction_numerical': 0.003399708596406022, 'mean_word_length': 3.9270334928229667, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2807756', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1376, 'n_words': 279}