@grammer_man who the fuck is this nigga and why u comin at me like that #Hoeassnigga


Posted: 2012-01-09 20:06   |  More posts about code computers funny idiots internet oddities

Had a spare hour last Thursday and decided to write a little twitter bot. There he is above. His name is Grammer_Man and he corrects other twitter users' misspellings, using data scraped from these Wikipedia pages.

Responses have been pouring in already, some agitated, some confused, but most positive -- which was a pleasant surprise. In any event, the minimal amount of effort in coding has paid off many times over in entertainment.

You can see who's responding at the moment by searching for @grammer_man, and also by checking his list of favourites.

Here is the (somewhat slapdash) code that powers our fearless spelling Nazi:

grabber.py

This module grabs the spelling data from Wikipedia.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import pickle

import requests
from BeautifulSoup import BeautifulSoup

def grab(letter):
    '''
    Grabs spellings from wikipedia
    '''
    url = 'http://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/%s' % letter
    html = requests.get(url).content
    soup = BeautifulSoup(html)
    bullets = soup.findAll('li')
    retval = {}
    for bullet in bullets:
        if 'plainlinks' in repr(bullet):
            values = bullet.text.split('(')
            if len(values) == 2:
                retval[values[0]] = values[1][:-1] # shave off the ) at end
    return retval

def get_spellings():
    '''
    Returns a dictionary of {false: correct} spellings
    '''
    if not os.path.exists('words.pkl'):
        retval = {}
        for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
            print 'Getting typos - %s' % c
            retval.update(grab(c))
        print 'Dumping...'
        f = open('words.pkl', 'w')
        pickle.dump(retval, f)
        f.close()
        return retval
    else:
        f = open('words.pkl', 'r')
        retval = pickle.load(f)
        f.close()
        return retval

if __name__ == '__main__':
    get_spellings()

bot.py

The bot. Selects misspellings at random, searches for them, responds to them, while also taking breaks between tweets and longer breaks every few hours.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import random
import time
import pickle

import twitter

from grabber import get_spellings

API = twitter.Api()

MESSAGES = u'''
Hey $USERNAME, didn't you mean $CORRECT there?
#
# All messages stored in here, one per line.
#
'''.split('\n')

def compose_message(twitter_post, mistake, correct):
    '''
    Choose a message from MESSAGES at random, substitute fields to personalise it and 
    check if it exceeds the twitter message limit. Try this 100 times before failing.
    '''
    retries = 0
    while retries < 100:
        message = MESSAGES[random.randint(0, len(MESSAGES) - 1)]
        message = message.replace('$USERNAME', '@%s' % twitter_post.user.screen_name)
        message = message.replace('$MISTAKE', '"%s"' % mistake).replace('$CORRECT', '"%s"' % correct)
        if message and len(message) < 141:
            return message
    return None

def correct_spelling(twitter_post, mistake, correct):
    '''
    Correct someone's spelling in a twitter_post
    '''
    print u'Correcting @%s for using %s...' %(twitter_post.user.screen_name, 
                                            mistake)
    message = compose_message(twitter_post, mistake, correct)
    if not message:
        print u'All messages were too long... Aborting...'
        return False
    else:
        failures = 0
        try:
            API.PostUpdate(message, in_reply_to_status_id=twitter_post.id)
        except Exception, e:
            print 'Failed to submit tweet (%s).'
            return False
        return True

def search(word):
    '''
    Search twitter for uses of a word, return one if it's been used recently.
    Otherwise return None.

    TODO: Add time awareness.
    '''
    print 'Searching for uses of %s...' % word
    results = API.GetSearch(word)
    if results:
        for result in results:
            if not check_if_done(result.id) and\
                not result.user.screen_name == 'grammer_man' and word in result.text:
                return result
    return None

def check_if_done(id):
    '''
    Checks if a tweet has already been responded to
    '''
    if os.path.exists('done.pkl'):
        f = open('done.pkl', 'r')
        done = pickle.load(f)
        f.close()
        if id in done:
            return True
    return False

