Sentiment analysis of blog post comments using AWS Comprehend
Last active
May 14, 2018 10:37
-
-
Save leostaples/dc9ea1f937e64e6000a5e3db2d0df27b to your computer and use it in GitHub Desktop.
Market Data comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
age | population | |
---|---|---|
positive | 27 | |
negative | 168 | |
neutral | 69 | |
mixed | 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.arc text { | |
font: 10px sans-serif; | |
text-anchor: middle; | |
} | |
.arc path { | |
stroke: #fff; | |
} | |
</style> | |
<svg width="960" height="500"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script> | |
var svg = d3.select("svg"), | |
width = +svg.attr("width"), | |
height = +svg.attr("height"), | |
radius = Math.min(width, height) / 2, | |
g = svg.append("g").attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); | |
var color = d3.scaleOrdinal(["#00ff00", "#ff0000", "#eee", "#808000"]); | |
var pie = d3.pie() | |
.sort(null) | |
.value(function(d) { return d.population; }); | |
var path = d3.arc() | |
.outerRadius(radius - 10) | |
.innerRadius(0); | |
var label = d3.arc() | |
.outerRadius(radius - 40) | |
.innerRadius(radius - 40); | |
d3.csv("data.csv", function(d) { | |
d.population = +d.population; | |
return d; | |
}, function(error, data) { | |
if (error) throw error; | |
var arc = g.selectAll(".arc") | |
.data(pie(data)) | |
.enter().append("g") | |
.attr("class", "arc"); | |
arc.append("path") | |
.attr("d", path) | |
.attr("fill", function(d) { return color(d.data.age); }); | |
arc.append("text") | |
.attr("transform", function(d) { return "translate(" + label.centroid(d) + ")"; }) | |
.attr("dy", "0.35em") | |
.text(function(d) { return d.data.age; }); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment