Created
June 10, 2014 03:34
-
-
Save jhroy/7296ffe7ffd22fc95e55 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# require "csv" | |
partis = ["QS", "CAQ", "PQ", "PLQ"] | |
partis.each do |parti| | |
fichier = "wordcloud-assnat-" + parti + ".txt" | |
fichier3 = "wordcloud-assnat-liste-mots-" + parti + ".txt" | |
puts fichier3 | |
contenu = File.open(fichier, "r").read | |
contenu = contenu.gsub(/[«»",.;:!?()]/,'').downcase | |
contenu = contenu.gsub('applaudissements','') | |
contenu = contenu.gsub(/\s.{1,2}'/," ") | |
contenu = contenu.gsub("\[",'') | |
contenu = contenu.gsub("\]",'') | |
contenu = contenu.gsub(/[[:space:]]+--[[:space:]]+/,' ') | |
contenu = contenu.gsub(/\s{2,}/,' ') | |
contenu = contenu.gsub("\n"," ") | |
contenu = contenu.gsub(" ","\n") | |
contenu = contenu.gsub(/^.{,2}$/,"") | |
contenu = contenu.gsub("\n"," ") | |
contenu = contenu.gsub(/\s{2,}/," ") | |
contenu = contenu.gsub(" ","\n") | |
f = File.open(fichier3, "w") | |
f.puts contenu | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment