def test(): default_mode = spelling_mode.spelling_mode() rulesets.set_default_mode(default_mode.combination) text = rulesets.to_upper(unicode(sample_text.get_sample_text())) histogram = statistics.map_labels(statistics.get_letter_histogram(text), DEFAULT_REPLACEMENTS) histogram2 = statistics.keep_n_largest(histogram, 20) print histogram2 print histogram2[:][1] plot_letter_histogram(TMP_PLOT_FILE, histogram2, 200, 200) console.show_image(TMP_PLOT_FILE) new_text = text[100:] + 'XXÖÖÜßßßßxxxxp' histogram = statistics.get_letter_histogram(text) histogram2 = statistics.get_letter_histogram(new_text) changes = statistics.compute_changes(histogram, histogram2) summary_small_changes = statistics.summarize_small_changes(changes, 0.05) actual_changes = statistics.keep_actual_changes(changes,0.05) plot_frequency_change_bars(TMP_PLOT_FILE, actual_changes, 600, 200, summary_small_changes) console.show_image(TMP_PLOT_FILE)
def prepare_histogram_image_view(self, text, plot_file): normalized_text = rulesets.to_upper(unicode(text)) histogram = statistics.map_labels(statistics.get_letter_histogram(normalized_text), charts.DEFAULT_REPLACEMENTS) histogram2 = statistics.keep_n_largest(histogram, 20, 'andere') charts.plot_letter_histogram(plot_file, histogram2, 200, 200)