def update_done(id):
    '''
    Updates a list of tweets that've been replied to
    '''
    if os.path.exists('done.pkl'):
        f = open('done.pkl', 'r')
        done = pickle.load(f)
        f.close()
    else:
        done = []

    done.append(id)

    f = open('done.pkl', 'w')
    pickle.dump(done, f)
    f.close()

def main():
    '''
    Main program flow
    '''
    words = get_spellings()
    counter = 0 
    while True:
        word = random.choice(words.keys())
        post = search(word)
        if counter > 100:
            rand_time = random.randint(120*60, 240*60)
            print 'Done %s tweets, sleeping for %s minutes' % (counter, rand_time/60)
            time.sleep(rand_time)
            counter = 0
        # TODO: PROPERLY PRUNE THE MISTAKES/CORRECTIONS FROM WIKIPEDIA AND REMOVE THIS:
        if not u',' in word + words[word] and not u';' in word + words[word]:
            if post:
                result = correct_spelling(post, word, words[word])
                if result:
                    counter += 1
                    print '#%s Done' % counter
                    update_done(post.id)
                    time.sleep(random.randint(300,500))

if __name__ == '__main__':
    main()

Grammer_Man uses the following libraries:

Comments


True terror is to wake up one morning and discover that your high school class is running the country


Posted: 2010-06-18 13:50   |  More posts about far-right germany idiots india oddities politics

Photo: Reuters

A select few quotations from a BBC article on Hitler's bizarre popularity in India:

Latest reports say Bollywood is now planning to cash in. A film - Dear Friend Hitler - is due to be released by the end of the year, focusing on the dictator's relationship with his mistress Eva Braun.

...

It's hard to narrow down what makes the dictator popular in India, but some young people say they are attracted by his "discipline and patriotism".

Most of them are, however, quick to add that they do not approve of his racial prejudices and the Holocaust in which millions of Jews were killed.

...

Nearly all the booksellers and publishers contacted in India say it is mainly young people who read Mein Kampf. It's not just the autobiography - books on the Nazi leader, T-shirts, bags, bandanas and key-rings are also in demand. A shop in Pune, called Teens, says it sells nearly 100 T-shirts a month with Hitler's image on them.

Dimple Kumari, a research associate in Pune, has not read Mein Kampf but she would wear the Hitler T-shirt out of admiration for him. She calls him "a legend" and tries to put her admiration for him in perspective: "The killing of Jews was not good, but everybody has a positive and negative side."

I have to say, I find this peculiar naivety fascinating. I also can't imagine what it must be like for a Western traveller to be walking down a street in, say, Bangalore, spotting a few people coming towards him clad in Hitler Apparel. Indeed, staying with Bangalore, since it's such a huge IT hub... Should we expect to see originally well-meaning and innocuous (to Indians, that is) photographs of young IT workers on their IBM or Microsoft campus, posing happily with their corporate swipe-cards dangling from from their neck, the strap perfectly framing a portrait of their "Dear Friend Hitler"? Indeed, do such places, renowned for their lack of dress-code in the West, already have a strict dress-code in places like India, in order to prevent such embarrassments? I wonder.

And, before I go, here's another great article from Der Spiegel on the same phenomenon, only this time in Pakistan. Yep, they're at it too. Who knows - perhaps this new-found love for the 20th century's most hated, genocidal dictator will only serve to foster a new friendship of shared values between India and Pakistan, leading to a stable peace! Surely no harm could come of future generations of two of the world's most antagonistic and unstable nuclear-countries worshipping a genocidal, maniacal, militaristic dictator!

Brings a whole new sense to that Vonnegut quote...

Comments


The biggest problem with Libertarian thinking


Posted: 2010-06-18 13:05   |  More posts about america idiots politics words

A member of reddit, quag7, contributes to a thread entitled "I am a registered Libertarian, but it seems the party has lost its way" in /r/Libertarian. Reposting here in full. Thanks to Hugh for bringing this to my attention:

Read more...

Comments


Girl banned from using sign-language on school bus


