temporal-t5/append-date.py

22 lines
700 B
Python

import datetime
import sys
for line_in in sys.stdin:
fields = line_in.rstrip('\n').split('\t')
date, text = fields[2], fields[-1]
d = datetime.datetime.strptime(date.split(' ')[0],"%Y-%m-%d")
day_of_year = str(d.timetuple().tm_yday)
day_of_month = str(d.day)
month = str(d.month)
year = str(d.year)
weekday = str(d.weekday())
day_of_year = str(d.timetuple().tm_yday)
text = text.replace('-\\n','').replace('\\n',' ')
text_splitted = text.split(' ')
for i in range(0,len(text_splitted),200):
text_chunk = ' '.join(text_splitted[i:i+200])
text_to_write = 'year: ' + year +' month: ' + month + ' day: ' + day_of_month + ' weekday: ' + weekday + ' '+ text_chunk
print(text_to_write)