Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{\rtf1\ansi\ansicpg1252\cocoartf1265\cocoasubrtf210
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural
{\field{\*\fldinst{HYPERLINK "http://www.rosalieyu.com/50-shades-of-gray-visualization/"}}{\fldrslt
\f0\fs24 \cf0 http://www.rosalieyu.com/50-shades-of-gray-visualization/}}}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

int getArticleKeywordCount(String word, String beginDate, String endDate) {
String request = baseURL + "?q=" + word + "&begin_date=" + beginDate + "&end_date=" + endDate + "&api-key=" + apiKey;
//
int total = 0;

JSONObject nytData = loadJSONObject(request);
println (request);
// println (nytData);

// exit();
JSONObject results = nytData.getJSONObject("response");
JSONObject results2 = results.getJSONObject("meta");

total = results2.getInt("hits");
println ("There were " + total + " occurences of the term " + word + " between " + beginDate + " and " + endDate);
try {
// nothing
}
catch (Exception e) {
println ("There was an error parsing the JSONObject.");
}

return(total);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode.id=processing.mode.java.JavaMode
mode=Java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
String apiKey = "cca969849fecc48bed9fa47cda530450:17:69780977";

String baseURL = "http://api.nytimes.com/svc/search/v2/articlesearch.json";

void setup() {

size(700, 300);

String[] words = {
"grey"
};
// color[] colors = {
// #FF0000, #00FF00, #0000FF
//};
String[] start = {

"19650301", "19660301", "19670301", "19680301", "19690301", "19700301", "19710301", "19720301", "19740301", "19750301", "19760301"
};
String[] end = {

"20060228", "20070228", "20080228", "20090228", "20100228", "20110228", "20120228", "20130228", "20140228","20150228"
};

int barSize = 20;
int startY = 50;


/* Search for the words in the given time framed array and stores their values */

for (int i = 0; i < start.length; i++) {
int freq = getArticleKeywordCount( words[0], start[i], end[i]);
//int freq1 = getArticleKeywordCount( words[1], start[i], end[i]);

fill(255);
rect(0, startY + (barSize * i), freq, barSize);
//rect(200, startY + (barSize * i), freq1, barSize);

fill(100);
text (start[i], 10, startY + (barSize * i) +14 );
text (start[i], 100, startY + (barSize * i) +14 );
}
}

void draw() {
//
noLoop();
}

//

Binary file not shown.