diff --git a/CommentTuParles/parles.py b/CommentTuParles/parles.py new file mode 100644 index 0000000..0bb3c05 --- /dev/null +++ b/CommentTuParles/parles.py @@ -0,0 +1,36 @@ +import json +import os +from collections import defaultdict + + +def analyse(): + path = "../data/" + files = os.listdir(path) + stats = { + "avg_length": defaultdict(lambda: 0), + "missing": defaultdict(lambda: 0) + } + + for filename in files: + with open(path + filename) as f: + content = json.load(f) + artist = content["name"] + songs = content["songs"] + + print("\n## %s ##" % artist) + + for song in songs: + title = song["title"] + if song["lyrics"] is not None: + lyrics = song["lyrics"] + stats["avg_length"][artist] += len(lyrics) + else: + stats["missing"][artist] += 1 + + stats["avg_length"][artist] /= len(songs) + print("%s: Average song is %i long (%i missing)." % ( + artist, stats["avg_length"][artist], stats["missing"][artist])) + + +if __name__ == '__main__': + analyse() diff --git a/LeBoulbiNet/boulbi.jpg b/LeBoulbiNet/boulbi.jpg index d962e6c..5fe84e0 100644 Binary files a/LeBoulbiNet/boulbi.jpg and b/LeBoulbiNet/boulbi.jpg differ diff --git a/LeBoulbiNet/data/Lyrics_Booba.json b/data/Lyrics_Booba.json similarity index 100% rename from LeBoulbiNet/data/Lyrics_Booba.json rename to data/Lyrics_Booba.json