File size: 714 Bytes
36ec053
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
from pathlib import Path
import sys
foldername = sys.argv[1]
"""
this script gives the text <bos> and <eos> tokens it could have all been one script but yeah
the foldername is passed and an argument when calling the script
"""
header = ['text']
songsfile = open(foldername+'.txt', 'w', encoding='UTF8')
for _,_, files in os.walk(foldername):
    for filename in files:
        print(filename)
        textsfile = open(Path(foldername, filename))
        texts = textsfile.read()
        texts = texts.split('*'*50)
        texts = texts[1:]
        for text in texts:
            text_with_tokens = f"<BOS>{text}<EOS>\n"
            #print(text_with_tokens)
            songsfile.write(text_with_tokens)