Recordings of the process

Hayden Reeves
1 / 3

This was the written journal I kept during my coding process. If it is illegible for some reason, it's also typed below.

Monday, Sep 19, 6:08 pm

So I thought that since my only and very minimal experience with coding was through HTML, I would code using that to make my life just a little easier. still, though, not easy. I'm trying to make an interactive map of Singapore with a few locations you can click on and see some information about.

Monday, Sep 19, 6:49 pm

I designed the map and uploaded it to Flickr so I could try to get the image source which I should be able to link to the HTML. So far, it's not perect. I'm gonna keep toying with it. 

Monday, Sep 19, 7:15 pm

So Flickr didn't work, but I found this website called tinypic.com where I uploaded the photo and recieved a link for the "img src=". Relieved :D Now I just have to figure out the link situation & "coords"... time for some Google education. 

Monday, Sep 19, 7:43 pm

I'm done with this for the night. I'll finish it tomorrow. I'm actually kind of enjoying this.

Monday, Sep 20, 5:16 pm

So I figured out the deal with the "coords" stuff. You have to size the image. I chose "width=600 px". Then you have to find what you want to be the center of your circle and you put that as your first two coordinates. ex, 241,69. Or, I guess, <area shape="circle" coords="241,69,10" href="#singapore_zoo">. I'm starting to get the hang of HTML. 

Monday, Sep 20, 7:18 pm

It took me 27 minutes to finally figure out how to change the line height for a paragraph. I got it, though, frustrating as it was. I've finished my bibliography now. Done and done. 

 

Reflection

The coding process for this map was not super esay, but I definitely learned a lot. I think I can truthfully say I know the basics of coding, and I know them well. I did have a few ups and downs (the downs being getting lost and teh ups being when I finally figured it out)... all in all, though, I think I really enjoyed this assignment.

Hallelujah

Hayden Reeves

So I did it. I finished the coding, and i did some math based off of what I learned from that coding. Here's a finished graph (which I will, of course, put into my video):

It's not that blurry in real life. Plus, I made it pretty because Katie told me to. And also I found an app.

Ta ta for now,

-Hayden

Still going

Hayden Reeves

Here's what I discovered: There is a program that you can use to put the information into a csv, but it's really complicated and i'm way too new at coding to possibly understand it. I found that when python spits out all that information I was talking about earlier, I can copy and paste it into a google sheets document. Here's what I'm doing now. I'm trying to go through the spreadsheet to make all of the tweets fit on one row each. I have to read all of the tweets that take up more than one word to see if they include the words "hitler" and "trump," and if they do, then I retype the tweet as "hitler trump" because that's all the information I need. I'm on cell 560 out of 3042. I might be here for a while...

Here's the final code that I used (thanks Will): 

from TwitterSearch import *
try:
    tso = TwitterSearchOrder() 
    tso.set_keywords(['Hitler']) 
    tso.set_language('en') 
    tso.set_include_entities(False) 
   
    ts = TwitterSearch(
        consumer_key = 'E45dKWxNRd4oUQIhNgpSqyncu',
        consumer_secret = 'kXV3V69kxXPLUlKq18mOz2eJhDnACVMtx8flkfWM5KG7sMaujy',
        access_token = '448004638-yX9qlCQLMIXzNnFm37hiLKhWslWAP1T5ohrj1SDX',
        access_token_secret = 'xQ3mGHvPDDVZ0Fke71zrjWWY0eyKHv7GAsSRXqpHD0kYI'
     )

    for tweet in ts.search_tweets_iterable(tso):
        print( '@%s tweeted: %s' % ( tweet['user']['screen_name'], tweet['text'] ) )


except TwitterSearchException as e: 
    print(e)

Good News & Bad news

Hayden Reeves

Here's the good news: With a lot of Will's help, I managed to get the code that will spit out any tweet with the code words that I ask for. The code (which is so much simpler than the last one... 24 lines of code instead of 465) looks like this:

from TwitterSearch import *
try:
    tso = TwitterSearchOrder() # create a TwitterSearchOrder object
    tso.set_keywords(['Trump', 'Hitler']) # let's define all words we would like to have a look for
    tso.set_language('en') # we want to see German tweets only
    tso.set_include_entities(False) # and don't give us all those entity information

    # it's about time to create a TwitterSearch object with our secret tokens
    ts = TwitterSearch(
        consumer_key = 'E45dKWxNRd4oUQIhNgpSqyncu',
        consumer_secret = 'kXV3V69kxXPLUlKq18mOz2eJhDnACVMtx8flkfWM5KG7sMaujy',
        access_token = '448004638-yX9qlCQLMIXzNnFm37hiLKhWslWAP1T5ohrj1SDX',
        access_token_secret = 'xQ3mGHvPDDVZ0Fke71zrjWWY0eyKHv7GAsSRXqpHD0kYI'
     )

     # this is where the fun actually starts 
    for tweet in ts.search_tweets_iterable(tso):
        print( '@%s tweeted: %s' % ( tweet['user']['screen_name'], tweet['text'] ) )


except TwitterSearchException as e: # take care of all those ugly errors if there are some
    print(e)

 

And here's the bad news: While it does spit out a list of tweets that look like this: 

What I really need is a number of tweets that contain the word "Hitler" and a percentage of those tweets that contain "Trump." I'm looking into an extension called SQLite that might be able to save all of the tweets into a csv file so I can search for a key word. I'll see if it works, or if i can even figure out how to code that. 

Nope.

Hayden Reeves

The code I found was written for some type of expert.. I have to find another one.

Here we go again.

Ah Ha!

Hayden Reeves

So what I found is that the new version of Python requires you write

 except Exception as e:
  

Instead of

 except Exception, e:
 

I don't know why. When I did that though, now the second line is saying there is a syntax error.

  print "Error reading id %s, exception: %s" % (kid, e)

I guess I don't know as much about coding as I thought I did...

Exception Errors

Hayden Reeves

There's this part of the code that reads:

 except Exception, e:
        print "Error reading id %s, exception: %s" % (kid, e)
        return None
    print "d.keys(): ", d.keys()   
    print "######## # OF STATUSES IN THIS GRAB: ", len(d['statuses'])
    print "max_id VALUE USED FOR THIS GRAB-->", max_id
    return d

The first line has an error that reads "invalid syntax." I have no idea how to fix that.

 

Programming process for october 25

Hayden Reeves

So I've given up on the original tutorial.. It was no good. I've moved onto one from curiositybits.com that is way more informative. I think I'm getting somewhere. I'm definitely learning a lot about coding, I can say that much about this project. I just realized that it's really easy to install modules using terminal, all you have to do is write "pip install (module)". So I just installed three different modules for this, and I have a long list of things to import at the beginning of my code. I installed urllib3, simplejson, and twython. Here's the things I've installed in the beginning of my code: 

So I'm going to keep going from here. 

 

 

Programming process for october 24

Hayden Reeves

I've decided that my data for the Unit 3 AT project will be about how frequently the word "Trump" is seen in tweets posted including the #Hitler or the keyword "Hitler." I've found a tutorial about how to find that information in python, so I'll keep updated on Nuvu about that. 

I've been told by the tutorial that I need to make an app on twitter, so I made one called "reeves44286 mining." 

I started the coding by importing "tweepy" in terminal by inserting "pip install tweepy==3.3.0"

I was told to input this in my python terminal: 

import tweepy
from tweepy import OAuthHandler
 
consumer_key = 'E45dKWxNRd4oUQIhNgpSqyncu'
consumer_secret = 'kXV3V69kxXPLUlKq18mOz2eJhDnACVMtx8flkfWM5KG7sMaujy'
access_token = '448004638-yX9qlCQLMIXzNnFm37hiLKhWslWAP1T5ohrj1SDX'
access_secret = 'xQ3mGHvPDDVZ0Fke71zrjWWY0eyKHv7GAsSRXqpHD0kYI'
 
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_secret)
 
api = tweepy.API(auth)

The numbers in token and secret are keys that were given to me by twitter after creating my app. supposedly these will give python access to tweets and information from the app. 

Actual HTML Code

Hayden Reeves

<style> #bibliography{ width: 400px;    font-size: 14px; } #bibliography p{ line-height: 40%; }</style>

<h1 style="text-align:center;">Interactive Map of Singapore</h1>

<h4 style="text-align:center;">&raquo; Click on the dots in the image to read about a part of Singapore.</h4>

<map name="singapore_map">
  <area shape="circle" coords="241,69,10" href="#singapore_zoo">
  <area shape="circle" coords="119,180,10" href="#jurong_bird_park">
  <area shape="circle" coords="270,217,10" href="#botanic_gardens">
  <area shape="circle" coords="318,247,10" href="#marina_bay_sands">
  <area shape="circle" coords="480,156,10" href="#changi_airport">
  <area shape="circle" coords="270,282,10" href="#sentosa">
</map>

<figure style="text-align:center;">
  <img usemap="#singapore_map" src="http://i63.tinypic.com/2ns6nfk.png" width="600px" </script> 
  <figcaption>Map of Singapore</figcaption>
