Created
May 2, 2012 20:59
-
-
Save melix/2580483 to your computer and use it in GitHub Desktop.
Factchecking #LeDebat !
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
import groovy.json.JsonSlurper | |
def candidats = ['#Sarkozy', '#Hollande'] | |
def flavors = ['INCORRECT', 'CORRECT', 'IMPRECIS'] | |
def factchecking = [:].withDefault { [:].withDefault { 0 } } | |
15.times { page -> | |
def jsonText = new URL("http://otter.topsy.com/search.json?type=tweet&q=factchecking+from:LeVeritometre&window=1d&offset=${10 * page}").text | |
def answers = new JsonSlurper().parseText(jsonText) | |
answers.response.list.title.each { content -> | |
candidats.each { c -> | |
if (content =~ c) { | |
boolean found = false | |
flavors.each { flavor -> | |
if (content =~ flavor && !found) { | |
factchecking[c][flavor]++ | |
found = true | |
} | |
} | |
} | |
} | |
} | |
} | |
factchecking |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment