コード例 #1
0
  def update_views(self):
    global logger

    view = self.find_subview_by_name('segmented_control_highlighting_mode')
    view.selected_index = self.highlightingMode
    
    view = self.find_subview_by_name('textfield_reference_mode_name')
    view.enabled = False
    view.text = self.referenceMode.control.name
    
    view = self.find_subview_by_name('textfield_current_mode_name')
    view.enabled = False
    view.text = self.loadedMode.control.name

    if self.loadedMode.combination == self.currentMode.combination:
      view.text_color = defaults.COLOR_BLACK
      
    else:
      view.text_color = defaults.COLOR_GREY
    
    difference_count_in_rules = util.count_differences_in_dicts(self.referenceMode.combination.__dict__, self.currentMode.combination.__dict__)
    view = self.find_subview_by_name('textview_mode_statistics')
    fmt = u"Regelabweichungen zur Referenz: %d\nAnzahl Zeichen:%d (Referenz:%d)\nAnzahl verschiedener Zeichen:%d (Referenz:%d)"
    reference_text = rulesets.to_upper(unicode(self.referenceSampleText))
    reference_letter_histogram = statistics.get_letter_histogram(reference_text)
    current_text = rulesets.to_upper(unicode(self.currentSampleText))
    current_letter_histogram = statistics.get_letter_histogram(current_text)    
    view.text = fmt % ( difference_count_in_rules, len(current_text), len(reference_text), len(current_letter_histogram), len(reference_letter_histogram) )
コード例 #2
0
def test():
    histogram = get_letter_histogram(rulesets.to_upper("Dies ist ein Test!"))
    print histogram
    histogram2 = map_labels(histogram, {" ": "space"})
    print histogram2
    histogram3 = keep_n_largest(histogram2, 5, "andere")
    print histogram3
    histogram4 = get_letter_histogram(rulesets.to_upper("Das ist noch ein Test!"))

    changes = compute_changes(histogram, histogram4)
    print changes
    summary = summarize_small_changes(changes, 0.5)
    actual_changes = keep_actual_changes(changes, 0.5)
    print actual_changes
    print summary
コード例 #3
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
コード例 #4
0
ファイル: charts.py プロジェクト: marcus67/rechtschreibung
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)  
コード例 #5
0
 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)