</figure>


<div>
  <h3 id="botanic_gardens"><font color=#ad0025> Botanic Gardens </font> </h3>
  <p>The Singapore Botanic Gardens is a 156-year-old tropical garden located at the fringe of Singapore's main shopping belt. It is one of three gardens, and the only tropical garden, to be honored as a UNESCO World Heritage Site. The Botanic Gardens has been ranked Asia's top park attraction since 2013, by TripAdvisor Travellers' Choice Awards. It was declared the inaugural Garden of the Year, International Garden Tourism Awards in 2012, and received Michelin’s three-star rating in 2008.</p>
</div>

<div>
  <h3 id="changi_airport"><font color=#ad0025> Changi Airport </font></h3>
  <p>Changi Airport, is the primary civilian airport for Singapore, and one of the largest transportation hubs in Southeast Asia. It is currently the World's Best Airport (Skytrax 2016), for the fourth consecutive year and counting (Skytrax's World's Best Airport 2013-2016) and is one of the world's busiest airports by international passenger traffic and cargo traffic.</p>
</div>

<div>
  <h3 id="jurong_bird_park"><font color=#ad0025> Jurong Bird Park </font></h3>
  <p>Jurong Bird Park is an aviary and tourist attraction in Jurong, Singapore. The bird park, managed by Wildlife Reserves Singapore, covers an area of 0.2 square kilometres (49 acres) on the western slope of Jurong Hill, the highest point in the Jurong region. It was reported by Wildlife Reserves Singapore on 1 June 2016 that Jurong Bird Park will cease operation and be relocated to Mandai in 2020. It will be renamed soon. As for now, operation resumes normally.</p>
</div>

<div>
  <h3 id="marina_bay_sands"><font color=#ad0025> Marina Bay Sands </font></h3>
  <p>Marina Bay Sands is an integrated resort fronting Marina Bay in Singapore. Prior to its opening in 2010, it was billed as the world's most expensive standalone casino property at S$8 billion, including the land cost. The resort includes a 2,561-room hotel, a 1,300,000 sq ft convention-exhibition centre, the 800,000 sq ft The Shoppes at Marina Bay Sands mall, a museum, two large theatres, "celebrity chef" restaurants, two floating Crystal Pavilions, a skating rink, and the world's largest atrium casino with 500 tables and 1,600 slot machines. The complex is topped by a 1,120 ft SkyPark with a capacity of 3,900 people and a 490 ft infinity swimming pool, set on top of the world's largest public cantilevered platform, which overhangs the north tower by 220 ft.</p>
</div>

<div>
  <h3 id="sentosa"><font color=#ad0025> Sentosa </font></h3>
  <p>Sentosa is a popular island resort in Singapore, visited by some twenty million people a year. Attractions include a 1.2 mi long sheltered beach, Fort Siloso, two golf courses, the Merlion, 14 hotels, and the Resorts World Sentosa, featuring the theme park Universal Studios Singapore.</p>
</div>

<div>
  <h3 id="singapore_zoo"><font color=#ad0025> Singapore Zoo </font></h3>
  <p>The Singapore Zoo, formerly known as the Singapore Zoological Gardens and commonly known locally as the Mandai Zoo, occupies 28 hectares (69 acres) on the margins of Upper Seletar Reservoir within Singapore's heavily forested central catchment area. The zoo was built at a cost of S$9 million granted by the government of Singapore and opened on 27 June 1973. It is operated by Wildlife Reserves Singapore, who also manage the neighbouring Night Safari, River Safari and the Jurong BirdPark.</p>
</div> 

<div id="bibliography">
 <h3><font size= "-2"> Bibliography: </h3>
 <p><font size= "-2"> "Singapore Zoo." Wikipedia. Wikimedia Foundation, n.d. Web. 20 Sept. 2016. 
<p><font size= "-2"> "Sentosa." Wikipedia. Wikimedia Foundation, n.d. Web. 20 Sept. 2016. 
<p><font size= "-2"> "Jurong Bird Park." Wikipedia. Wikimedia Foundation, n.d. Web. 20 Sept. 2016. 
<p><font size= "-2"> "Marina Bay Sands." Wikipedia. Wikimedia Foundation, n.d. Web. 20 Sept. 2016. 
<p><font size= "-2"> "Singapore Botanic Gardens." Wikipedia. Wikimedia Foundation, n.d. Web. 20 Sept. 2016. 
<p><font size= "-2"> "Singapore Changi Airport." Wikipedia. Wikimedia Foundation, n.d. Web. 20 Sept. 2016. 
</div>