<commit_before>var express = require('express');
var ejs = require('ejs');
var Twit = require('twit');

var T = new Twit({
	consumer_key: 'BVqjZWN5bSUMEB8aWbA4w',
	consumer_secret: '<KEY>',
	access_token: '<KEY>',
	access_token_secret: '<KEY>'	
});

var app = express();

app.use(express.bodyParser());
app.use(express.static('public'));
app.use(app.router);
app.set('views', __dirname + '/views');
app.engine('html', ejs.renderFile);

var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
	console.log('Listening on ' + port + '... Happy hacking!');
});

app.get('/', function(req, res) {
	var psi = false;
	T.get('statuses/user_timeline', { screen_name: 'NEAsg', count: 5}, function(err, reply) {
		for (var i = 0; i < 5; i++) {
			if(psi == false) {
				psi = getPsiFromTweet(reply[i].text);
			}
		}
		res.render('index.ejs', { psi: psi });
	});
});

// js functions for parsing @NEAsg's tweets

function hasPSI(text) {
	text = text.toUpperCase();
	for (var i = 0; i < text.length; i++) {
		if (i >= 2) {
			if (text[i-2] + text[i-1] + text[i] === 'PSI') {
				console.log('has psi!');
				return true;
			}
		}
	}
	console.log('has no psi!')
	return false;
}

function psiTweet(text) {
	if (hasPSI) {
		return true;
	} else {
		return false;
	}
}

function is24hrPsi(text) {
	text = text.toUpperCase();
	console.log(text);
	for (var i = 0; i < text.length; i++) {
		if (i >= 6) {
			if (text[i-6] + text[i-5] + text[i-4] + text[i-3] + text[i-2] + text[i-1] + text[i] === '24-HOUR') {
				console.log('it is a 24 hour psi reading');
				return true;
			}
		}
	}
	console.log('it is not a 24hr psi reading')
	return false;
}

function getPsiFromTweet(text) {
	if (psiTweet(text) && !is24hrPsi(text)) {<commit_msg>fixed bug of displaying erronous PSI<commit_after>var express = require('express');
var ejs = require('ejs');
var Twit = require('twit');

var T = new Twit({
	consumer_key: 'BVqjZWN5bSUMEB8aWbA4w',
	consumer_secret: '<KEY>',
	access_token: '<KEY>',
	access_token_secret: '<KEY>'	
});

var app = express();

app.use(express.bodyParser());
app.use(express.static('public'));
app.use(app.router);
app.set('views', __dirname + '/views');
app.engine('html', ejs.renderFile);

var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
	console.log('Listening on ' + port + '... Happy hacking!');
});

app.get('/', function(req, res) {
	var psi = false;
	T.get('statuses/user_timeline', { screen_name: 'NEAsg', count: 5}, function(err, reply) {
		for (var i = 0; i < 5; i++) {
			if(psi == false) {
				psi = getPsiFromTweet(reply[i].text);
			}
		}
		res.render('index.ejs', { psi: psi });
	});
});

// js functions for parsing @NEAsg's tweets

function hasPSI(text) {
	text = text.toUpperCase();
	for (var i = 0; i < text.length; i++) {
		if (i >= 2) {
			if (text[i-2] + text[i-1] + text[i] === 'PSI') {
				console.log('has psi!');
				return true;
			}
		}
	}
	console.log('has no psi!')
	return false;
}

function psiTweet(text) {
	if (hasPSI(text)) {
		return true;
	} else {
		return false;
	}
}

function is24hrPsi(text) {
	text = text.toUpperCase();
	console.log(text);
	for (var i = 0; i < text.length; i++) {
		if (i >= 6) {
			if (text[i-6] + text[i-5] + text[i-4] + text[i-3] + text[i-2] + text[i-1] + text[i] === '24-HOUR') {
				console.log('it is a 24 hour psi reading');
				return true;
			}
		}
	}
	console.log('it is not a 24hr psi reading')
	return false;
}

function getPsiFromTweet(text) {
	if (psiTweet(text) && !is24hrPsi(text)) {
{'fraction_non_alphanumeric': 0.2066799885812161, 'fraction_numerical': 0.018270054239223524, 'mean_word_length': 3.7223719676549867, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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': '6750238', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1430, 'n_words': 325}