Skip to content

Instantly share code, notes, and snippets.

@kardeiz
Created January 11, 2013 22:49
Show Gist options
  • Save kardeiz/4514649 to your computer and use it in GitHub Desktop.
Save kardeiz/4514649 to your computer and use it in GitHub Desktop.
blah js for later
<html>
<head>
<title>Charts</title>
<!-- <script src="../assets/d3.v2.js"></script> -->
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="../assets/sankey.js"></script>
<script src="../assets/jquery-1.8.3.min.js"></script>
<script src="../assets/underscore.js"></script>
<script src="../assets/underscore.nest.js"></script>
<script src="../assets/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.js"></script>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link href='../assets/bootstrap.css' rel='stylesheet' type='text/css'>
<link href='../assets/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css' rel='stylesheet' type='text/css'>
<style type="text/css">
</style>
</head>
<body>
<div id="content"/>
</body>
<script type="text/javascript">
$(document).ready(function(){
d3.tsv('../assets/summon_survey_results_cleaned.txt', function(csv){
processData(csv);
});
function processData(data) {
console.log(parseText("elephants exist as elephants, right, elephant?"));
}
function buildWordle() {
}
var stopWords = /^(i|me|my|myself|we|us|our|ours|ourselves|you|your|yours|yourself|yourselves|he|him|his|himself|she|her|hers|herself|it|its|itself|they|them|their|theirs|themselves|what|which|who|whom|whose|this|that|these|those|am|is|are|was|were|be|been|being|have|has|had|having|do|does|did|doing|will|would|should|can|could|ought|i'm|you're|he's|she's|it's|we're|they're|i've|you've|we've|they've|i'd|you'd|he'd|she'd|we'd|they'd|i'll|you'll|he'll|she'll|we'll|they'll|isn't|aren't|wasn't|weren't|hasn't|haven't|hadn't|doesn't|don't|didn't|won't|wouldn't|shan't|shouldn't|can't|cannot|couldn't|mustn't|let's|that's|who's|what's|here's|there's|when's|where's|why's|how's|a|an|the|and|but|if|or|because|as|until|while|of|at|by|for|with|about|against|between|into|through|during|before|after|above|below|to|from|up|upon|down|in|out|on|off|over|under|again|further|then|once|here|there|when|where|why|how|all|any|both|each|few|more|most|other|some|such|no|nor|not|only|own|same|so|than|too|very|say|says|said|shall)$/,
punctuation = /[!"&()*+,-\.\/:;<=>?\[\\\]^`\{|\}~]+/g,
discard = /^(@|https?:)/,
wordSeparators = /[\s\u3031-\u3035\u309b\u309c\u30a0\u30fc\uff70]+/g;
function parseText(text) {
tags = {};
var cases = {};
text.split(wordSeparators).forEach(function(word) {
word = word.replace(punctuation, "");
if (stopWords.test(word.toLowerCase())) return;
word = word.substr(0, 30);
cases[word.toLowerCase()] = word;
tags[word = word.toLowerCase()] = (tags[word] || 0) + 1;
});
tags = d3.entries(tags).sort(function(a, b) { return b.value - a.value; });
tags.forEach(function(d) { d.key = cases[d.key]; });
return tags.slice(0, 75);
}
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment