Spaces:
Build error
Build error
File size: 598 Bytes
bf13772 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import json
with open('test.txt', 'r') as f:
file = f.readlines()
n = 1
l = 0
for line in file:
line = json.loads(line)
text1 = line['major_premise']
text2 = line['minor_premise']
if type(text1) == str:
l = l + len(text1.split(" "))
else:
for text in text1:
l = l + len(text.split(" "))
if type(text2) == str:
l = l + len(text2.split(" "))
else:
for text in text2:
l = l + len(text.split(" "))
n += 1
result = l/n
print(result) |