avg = np.mean([
                metrics['FK'], metrics['CL'], metrics['DC'], metrics['SMOG'],
                metrics['ARI']
            ])

            if avg >= 6:
                results.append('no')
            else:
                results.append('yes')
    return results


path_for_pipeline = input(
    'type in the path to a folder with texts to analyze: ')

suitability = classify_1_to_4(extracting_texts_paths(path_for_pipeline))

# declaration of all the vars for the output
file_names = []
texts = []

num_of_1st_class = []
str_of_1st_class = []

num_of_2nd_class_W = []
num_of_2nd_class_S = []
str_of_2nd_class_W = []
str_of_2nd_class_S = []

num_of_3rd_class_W = []
num_of_3rd_class_S = []
Esempio n. 2
0
num_of_2nd_class_W = []
names_of_2nd_class_feats_W = []
num_of_2nd_class_S = []
names_of_2nd_class_feats_S = []

num_of_3rd_class_W = []
names_of_3rd_class_feats_W = []
num_of_3rd_class_S = []
names_of_3rd_class_feats_S = []

num_of_4th_class_W = []
names_of_4th_class_feats_W = []
num_of_4th_class_S = []
names_of_4th_class_feats_S = []

paths = extracting_texts_paths(path_for_pipeline)


# transform a word to a mask of type CVC... where C is a consonant and V is a vowel
def get_word_mask(word):
    mask = []

    for sym in word:
        mask.append('V' if sym in text_accentAPI.VOWELS else 'C')

    return mask


def get_accent_syl_id(accentuated_char_id, list_of_syls_lengths):
    last = len(list_of_syls_lengths) - 1
Esempio n. 3
0
        writer.write(header_of_table + '\n')

        for i in tqdm(range(len(list_of_paths))):

            if list_of_paths[i][-3:] == 'csv':
                pass
            else:
                length = len(list_of_paths)

                with open(list_of_paths[i], 'r', encoding='utf-8') as opener:
                    readability_result = func(opener.read())
                    name = list_of_paths[i].split('\\')[-1]

                    if i == length-1:
                        writer.write(name + ', ' + ', '.join([str(round(value, 3))
                                                              for value in readability_result.values()]))
                    else:
                        writer.write(name + ', ' + ', '.join([str(round(value, 3))
                                                              for value in readability_result.values()]) + '\n')


if __name__ == '__main__':
    header = 'filename, Flesch-Kincaid, Coleman-Liau index, Dale-Chale readability formula, readability level (SMOG), ' \
             'Automated Readability Index, # of chars, # of spaces, # of letters, # of words, # of sentences, ' \
             '# of complex words, # of simple words, average # of words per sentence, ' \
             'average # of syllables per sentence, % of complex words'

    path_for_offline_api = input("type in the path to a folder with texts to analyze: ")

    create_an_output_table_offline(extracting_texts_paths(path_for_offline_api), IB_metrics_readability.calc_readability_metrics, header)