def circs_in_line(play, position, len_limit=3): lines = get_lines(play, position, len_limit) str_circs = 0 ant_circs = 0 str_syls = 0 ant_syls = 0 for l in lines: str_circs += count_circs(l.texts[0]) ant_circs += count_circs(l.texts[1]) str_syls += count_syllables(l.texts[0]) ant_syls += count_syllables(l.texts[1]) total_circs = str_circs + ant_circs total_syls = str_syls + ant_syls str_percent = str_circs / str_syls ant_percent = ant_circs / ant_syls total_percent = total_circs / total_syls print('Str: {}'.format(str_percent)) print('Ant: {}'.format(ant_percent)) print('Total: {}'.format(total_percent)) return (total_circs, total_syls, str_circs, ant_circs, str_syls, ant_syls)
def circs_in_play(play, print_all=True, clean_entries=False, exclude=False, str_ant=False): clean_name = play.file[:-4] full_text = load_text(clean_name + '-CLEAN.txt', CORPUS_DIR + 'clean_OCTs/') full_circs = count_circs(full_text) full_chars = len(full_text) full_words = len(full_text.split()) full_percent = full_circs / full_chars if exclude: exclusion_list = [ 'Agamemnon-1-δ-A', 'Agamemnon-5-ζ-B', 'Agamemnon-6-γ' ] pairs = [p for p in play.pairs if p.name not in exclusion_list] else: pairs = play.pairs strophes = [pair.strophe.raw_text for pair in pairs] antistrophes = [pair.antistrophe.raw_text for pair in pairs] strophe_circs = sum([count_circs(s) for s in strophes]) strophe_chars = sum([len(s) for s in strophes]) strophe_words = sum([len(s.split()) for s in strophes]) antistrophe_circs = sum([count_circs(a) for a in antistrophes]) antistrophe_chars = sum([len(a) for a in antistrophes]) antistrophe_words = sum([len(a.split()) for a in antistrophes]) str_syl_count = sum([count_syllables(p.strophe.raw_text) for p in pairs]) ant_syl_count = sum( [count_syllables(p.antistrophe.raw_text) for p in pairs]) song_syl_count = str_syl_count + ant_syl_count full_syl_count = count_syllables(full_text) song_circs = strophe_circs + antistrophe_circs song_words = strophe_words + antistrophe_words song_percent = song_circs / song_words prose_circs = full_circs - song_circs prose_words = full_words - song_words prose_percent = prose_circs / prose_words full_per_syl = full_circs / full_syl_count song_per_syl = song_circs / song_syl_count str_per_syl = strophe_circs / str_syl_count ant_per_syl = antistrophe_circs / ant_syl_count if not clean_entries: print() print(play.name) print() print('Full text:\t' + pr_per(full_per_syl, mark=True)) print('Strophic pairs:\t' + pr_per(song_per_syl, mark=True)) print(' Str: ' + pr_per(str_per_syl, mark=True)) print(' Ant: ' + pr_per(ant_per_syl, mark=True)) if print_all: for pair in pairs: Stanza_p = pair_circs(pair) entry = pair.name + '#' + pr_per(Stanza_p, mark=False) if (Stanza_p > song_per_syl * 1.5): entry += '#XX' print(entry) if str_ant: for pair in pairs: Stanza_p = pair_circs(pair) entry = pair.name + '#' + pr_per(Stanza_p, mark=False) if (Stanza_p > song_per_syl * 1.5): entry += '#XX' print(entry) return (full_circs, full_syl_count, song_circs, song_syl_count, strophe_circs, antistrophe_circs)
def pair_circs(pair): circs = count_circs(pair.strophe.raw_text) + count_circs( pair.antistrophe.raw_text) syl_count = count_syllables(pair.strophe.raw_text + '\n' + pair.antistrophe.raw_text) return circs / syl_count
def trim_control(): circs = count_circs(WATCHMAN) syls = count_syllables(WATCHMAN) return circs / syls
def circ_per_syls(stanza): circs = count_circs(stanza.raw_text) return circs / stanza.syl_count
def percent_circ(text): circs = count_circs(text) words = len(text.split()) return circs / words