This commit is contained in:
alesad7 2022-04-03 22:36:26 +02:00
parent a865e5781f
commit b6f858fa1e

4
run.py
View File

@ -35,7 +35,7 @@ def predict(before, after):
prob += value prob += value
result += f'{key}:{value} ' result += f'{key}:{value} '
if prob == 0.0: if prob == 0.0:
return 'to:0.02 be:0.02 the:0.02 or:0.01 not:0.01 and:0.01 a:0.01 :0.9' return 'to:0.015 be:0.015 the:0.015 not:0.01 and:0.02 a:0.02 :0.9'
result += f':{max(1 - prob, 0.01)}' result += f':{max(1 - prob, 0.01)}'
return result return result
@ -46,7 +46,7 @@ def make_prediction(file):
for _, row in data.iterrows(): for _, row in data.iterrows():
before, after = word_tokenize(data_preprocessing(str(row[6]))), word_tokenize(data_preprocessing(str(row[7]))) before, after = word_tokenize(data_preprocessing(str(row[6]))), word_tokenize(data_preprocessing(str(row[7])))
if len(before) < 3 or len(after) < 3: if len(before) < 3 or len(after) < 3:
prediction = 'to:0.02 be:0.02 the:0.02 or:0.01 not:0.01 and:0.01 a:0.01 :0.9' prediction = 'to:0.015 be:0.015 the:0.015 not:0.01 and:0.02 a:0.02 :0.9'
else: else:
prediction = predict(before[-1], after[0]) prediction = predict(before[-1], after[0])
file_out.write(prediction + '\n') file_out.write(prediction + '\n')