Skip to content

Instantly share code, notes, and snippets.

@melix
Created May 2, 2012 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melix/2580483 to your computer and use it in GitHub Desktop.
Save melix/2580483 to your computer and use it in GitHub Desktop.
Factchecking #LeDebat !
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