Posted: 2010-06-09 00:09   |  More posts about america idiots news

From ABC News:

School officials have threatened a hearing-impaired girl with suspension if she uses sign language to talk to her friends on the school bus, the girl's parents say.

But officials at Stonybrook School — which is not a school for the hearing-impaired — and district officials in Branchburg, N.J., apparently believe signing is a safety hazard. They have sent a letter to the Lesko family ordering Danica to stop using sign language on the school bus or risk a three-day suspension.

The March 30 letter from her principal that said Danica was "doing sign language after being told it wasn't allowed on the bus."

The Leskos may file a lawsuit over the sign language ban, claiming officials are violating Danica's civil rights and violating the Americans with Disabilities Act.

"She has a hearing problem, and now she's being punished for using sign language," Mary Ann Lesko, Danica's mother, told The Star-Ledger of Newark. "It's absurd."

A horrific story already, my heart sank to a new low when I read the closing paragraph:

Danica's parents say she began losing her hearing last November, when a classmate allegedly shot a bottle rocket near her ear. They have already sued the Branchburg School District over that incident.

Comments


Don't hold your breath for tolerance.


Posted: 2009-10-17 02:25   |  More posts about gay rights idiots media news politics

In the past week, Stephen Gately, former member of Irish boy-band Boyzone, died. Jan Moir of the Daily Mail wrote an incredibly repulsive article on the subject and Charlie Brooker responded indignantly.

Meanwhile, a Ugandan minister of parliament has proposed legislation to enforce a penalty of death for the "offence of aggravated homosexuality."

Well then.

Comments


Is this some kind of sick joke?


Posted: 2009-06-11 22:02   |  More posts about idiots media music news

From BBC News:

John Lennon's widow Yoko Ono has been given a lifetime achievement honour at Mojo magazine's awards in London.

Mojo chief editor Phil Alexander, who hosted the event, praised Ono, 76, as "a huge influence on modern music".

Bollocks.

Comments


This is what Obama is up against


Posted: 2009-06-05 18:12   |  More posts about america idiots israel / palestine conflict politics

Max Blumenthal writes: On the eve of President Barack Obama’s address to the Muslim world from Cairo, Egypt, I stepped out onto the streets of Jerusalem with my friend Joseph Dana to interview young Israelis and American Jews about their reaction to the speech. We encountered rowdy groups of beer sodden twenty-somethings, many from the United States, and all eager to vent their visceral, even violent hatred of Barack Obama and his policies towards Israel. Usually I offer a brief commentary on my video reports, but this one requires no comment at all. Quite simply, it contains some of the most shocking footage I have ever filmed. Watch it and see if you agree. (This video was removed from the Huffington Post on the grounds that it had “no news value” and “did not move the conversation forward.”)

Joseph Dana, one of the co-creators of the video above, has written the following to explain why he and Max Blumenthal made the video, and what he thinks it shows:

It’s about entitlement, stupid. Max and I went on to the streets of Jerusalem at ten o’clock on a Wednesday to ascertain the feelings of the young population about Obama’s upcoming speech in Cairo. As is often the case, the streets of central Jerusalem were not filled with native Israelis but American Jews. Doubtlessly anyone who has visited Jerusalem has encountered the droves of American Jewish kids that are sent to Israel to study for a period of time from Teaneck or Westchester. We asked people a simple question, “What do you think of Obama and Israel?” Most of the people that we talked to were dual American Israeli citizens. The answers in this video reflect the education and worrisome perspectives that many American Jews harbor towards Israeli politics. The sense of entitlement that the American Jewish community has when it comes to Israeli policy is on full raw display in the words of these young adults. Based on our interviews these people were from high socio economic backgrounds and had developed thoughts about current Israeli politics. The question is why more journalists are not covering this story. All you have to do is walk the streets of Jerusalem and you will find dozens of people that harbor the same beliefs. As a resident of Jerusalem, I can say that the people represented in this video are not members of a fringe group or simply drunk college kids. These people reflect the sentiments shared by many people in this country and this city. These people and their families are the core of the opposition to meaningful peace between Israel and her neighbors. This is what Obama is up against.

Comments


The assassination of George Tiller


Posted: 2009-06-01 16:25   |  More posts about idiots internet politics

Yesterday, an abortionist in Wichita, Kansas, Dr. George Tiller was shot dead outside the Reformation Lutheran Church in the city. The BBC has a good op-ed piece on violence in the abortion debate:

While many pro-life organisations have come out and condemned the killing on Sunday, the fact remains that violence and intimidation have remained a constant thread in the history of the modern-day movement.

According to data gathered by the National Abortion Federation, a pro-choice group, there had been at least nine killings in anti-abortion protests, 17 attempted murders and 400 death threats.

Bombings and arson attempts of abortion facilities also happen on a regular basis with cases often reaching double figures every year.

The most famous was probably the Christmas Day bombings which targeted three clinics in 1984 with the perpetrators dubbing them a "birthday gift for Jesus".

More reading material of a distinctly more repulsive nature is available in this blog post on Carnal Nation, in which the author has used Twitter for its only sensible purpose: mining public opinion. Gathered there is a collection of "tweets" from a fringe-group of pro-life nutjobs who, ironically, celebrated the assassination.

They would seem to be also supporters of the death penalty, which would make one doubt the creedence of their claim that they believe every life really is sacred. Or perhaps their flawed logic is simply the product of having been brought up to believe fundamentalist dogma, and they see no logical contradiction.

In any event, here are some of the tweets:

George Tiller the baby killer was shot dead this morning. God bless the gunmen who hopefully won't be caught.
was George Tiller the baby killers brain scrambled the way he scrambled full term fetuses.. one can only hope
No need to pray for George Tiller. We know he went straight to hell!!!!!
Tiller the Baby Killer is finally dead....God took care of what needed to be done....
the killing of tiller the baby killer was JUSTICE, not murder.

All very Christian and forgiving, don't you think? It's worth noting that the overwhelming majority of tweets from both sides of the abortion debate expressed horror at the assassination of Dr. Tiller. Indeed, the last tweet linked above seems to be from a particularly screwy individual, who also appears to be a proud racist.

So, these people aren't in the mainstream, but the Internet acts as a veritable megaphone for their idiocy. The effects on their lives is predictable, as "the stupid, bigoted comments people used to make at the water cooler now get preserved for future employers to find using Google."

But what effect does this have on the rest of us? Comment and phenomena like this will always be sought out to satisfy a kind of morbid curiosity many of us might have. Is there the chance this will result in it becoming more acceptable and popular?

Comments


Don't do this.


Posted: 2009-05-16 18:26   |  More posts about art electronic idiots music

There's a special place in hell reserved for people who take the complete piss at gigs by doing things like this:

Radiohead - Nude (Live at 93 Feet East, London, 2008-01-16)

Well handled by Thom, though, I must say. Reminds me of the Autechre bootleg, Live @ Lee's Palace (2008-04-12), a fantastic bootleg in quality and setlist, almost ruined by some stupid bitch who keeps screaming and talking in the left channel... Or the drunken idiots who kept coming up to the bootlegger at Aphex's 2008 Oxegen Festival gig.

It's more excusable in the last two cases, but even so -- what do you go to a gig for? To experience, enjoy and dance to the music? Or to scream into your poor, resentful friends' ears any banal shit that comes into your thick head?

Comments


In pursuit of the perfect body


Posted: 2009-05-16 17:56   |  More posts about idiots oddities science

A recent paper in The Lancet, an English medical journal, describes the adverse effects of steroid abuse. A striking case study in the paper is that of a 21-year-old amateur bodybuilder who arrived at a clinic in Dusseldorf, Germany with severe acne on his chest and upper back.

He was a constant user of anabolic-androgenic steroids, of which acne is a side effect — as is damaged sperm and shrunken testicles, both of which he also possessed.

Potentially NSFW photos of the severe damage done to his chest can be seen here.

I don't know if it's just me, but I find all three images equally repulsive.

Comments