Update rockyRoadtoDublin.py

This commit is contained in:
Iwona Christop 2022-05-28 17:57:38 +02:00
parent 40653583a6
commit 57bb940cb8

View File

@ -1,8 +1,12 @@
import inout as io import inout as io
def generateChooChoo(data, target, categories): def generateChooChoo(data, target, categories):
data = [x[2].replace('\n', '').replace(':', '') for x in io.read(data)] data = io.read(data)
years = [x[0] for x in data]
text = [x[2].replace('\n', '').replace(':', '') for x in data]
target = [x[0].replace('\n', '') for x in io.read(target)] target = [x[0].replace('\n', '') for x in io.read(target)]
for i in range(len(text)):
data[i] = text[i] + ' year:'
if categories == {}: if categories == {}:
i = 0 i = 0
@ -14,7 +18,11 @@ def generateChooChoo(data, target, categories):
return {'data': data, 'target': target}, categories return {'data': data, 'target': target}, categories
def predictFuture(test): def predictFuture(test):
data = [x[2].replace('\n', '').replace(':', '') for x in io.read(test + '/in.tsv')] data = io.read(test)
years = [x[0] for x in data]
text = [x[2].replace('\n', '').replace(':', '') for x in data]
for i in range(len(text)):
data[i] = text[i] + ' year:'
with open('vw-' + test, 'w', encoding='utf-8') as f: with open('vw-' + test, 'w', encoding='utf-8') as f:
for text in data: for text in data:
f.write('1 |text ' + text + '\n') f.write('1 |text ' + text + '\n')