none

mail@pastecode.io avatar
unknown
python
a year ago
1.3 kB
4
Indexable
Never
import csv
import re
import string



with open('CFE-D.tsv', 'r', newline='') as tsv_file:
    tsv_reader = csv.reader(tsv_file, delimiter='\t')
    next(tsv_reader)
    
    none_infavor = 0
    none_against = 0
    total_infavor = 0
    total_against = 0


    for row in tsv_reader:
        alignment = row[2]
        comment = row[3]
        label = row[12] if len(row) >= 13 else None

        if alignment == "In favor" or label == "In favor":
            total_infavor += 1
        if alignment == "Against" or label == "Against":
            total_against += 1

        if '?' not in comment and '!' not in comment:
            if alignment == "In favor" or label == "In favor":
                none_infavor += 1
            elif alignment == "Against" or label == "Against":
                none_against += 1

    print(f'Nombre de commentaires POUR sans "?" ni "!" : {none_infavor}')
    print(f'Nombre de commentaires CONTRE sans "?" ni "!" : {none_against}')
    print("-"*33)
    print("-"*33)
    print(f'Fréquence relative des commentaires POUR sans "?" ni "!" :   {round(none_infavor / total_infavor * 100, 2)}')
    print(f'Fréquence relative des commentaires CONTRE sans "?" ni "!" :   {round(none_against / total_against * 100, 2)}')
    print("-"*33)