25 lines
665 B
Python
25 lines
665 B
Python
import csv
|
|
import re
|
|
|
|
def makeoutput(infile, outfile):
|
|
output = []
|
|
regex = r'paranormal|ufo|youtube|spirit'
|
|
with open(infile) as tsvfile:
|
|
reader = csv.reader(tsvfile, delimiter='\t')
|
|
for row in reader:
|
|
if re.search(regex, str(row).lower()):
|
|
output.append('1')
|
|
else:
|
|
output.append('0')
|
|
|
|
|
|
with open(outfile, 'wt') as tsvfile:
|
|
tsv_writer = csv.writer(tsvfile, delimiter='\t')
|
|
for i in output:
|
|
tsv_writer.writerow(i)
|
|
|
|
makeoutput("test-A/in.tsv", "test-A/out.tsv")
|
|
makeoutput("train/in.tsv", "train/out.tsv")
|
|
makeoutput("dev-0/in.tsv", "dev-0/out.tsv")
|
|
|