import json


def clean_text(corpus: str):
    return "\n".join([l.replace("’", "\'")
                      for l in corpus.split("\n")
                      if l != ""
                      and l.find("RapGenius France") == -1])


if __name__ == '__main__':
    corpus: str = ""

    with open("../data/Lyrics_LucioBukowski.json") as f:
        text = json.load(f)
        songs = text["songs"]
        for song in songs:
            lyrics = song["lyrics"]
            if lyrics is not None:
                corpus += lyrics + "\n"

        corpus = clean_text(corpus)

        print(corpus)
        with open("../data/genius.txt", "w+") as o:
            o.writelines(corpus)
