Пример #1
0
 def prepare_bar_plot_image_view(self, reference_text, working_text, plot_file, width, height):
   normalized_reference_text = rulesets.to_upper(unicode(reference_text))
   normalized_working_text = rulesets.to_upper(unicode(working_text))
   reference_histogram = statistics.get_letter_histogram(normalized_reference_text)
   working_histogram = statistics.get_letter_histogram(normalized_working_text)
   changes = statistics.compute_changes(reference_histogram, working_histogram)
   summary_small_changes = statistics.summarize_small_changes(changes, 0.05)
   actual_changes = statistics.keep_actual_changes(changes, 0.05)
   
   if len(actual_changes) > 0:
     charts.plot_frequency_change_bars(plot_file, actual_changes, width, height, summary_small_changes)    
     return 1
     
   else:
     return 0
Пример #2
0
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)