User:Natasa Siencnik/workshop1: Difference between revisions
No edit summary |
|||
(121 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Category:Prototyping]] | [[Category:Prototyping]] | ||
[[Category:2011 P1.02]] | |||
=Time for Revolution= | |||
WORLD CLOCK INSTALLATION MEASURING POLITICAL DEBATE ON TWITTER | |||
<br /> | |||
<br /> | |||
[[File:Revolution_Quotation_Open-day.jpg | 750px]]<br /> | |||
<br /> | |||
===Sketches and Ideas=== | |||
[[File:Presentation-lower BW-new.jpg | 1000px]] | |||
<br /> | |||
<br /> | |||
===Concept=== | |||
Inspired by both the current political struggles in North Africa and the supposed lack of public participation in Western societies, the installation of parallel clocks is monitoring the political activity according to Twitter in a selection of countries. Conventional world clocks are typically found in loci such as hotel lobbies or stock market halls, representing stand-alone heterotopias, yet displaying their undeniable dependencies and power relations. But instead of progressing in time simultaneously, the incoming tweets about revolution are the engine for driving the clock hand. While time is running faster in some countries, others seem to be in a static mode, providing both stability and stagnancy. Presented simultaneous and equal in their physical manifestation, some clocks indicate it is time for change in an infinite loop.<br /> | |||
== | <br /> | ||
[[File:World-Clock.png | 500px]]<br /> | |||
<br /> | <br /> | ||
<br /> | <br /> | ||
===Project Description=== | |||
1 — Searching Twitter for keywords related to political debate for a selection of countries<br /> | |||
2 — Entries related to each country are the engine for moving the clock hand<br /> | |||
3 — Displaying current <i>political time</i> for each country | |||
<br /> | |||
<br /> | |||
===Scripting Progress=== | |||
[[File:TwitterRevolution_Flowchart.jpg | | [[File:TwitterRevolution_Flowchart.jpg | 500px]]<br /> | ||
=====Python : Script 2011-02-15===== | |||
<source lang="python"> | |||
<source lang=" | |||
#!//usr/bin/python | #!//usr/bin/python | ||
import urllib2, json, sys | import urllib2, json, sys | ||
#from apikey import apikey | |||
#api = twitter.Api(username=username, password=password) | |||
url = 'http://search.twitter.com/search.json?q=%23revolution' | url = 'http://search.twitter.com/search.json?q=%23revolution' | ||
f = urllib2.urlopen(url) | f = urllib2.urlopen(url) | ||
data = json.load(f) | data = json.load(f) | ||
for r in data['results']: | |||
# print r['created_at'] + r['from_user'] + ' : "' + r['text'] + '"' | |||
sys.stdout.write r['created_at'] + r['from_user'] + ' : "' + r['text'] + '"' | |||
</source> | |||
=====Python : Script 2011-03-10===== | |||
<source lang="python"> | |||
#!/usr/bin/env python | |||
#-*- coding:utf-8 -*- | |||
import os, urllib2, json, sys, codecs | |||
enc = codecs.getencoder("ascii") | |||
def twittersearch(tag): | |||
url = enc(u'http://search.twitter.com/search.json?q=%%23%s' % tag, "xmlcharrefreplace")[0] | |||
print("Query-URL: " + url) | |||
f = urllib2.urlopen(url) | |||
data = json.load(f) | |||
out = [] | |||
for entry in data['results']: | |||
d = {} | |||
for key in ('created_at', 'id', 'text', 'iso_language_code') : | |||
d[key] = entry[key] | |||
out.append(d) | |||
return out | |||
list_of_languages = [ | |||
u"Rewolusie", | |||
u"Revolucion", | |||
#u"الثورة", | |||
#u"Հեղափոխություն", | |||
u"Inqilab", | |||
u"Iraultza", | |||
#u"Рэвалюцыі", | |||
#u"Революция", | |||
u"Revolució", | |||
#u"革命", | |||
u"Revolucija", | |||
u"Revoluce", | |||
u"Revolution", | |||
u"Revolutie", | |||
u"Revolutsioon", | |||
u"Rebolusyon", | |||
u"Vallankumous", | |||
u"Révolution", | |||
u"Revolución", | |||
#u"რევოლუცია", | |||
#u"Επανάσταση", | |||
u"Revolisyon", | |||
#u"מהפכה", | |||
#u"क्रांति", | |||
u"Forradalom", | |||
u"Revolusi", | |||
u"Réabhlóid", | |||
u"Rivoluzione", | |||
#u"革命", | |||
#u"רעוואָלוציע", | |||
#u"혁명", | |||
u"Revolūcija", | |||
u"Revoliucija", | |||
#u"Револуција", | |||
u"Rivoluzzjoni", | |||
#u"انقلاب", | |||
u"Rewolucji", | |||
u"Revolução", | |||
u"Revoluţie", | |||
#u"Революции", | |||
#u"Револуција", | |||
u"Revolúcia", | |||
u"Mapinduzi", | |||
#u"การปฏิวัติ", | |||
u"Devrim", | |||
#u"Революції", | |||
u"Cách mạng", | |||
u"Chwyldro", | |||
] | |||
out = [] | |||
for tag in list_of_languages: | |||
out.extend(twittersearch(tag)) | |||
ids = [] | |||
for entry in out: | |||
if entry['id'] in ids: | |||
print('non-unique id found\n') | |||
else: | |||
ids.append(entry['id']) | |||
print("%(created_at)s - %(id)d : %(text)s\nIn %(iso_language_code)s" % entry) | |||
sys.exit() | |||
</source> | |||
=====Python : Script 2011-03-24===== | |||
<source lang="python"> | |||
#!/usr/bin/env python | |||
#-*- coding:utf-8 -*- | |||
import os, urllib2, json, sys, codecs, datetime | |||
enc = codecs.getencoder("ascii") | |||
def twittersearch(query): | |||
url = enc(u'http://search.twitter.com/search.json?q=%s' % query, "xmlcharrefreplace")[0] | |||
print("Query-URL: " + url) | |||
f = urllib2.urlopen(url) | |||
data = json.load(f) | |||
out = [] | |||
for entry in data['results']: | |||
d = {} | |||
for key in ('created_at', 'id', 'text', 'iso_language_code') : | |||
d[key] = entry[key] | |||
out.append(d) | |||
return out | |||
for | list_of_queries = [ | ||
{"country":"Egypt","tags": ["revolution"]}, | |||
{"country":"Libya","tags": ["revolution"]} | |||
] | |||
out = {} | |||
for qd in list_of_queries: | |||
out[qd["country"]] = [] | |||
for tag in qd["tags"]: | |||
query = u"%%23%s+%%23%s" % (tag, qd["country"]) | |||
out[qd["country"]].extend(twittersearch(query)) | |||
for (country, entries) in out.items(): | |||
ids = [] | |||
print(country) | |||
for entry in entries: | |||
if entry['id'] in ids: | |||
print('non-unique id found\n') | |||
else: | |||
ids.append(entry['id']) | |||
print("%(created_at)s - %(id)d : %(text)s\nIn %(iso_language_code)s" % entry) | |||
sys.exit() | |||
</source> | </source> | ||
=====Python : Compare Date and Time===== | |||
<source lang="php"> | <source lang="php"> | ||
import datetime | |||
In [4]: dt = datetime.datetime.strptime("24 Mar 2011 10:48:33", "%d %b %Y %H:%M:%S") | |||
In [5]: dt | |||
Out[5]: datetime.datetime(2011, 3, 24, 10, 48, 33) | |||
In [6]: dt2 = datetime.datetime.strptime("24 Mar 2011 10:48:35", "%d %b %Y %H:%M:%S") | |||
In [7]: dt2 | |||
Out[7]: datetime.datetime(2011, 3, 24, 10, 48, 35) | |||
In [8]: dt2 > dt | |||
Out[8]: True | |||
In [9]: dt2 == dt | |||
Out[9]: False | |||
</source> | |||
=====Python : Script 2011-03-28===== | |||
<source lang="python"> | |||
#!/usr/bin/env python | |||
#-*- coding:utf-8 -*- | |||
import os, urllib2, json, sys, codecs, datetime, MySQLdb | |||
enc = codecs.getencoder("ascii") | |||
search = "revolution" | |||
def twittersearch(query): | |||
url = enc(u'http://search.twitter.com/search.json?q=%s' % query, "xmlcharrefreplace")[0] | |||
print("Query-URL: " + url) | |||
f = urllib2.urlopen(url) | |||
data = json.load(f) | |||
out = [] | |||
for entry in data['results']: | |||
d = {} | |||
for key in ('created_at', 'id', 'text', 'iso_language_code') : | |||
d[key] = entry[key] | |||
out.append(d) | |||
return out | |||
def getDateTime(timestring): | |||
#return datetime suitable for mysql | |||
return 0 | |||
conn = MySQLdb.connect (host = "localhost", user = "natasa", passwd = "********", db = "revolution") | |||
list_of_queries = [ | |||
{"country":"Egypt","tags": [search]}, | |||
{"country":"Libya","tags": [search]} | |||
] | |||
out = {} | |||
for qd in list_of_queries: | |||
out[qd["country"]] = [] | |||
for tag in qd["tags"]: | |||
query = u"%%23%s+%%23%s" % (tag, qd["country"]) | |||
out[qd["country"]].extend(twittersearch(query)) | |||
for (country, entries) in out.items(): | |||
ids = [] | |||
print(country) | |||
for entry in entries: | |||
if entry['id'] in ids: | |||
print('non-unique id found\n') | |||
else: | |||
ids.append(entry['id']) | |||
print("%(created_at)s - %(id)d : %(text)s\nIn %(iso_language_code)s" % entry) | |||
time = 0;#getDateTime(created_at) | |||
try: | |||
query = "insert into tweets (tweet_id, tweet_time, tweet_search, tweet_text) values('%s', %d, '%s', '%s')" % (entry['id'], time, search, entry['text']) | |||
print('query %s' % query) | |||
cursor = conn.cursor () | |||
cursor.execute (query) | |||
#update tags/tweet table | |||
#update current time country | |||
except ValueError: | |||
print "tweet already in database" | |||
conn.close() | |||
sys.exit() | |||
</source> | |||
=====Python : Script 2011-04-05===== | |||
<source lang="python"> | |||
#!/usr/bin/env python | |||
#-*- coding:utf-8 -*- | |||
import os, urllib2, json, sys, codecs, datetime, time | |||
#url = BIG_URL+"q="+search | |||
#data = json.load(urllib2.urlopen().read(url)) | |||
search = codecs.open("twitterFeed_json", encoding="utf-8") | |||
data = json.load(search) | |||
tweetTimes = [] | |||
import dateutil, dateutil.parser | |||
#for d in data["results"]: | |||
# tweetTimes.append((d["created_at"], d["text"])) | |||
for d in reversed(data["results"]): | |||
createdTime = dateutil.parser.parse(d["created_at"]) | |||
tweetTimes.append((createdTime, d["text"])) | |||
# Perform the Tweets! | |||
for i, (createdTime, text) in enumerate(tweetTimes): | |||
print text | |||
print | |||
if i+1 < len(tweetTimes): | |||
(nextTime, nextText) = tweetTimes[i+1] | |||
print createdTime, nextTime | |||
diff = nextTime - createdTime | |||
diffsecs = diff.seconds + (diff.days * 60 * 60 * 24) | |||
time.sleep(diffsecs * 0.0001 ) | |||
# os.system("mplayer foo.wav") | |||
</source> | |||
=====Python : Script 2011-04-18===== | |||
<source lang="python"> | |||
#!/usr/bin/env python | |||
#-*- coding:utf-8 -*- | |||
import os, urllib2, json, sys, codecs, datetime, time | |||
# Open the url and save the result in data | |||
def getdata(query) : | |||
url = "http://search.twitter.com/search.json?q=%23"+query | |||
search = urllib2.urlopen(url) | |||
result = json.load(search) | |||
return result | |||
tag = sys.argv[1] | |||
data = getdata(tag) | |||
frequency = sys.argv[2] | |||
tweetTimes = [] | |||
import dateutil, dateutil.parser | |||
for d in reversed(data["results"]): | |||
createdTime = dateutil.parser.parse(d["created_at"]) | |||
tweetTimes.append((createdTime, d["text"])) | |||
# Perform the Tweets! | |||
for i, (createdTime, text) in enumerate(tweetTimes): | |||
print text | |||
print | |||
if i+1 < len(tweetTimes): | |||
(nextTime, nextText) = tweetTimes[i+1] | |||
print createdTime, nextTime | |||
diff = nextTime - createdTime | |||
diffsecs = diff.seconds + (diff.days * 60 * 60 * 24) | |||
time.sleep(diffsecs * 0.01 ) | |||
os.system("tones 50 "+frequency) | |||
</source> | |||
=====Python : Script 2011-04-19===== | |||
<span style="font-size:8.5pt"> | |||
python twitterFeed-timestamps_20110418.py peace 220<br /> | |||
python twitterFeed-timestamps_20110418.py war 262<br /> | |||
python twitterFeed-timestamps_20110418.py freedom 330<br /> | |||
python twitterFeed-timestamps_20110418.py revolution 397<br /> | |||
<source lang="python"> | |||
#!/usr/bin/env python | |||
#-*- coding:utf-8 -*- | |||
import os, urllib2, json, sys, codecs, datetime, time | |||
var = 1 | |||
while var == 1 : # This constructs an infinite loop | |||
# Open the url and save the result in data | |||
def getdata(query) : | |||
url = "http://search.twitter.com/search.json?q=%23"+query | |||
search = urllib2.urlopen(url) | |||
result = json.load(search) | |||
return result | |||
tag = sys.argv[1] | |||
data = getdata(tag) | |||
frequency = sys.argv[2] | |||
tweetTimes = [] | |||
import dateutil, dateutil.parser | |||
for d in reversed(data["results"]): | |||
createdTime = dateutil.parser.parse(d["created_at"]) | |||
tweetTimes.append((createdTime, d["text"])) | |||
# Perform the Tweets! | |||
for i, (createdTime, text) in enumerate(tweetTimes): | |||
print text | |||
print | |||
if i+1 < len(tweetTimes): | |||
(nextTime, nextText) = tweetTimes[i+1] | |||
print createdTime, nextTime | |||
diff = nextTime - createdTime | |||
diffsecs = diff.seconds + (diff.days * 60 * 60 * 24) | |||
time.sleep(diffsecs * 0.01 ) | |||
os.system("tones 50 "+frequency) | |||
</source> | </source> | ||
<br /> | |||
===Database=== | |||
Here are my first attempts in creating a SQL database.<br /> | |||
<br /> | |||
[[File:Screenshot-sql-revolution.png]]<br /> | |||
[[File:Screenshot-sql-tweets2.png | 500px]]<br /> | |||
[[File:Screenshot-mysql-countries.png | 500px]]<br /> | |||
<br /> | |||
<br /> | |||
===List of Countries=== | |||
LY - Libya - Tripoli<br /> | |||
EG - Egypt - Cairo<br /> | |||
IQ - Iraq - Baghdad<br /> | |||
RU - Russia - Moskow<br /> | |||
JP - Japan - Tokyo<br /> | |||
IN - India - New Delhi<br /> | |||
CN - China - Beijing<br /> | |||
KP - North Korea - Pyongyang<br /> | |||
IL - Israel - Jerusalem<br /> | |||
PS - Palestine - Ramallah<br /> | |||
US - United States - New York<br /> | |||
UK - United Kingdom - London<br /> | |||
NL - Netherlands - Amsterdam<br /> | |||
<br /> | |||
===List of Keywords=== | |||
Anarchism<br /> | |||
Anarchist<br /> | |||
Biopolitics<br /> | |||
Cabinet<br /> | |||
Campaign<br /> | |||
Capitalism<br /> | |||
Capitalist<br /> | |||
Coalition<br /> | |||
Communism<br /> | |||
Communist<br /> | |||
Constitution<br /> | |||
Delegation<br /> | |||
Democracy<br /> | |||
Democratic<br /> | |||
Dictator<br /> | |||
Dictatorship<br /> | |||
Election<br /> | |||
Empire<br /> | |||
Enemy<br /> | |||
Federal republic<br /> | |||
Free<br /> | |||
Freedom<br /> | |||
Governance<br /> | |||
Government<br /> | |||
Governmentality<br /> | |||
House of Commons<br /> | |||
House of Lords<br /> | |||
Ideology<br /> | |||
Leader<br /> | |||
Leadership<br /> | |||
Left-Wing<br /> | |||
Liberalism<br /> | |||
Liberalist<br /> | |||
Lobby<br /> | |||
Military<br /> | |||
Monarchy<br /> | |||
Nation state<br /> | |||
Nomination<br /> | |||
Nominee<br /> | |||
Oligarchy<br /> | |||
Opposition<br /> | |||
Oppositional<br /> | |||
Parliament<br /> | |||
Participatory democracy<br /> | |||
Plutocracy<br /> | |||
Police<br /> | |||
Political<br /> | |||
Politics<br /> | |||
Poll<br /> | |||
President<br /> | |||
President<br /> | |||
Presidential system<br /> | |||
Reactionary<br /> | |||
Rebells<br /> | |||
Regime<br /> | |||
Regnacy<br /> | |||
Revolution<br /> | |||
Revolutionary<br /> | |||
Revolotionist<br /> | |||
Right-Wing<br /> | |||
Self-determination<br /> | |||
Socialism<br /> | |||
Super Tuesday<br /> | |||
Terrorism<br /> | |||
Totalitarian<br /> | |||
Vote<br /> | |||
Voting<br /> | |||
<br /> | |||
===List of Languages=== | |||
<span style="font-size:8.5pt"> | |||
Link: http://www.explore2india.com/worldcapital.htm | |||
Link: http://en.wikipedia.org/wiki/List_of_countries_and_capitals_in_native_languages | |||
</span> | |||
Afriaans: Rewolusie<br /> | |||
Albanian: Revolucion<br /> | |||
Arabic: الثورة<br /> | |||
Armenian: Հեղափոխություն<br /> | |||
Azerbaijjani: Inqilab<br /> | |||
Basque: Iraultza<br /> | |||
Belarusian: Рэвалюцыі<br /> | |||
Bulgarian: Революция<br /> | |||
Catalan: Revolució<br /> | |||
Chinese: 革命<br /> | |||
Croatian: Revolucija<br /> | |||
Czech: Revoluce<br /> | |||
Danish: Revolution<br /> | |||
Dutch: Revolutie<br /> | |||
English: Revolution<br /> | |||
Estonian: Revolutsioon<br /> | |||
Filipino: Rebolusyon<br /> | |||
Finnish: Vallankumous<br /> | |||
French: Révolution<br /> | |||
Galician: Revolución<br /> | |||
Georgian: რევოლუცია<br /> | |||
German: Revolution<br /> | |||
GreeK: Επανάσταση<br /> | |||
Haitian: Revolisyon<br /> | |||
Hebrew: מהפכה<br /> | |||
Hindi: क्रांति<br /> | |||
Hungarian: Forradalom<br /> | |||
Icelanding: Revolution<br /> | |||
Indonasian: Revolusi<br /> | |||
Irish: Réabhlóid<br /> | |||
Italian: Rivoluzione<br /> | |||
Japanese: 革命<br /> | |||
Jiddish: רעוואָלוציע<br /> | |||
Korean: 혁명<br /> | |||
Latvian: Revolūcija<br /> | |||
Lithuanian: Revoliucija<br /> | |||
Macedonian: Револуција<br /> | |||
Malay: Revolusi<br /> | |||
Maltese: Rivoluzzjoni<br /> | |||
Norvegian: Revolution<br /> | |||
Persian: انقلاب<br /> | |||
Polish: Rewolucji<br /> | |||
Portuguese: Revolução<br /> | |||
Romanian: Revoluţie<br /> | |||
Russian: Революции<br /> | |||
Serbian: Револуција<br /> | |||
Slovak: Revolúcia<br /> | |||
Slovenian: Revolucija<br /> | |||
Spanish: Revolución<br /> | |||
Swahili: Mapinduzi<br /> | |||
Swedish: Revolution<br /> | |||
Tagalog: Rebolusyon<br /> | |||
Thai: การปฏิวัติ<br /> | |||
Turkish: Devrim<br /> | |||
Ukrainian: Революції<br /> | |||
Urdu: انقلاب<br /> | |||
Vietnamese: Cách mạng<br /> | |||
Welsh: Chwyldro<br /> | |||
<br /> | |||
===Assessment 04.2011=== | |||
Symphony in one movement about PEACE_WAR_FREEDOM_REVOLUTION in A Minor<br /> | |||
<br /> | |||
[[File:Screenshot_ASSESSMENT_natasa.png | 750px]]<br /> | |||
<br /> | |||
A 220 Hz Peace<br /> | |||
C 262 Hz War<br /> | |||
E 330 Hz Freedom<br /> | |||
G 397 Hz Revolution<br /> | |||
<br /> | |||
===Revolutionary Music=== | |||
Based on the presentation for the assessment I decided to work further on a musical performance and plan to work on a physical installation with Stock.<br /> | |||
1 — Perform music based on online discussions / trends<br /> | |||
2 — Define set of positive and negativ words (e.g. war = negative, peace = positive)<br /> | |||
3 — Positive words are performed in major and negtive in minor within one scale<br /> | |||
4 — Physical object based on a microcontroller and little pipes that perform the <i>symphony</i><br /> | |||
<br />[[File:arduino_natasa_revolution-01.jpg | 500px]]<br /> | |||
<br /> | |||
===Questions and Tasks=== | |||
1 — What are the next steps codewise<br /> | |||
2 — Talk to Stock about building a physical installation<br /> | |||
3 — Buy servos and borrow / buy microcontroller<br /> | |||
<i> | <br /> | ||
<span style="font-size:8.5pt"> | |||
<i>Thanks to Stock, Evo, Michael and Aymeric for their technical support.</i> | |||
</span> |
Latest revision as of 14:27, 29 June 2011
Time for Revolution
WORLD CLOCK INSTALLATION MEASURING POLITICAL DEBATE ON TWITTER
Sketches and Ideas
Concept
Inspired by both the current political struggles in North Africa and the supposed lack of public participation in Western societies, the installation of parallel clocks is monitoring the political activity according to Twitter in a selection of countries. Conventional world clocks are typically found in loci such as hotel lobbies or stock market halls, representing stand-alone heterotopias, yet displaying their undeniable dependencies and power relations. But instead of progressing in time simultaneously, the incoming tweets about revolution are the engine for driving the clock hand. While time is running faster in some countries, others seem to be in a static mode, providing both stability and stagnancy. Presented simultaneous and equal in their physical manifestation, some clocks indicate it is time for change in an infinite loop.
Project Description
1 — Searching Twitter for keywords related to political debate for a selection of countries
2 — Entries related to each country are the engine for moving the clock hand
3 — Displaying current political time for each country
Scripting Progress
Python : Script 2011-02-15
#!//usr/bin/python
import urllib2, json, sys
#from apikey import apikey
#api = twitter.Api(username=username, password=password)
url = 'http://search.twitter.com/search.json?q=%23revolution'
f = urllib2.urlopen(url)
data = json.load(f)
for r in data['results']:
# print r['created_at'] + r['from_user'] + ' : "' + r['text'] + '"'
sys.stdout.write r['created_at'] + r['from_user'] + ' : "' + r['text'] + '"'
Python : Script 2011-03-10
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os, urllib2, json, sys, codecs
enc = codecs.getencoder("ascii")
def twittersearch(tag):
url = enc(u'http://search.twitter.com/search.json?q=%%23%s' % tag, "xmlcharrefreplace")[0]
print("Query-URL: " + url)
f = urllib2.urlopen(url)
data = json.load(f)
out = []
for entry in data['results']:
d = {}
for key in ('created_at', 'id', 'text', 'iso_language_code') :
d[key] = entry[key]
out.append(d)
return out
list_of_languages = [
u"Rewolusie",
u"Revolucion",
#u"الثورة",
#u"Հեղափոխություն",
u"Inqilab",
u"Iraultza",
#u"Рэвалюцыі",
#u"Революция",
u"Revolució",
#u"革命",
u"Revolucija",
u"Revoluce",
u"Revolution",
u"Revolutie",
u"Revolutsioon",
u"Rebolusyon",
u"Vallankumous",
u"Révolution",
u"Revolución",
#u"რევოლუცია",
#u"Επανάσταση",
u"Revolisyon",
#u"מהפכה",
#u"क्रांति",
u"Forradalom",
u"Revolusi",
u"Réabhlóid",
u"Rivoluzione",
#u"革命",
#u"רעוואָלוציע",
#u"혁명",
u"Revolūcija",
u"Revoliucija",
#u"Револуција",
u"Rivoluzzjoni",
#u"انقلاب",
u"Rewolucji",
u"Revolução",
u"Revoluţie",
#u"Революции",
#u"Револуција",
u"Revolúcia",
u"Mapinduzi",
#u"การปฏิวัติ",
u"Devrim",
#u"Революції",
u"Cách mạng",
u"Chwyldro",
]
out = []
for tag in list_of_languages:
out.extend(twittersearch(tag))
ids = []
for entry in out:
if entry['id'] in ids:
print('non-unique id found\n')
else:
ids.append(entry['id'])
print("%(created_at)s - %(id)d : %(text)s\nIn %(iso_language_code)s" % entry)
sys.exit()
Python : Script 2011-03-24
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os, urllib2, json, sys, codecs, datetime
enc = codecs.getencoder("ascii")
def twittersearch(query):
url = enc(u'http://search.twitter.com/search.json?q=%s' % query, "xmlcharrefreplace")[0]
print("Query-URL: " + url)
f = urllib2.urlopen(url)
data = json.load(f)
out = []
for entry in data['results']:
d = {}
for key in ('created_at', 'id', 'text', 'iso_language_code') :
d[key] = entry[key]
out.append(d)
return out
list_of_queries = [
{"country":"Egypt","tags": ["revolution"]},
{"country":"Libya","tags": ["revolution"]}
]
out = {}
for qd in list_of_queries:
out[qd["country"]] = []
for tag in qd["tags"]:
query = u"%%23%s+%%23%s" % (tag, qd["country"])
out[qd["country"]].extend(twittersearch(query))
for (country, entries) in out.items():
ids = []
print(country)
for entry in entries:
if entry['id'] in ids:
print('non-unique id found\n')
else:
ids.append(entry['id'])
print("%(created_at)s - %(id)d : %(text)s\nIn %(iso_language_code)s" % entry)
sys.exit()
Python : Compare Date and Time
import datetime
In [4]: dt = datetime.datetime.strptime("24 Mar 2011 10:48:33", "%d %b %Y %H:%M:%S")
In [5]: dt
Out[5]: datetime.datetime(2011, 3, 24, 10, 48, 33)
In [6]: dt2 = datetime.datetime.strptime("24 Mar 2011 10:48:35", "%d %b %Y %H:%M:%S")
In [7]: dt2
Out[7]: datetime.datetime(2011, 3, 24, 10, 48, 35)
In [8]: dt2 > dt
Out[8]: True
In [9]: dt2 == dt
Out[9]: False
Python : Script 2011-03-28
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os, urllib2, json, sys, codecs, datetime, MySQLdb
enc = codecs.getencoder("ascii")
search = "revolution"
def twittersearch(query):
url = enc(u'http://search.twitter.com/search.json?q=%s' % query, "xmlcharrefreplace")[0]
print("Query-URL: " + url)
f = urllib2.urlopen(url)
data = json.load(f)
out = []
for entry in data['results']:
d = {}
for key in ('created_at', 'id', 'text', 'iso_language_code') :
d[key] = entry[key]
out.append(d)
return out
def getDateTime(timestring):
#return datetime suitable for mysql
return 0
conn = MySQLdb.connect (host = "localhost", user = "natasa", passwd = "********", db = "revolution")
list_of_queries = [
{"country":"Egypt","tags": [search]},
{"country":"Libya","tags": [search]}
]
out = {}
for qd in list_of_queries:
out[qd["country"]] = []
for tag in qd["tags"]:
query = u"%%23%s+%%23%s" % (tag, qd["country"])
out[qd["country"]].extend(twittersearch(query))
for (country, entries) in out.items():
ids = []
print(country)
for entry in entries:
if entry['id'] in ids:
print('non-unique id found\n')
else:
ids.append(entry['id'])
print("%(created_at)s - %(id)d : %(text)s\nIn %(iso_language_code)s" % entry)
time = 0;#getDateTime(created_at)
try:
query = "insert into tweets (tweet_id, tweet_time, tweet_search, tweet_text) values('%s', %d, '%s', '%s')" % (entry['id'], time, search, entry['text'])
print('query %s' % query)
cursor = conn.cursor ()
cursor.execute (query)
#update tags/tweet table
#update current time country
except ValueError:
print "tweet already in database"
conn.close()
sys.exit()
Python : Script 2011-04-05
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os, urllib2, json, sys, codecs, datetime, time
#url = BIG_URL+"q="+search
#data = json.load(urllib2.urlopen().read(url))
search = codecs.open("twitterFeed_json", encoding="utf-8")
data = json.load(search)
tweetTimes = []
import dateutil, dateutil.parser
#for d in data["results"]:
# tweetTimes.append((d["created_at"], d["text"]))
for d in reversed(data["results"]):
createdTime = dateutil.parser.parse(d["created_at"])
tweetTimes.append((createdTime, d["text"]))
# Perform the Tweets!
for i, (createdTime, text) in enumerate(tweetTimes):
print text
print
if i+1 < len(tweetTimes):
(nextTime, nextText) = tweetTimes[i+1]
print createdTime, nextTime
diff = nextTime - createdTime
diffsecs = diff.seconds + (diff.days * 60 * 60 * 24)
time.sleep(diffsecs * 0.0001 )
# os.system("mplayer foo.wav")
Python : Script 2011-04-18
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os, urllib2, json, sys, codecs, datetime, time
# Open the url and save the result in data
def getdata(query) :
url = "http://search.twitter.com/search.json?q=%23"+query
search = urllib2.urlopen(url)
result = json.load(search)
return result
tag = sys.argv[1]
data = getdata(tag)
frequency = sys.argv[2]
tweetTimes = []
import dateutil, dateutil.parser
for d in reversed(data["results"]):
createdTime = dateutil.parser.parse(d["created_at"])
tweetTimes.append((createdTime, d["text"]))
# Perform the Tweets!
for i, (createdTime, text) in enumerate(tweetTimes):
print text
print
if i+1 < len(tweetTimes):
(nextTime, nextText) = tweetTimes[i+1]
print createdTime, nextTime
diff = nextTime - createdTime
diffsecs = diff.seconds + (diff.days * 60 * 60 * 24)
time.sleep(diffsecs * 0.01 )
os.system("tones 50 "+frequency)
Python : Script 2011-04-19
python twitterFeed-timestamps_20110418.py peace 220
python twitterFeed-timestamps_20110418.py war 262
python twitterFeed-timestamps_20110418.py freedom 330
python twitterFeed-timestamps_20110418.py revolution 397
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import os, urllib2, json, sys, codecs, datetime, time
var = 1
while var == 1 : # This constructs an infinite loop
# Open the url and save the result in data
def getdata(query) :
url = "http://search.twitter.com/search.json?q=%23"+query
search = urllib2.urlopen(url)
result = json.load(search)
return result
tag = sys.argv[1]
data = getdata(tag)
frequency = sys.argv[2]
tweetTimes = []
import dateutil, dateutil.parser
for d in reversed(data["results"]):
createdTime = dateutil.parser.parse(d["created_at"])
tweetTimes.append((createdTime, d["text"]))
# Perform the Tweets!
for i, (createdTime, text) in enumerate(tweetTimes):
print text
print
if i+1 < len(tweetTimes):
(nextTime, nextText) = tweetTimes[i+1]
print createdTime, nextTime
diff = nextTime - createdTime
diffsecs = diff.seconds + (diff.days * 60 * 60 * 24)
time.sleep(diffsecs * 0.01 )
os.system("tones 50 "+frequency)
Database
Here are my first attempts in creating a SQL database.
List of Countries
LY - Libya - Tripoli
EG - Egypt - Cairo
IQ - Iraq - Baghdad
RU - Russia - Moskow
JP - Japan - Tokyo
IN - India - New Delhi
CN - China - Beijing
KP - North Korea - Pyongyang
IL - Israel - Jerusalem
PS - Palestine - Ramallah
US - United States - New York
UK - United Kingdom - London
NL - Netherlands - Amsterdam
List of Keywords
Anarchism
Anarchist
Biopolitics
Cabinet
Campaign
Capitalism
Capitalist
Coalition
Communism
Communist
Constitution
Delegation
Democracy
Democratic
Dictator
Dictatorship
Election
Empire
Enemy
Federal republic
Free
Freedom
Governance
Government
Governmentality
House of Commons
House of Lords
Ideology
Leader
Leadership
Left-Wing
Liberalism
Liberalist
Lobby
Military
Monarchy
Nation state
Nomination
Nominee
Oligarchy
Opposition
Oppositional
Parliament
Participatory democracy
Plutocracy
Police
Political
Politics
Poll
President
President
Presidential system
Reactionary
Rebells
Regime
Regnacy
Revolution
Revolutionary
Revolotionist
Right-Wing
Self-determination
Socialism
Super Tuesday
Terrorism
Totalitarian
Vote
Voting
List of Languages
Link: http://www.explore2india.com/worldcapital.htm Link: http://en.wikipedia.org/wiki/List_of_countries_and_capitals_in_native_languages
Afriaans: Rewolusie
Albanian: Revolucion
Arabic: الثورة
Armenian: Հեղափոխություն
Azerbaijjani: Inqilab
Basque: Iraultza
Belarusian: Рэвалюцыі
Bulgarian: Революция
Catalan: Revolució
Chinese: 革命
Croatian: Revolucija
Czech: Revoluce
Danish: Revolution
Dutch: Revolutie
English: Revolution
Estonian: Revolutsioon
Filipino: Rebolusyon
Finnish: Vallankumous
French: Révolution
Galician: Revolución
Georgian: რევოლუცია
German: Revolution
GreeK: Επανάσταση
Haitian: Revolisyon
Hebrew: מהפכה
Hindi: क्रांति
Hungarian: Forradalom
Icelanding: Revolution
Indonasian: Revolusi
Irish: Réabhlóid
Italian: Rivoluzione
Japanese: 革命
Jiddish: רעוואָלוציע
Korean: 혁명
Latvian: Revolūcija
Lithuanian: Revoliucija
Macedonian: Револуција
Malay: Revolusi
Maltese: Rivoluzzjoni
Norvegian: Revolution
Persian: انقلاب
Polish: Rewolucji
Portuguese: Revolução
Romanian: Revoluţie
Russian: Революции
Serbian: Револуција
Slovak: Revolúcia
Slovenian: Revolucija
Spanish: Revolución
Swahili: Mapinduzi
Swedish: Revolution
Tagalog: Rebolusyon
Thai: การปฏิวัติ
Turkish: Devrim
Ukrainian: Революції
Urdu: انقلاب
Vietnamese: Cách mạng
Welsh: Chwyldro
Assessment 04.2011
Symphony in one movement about PEACE_WAR_FREEDOM_REVOLUTION in A Minor
A 220 Hz Peace
C 262 Hz War
E 330 Hz Freedom
G 397 Hz Revolution
Revolutionary Music
Based on the presentation for the assessment I decided to work further on a musical performance and plan to work on a physical installation with Stock.
1 — Perform music based on online discussions / trends
2 — Define set of positive and negativ words (e.g. war = negative, peace = positive)
3 — Positive words are performed in major and negtive in minor within one scale
4 — Physical object based on a microcontroller and little pipes that perform the symphony
Questions and Tasks
1 — What are the next steps codewise
2 — Talk to Stock about building a physical installation
3 — Buy servos and borrow / buy microcontroller
Thanks to Stock, Evo, Michael and Aymeric for their technical support.