Create new prediction, becasue forgot about another in.tsv
This commit is contained in:
parent
02b281edc8
commit
caca661287
@ -2,19 +2,37 @@ from collections import defaultdict
|
|||||||
import math
|
import math
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
open_file=open('naive_base_model.pkl','rb')
|
open_file = open('naive_base_model.pkl', 'rb')
|
||||||
write_file_test=open('test-A/out.tsv','w')
|
pickle_loaded = pickle.load(open_file)
|
||||||
write_file_dev=open('dev-0/out.tsv','w')
|
|
||||||
pickle_loaded=pickle.load(open_file)
|
|
||||||
paranomal_class_logprob, skeptic_class_logprob, word_logprobs = pickle_loaded
|
paranomal_class_logprob, skeptic_class_logprob, word_logprobs = pickle_loaded
|
||||||
|
#pickle_loaded=pickle.load(open_file)
|
||||||
|
#paranomal_class_logprob, skeptic_class_logprob, word_logprobs = pickle_loaded
|
||||||
#Niektórych słów nie bezie w zbiorze treningowym dev-0 i dev-A
|
#Niektórych słów nie bezie w zbiorze treningowym dev-0 i dev-A
|
||||||
for i in word_logprobs.keys():
|
def prediction(input,output):
|
||||||
for token, tokens in word_logprobs[i].items():
|
output_file = open(output,'w')
|
||||||
try:
|
with open(input,encoding='utf-8') as in_file:
|
||||||
if (word_logprobs['skeptic'][token] > word_logprobs['paranormal'][token]):
|
for line in in_file:
|
||||||
write_file_test.write("S\n")
|
temp_paranormal_logprob = paranomal_class_logprob
|
||||||
write_file_dev.write("S\n")
|
temp_skeptic_logprob = skeptic_class_logprob
|
||||||
|
text, timestamp = line.rstrip('\n').split('\t')
|
||||||
|
tokens = text.lower().split(' ')
|
||||||
|
for token in tokens:
|
||||||
|
if token not in word_logprobs['paranormal']:
|
||||||
|
word_logprobs['paranormal'][token] = 0
|
||||||
|
if token not in word_logprobs['skeptic']:
|
||||||
|
word_logprobs['skeptic'][token] = 0
|
||||||
|
|
||||||
|
temp_paranormal_logprob += paranomal_class_logprob + word_logprobs['paranormal'][token]
|
||||||
|
temp_skeptic_logprob += skeptic_class_logprob + word_logprobs['skeptic'][token]
|
||||||
|
|
||||||
|
if temp_paranormal_logprob > temp_skeptic_logprob:
|
||||||
|
output_file.write('P\n')
|
||||||
else:
|
else:
|
||||||
write_file_test.write("P\n")
|
output_file.write('S\n')
|
||||||
write_file_dev.write("P\n")
|
|
||||||
except KeyError:break
|
def main():
|
||||||
|
prediction('dev-0/in.tsv','dev-0/out.tsv')
|
||||||
|
prediction('test-A/in.tsv/in.tsv','test-A/out.tsv')
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
5225
dev-0/out.tsv
5225
dev-0/out.tsv
File diff suppressed because it is too large
Load Diff
5107
test-A/out.tsv
5107
test-A/out.tsv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user