Exemplo n.º 1
0
  def handle_button_action(self, name, sender):
    BUTTON_PREFIX = 'button_'
    INFO_PREFIX = 'info_'
    
    if name == 'button_start_speech':
      speech.say(sample_text.get_sample_text(), 'de', 1.0 * self.conf.rechtschreibung.speech_speed / 100.0)
      
    elif name == 'button_stop_speech':
      speech.stop()
    
    elif name == 'button_load_mode':
      self.load_mode_start(LOAD_MODE_RULESET)
    
    elif name == 'button_load_reference_mode':
      self.load_mode_start(LOAD_MODE_REFERENCE)
    
    elif name == 'button_save_mode':
      self.save_mode_start()
    
    elif name == 'button_open_app_control_view':
      self.open_app_control_view()

    elif name == 'button_open_top_navigation_view':
      self.open_top_navigation_view()

    elif name == 'button_open_statistics_view':
      self.open_statistics_view()

    elif name == 'button_close_top_navigation_view':
      self.close_top_navigation_view()

    elif name == 'button_icon_rechtschreibung':
      self.button_icon_rechtschreibung()

    elif name.startswith(BUTTON_PREFIX):
      view_name = name[len(BUTTON_PREFIX):]
      child_view = self.find_subview_by_name(view_name)
      if child_view != None:
        view = self.find_subview_by_name(NAME_NAVIGATION_VIEW)
        view.push_view(child_view)
        return 1
        
      else:
        logger.warning("cannot find subview '%s" % view_name)
      
    elif name.startswith(INFO_PREFIX):
      info_name = name[len(INFO_PREFIX):]
      rule_info = self.rule_doc_manager.get_rule_info_by_attr_name(info_name)
      
      if rule_info:
        self.info_popup.present(rule_info, close_label=words.schlieszen(c=rulesets.C_BOS))
        
      else:
        logger.error("cannot find info text for %s" % info_name)
        
    else:  
      super(MainViewController, self).handle_button_action(name, sender)
Exemplo n.º 2
0
 def update_sample_text(self):      
   """
   :type webview: ui.View
   """
   self.currentSampleText = sample_text.get_sample_text()
   webview = self.view['webview_text_view']
   if self.highlightingMode == HIGHLIGHT_DELTA:
     compareText = self.previousSampleText
   else:
     compareText = self.referenceSampleText
   html_content = util.get_html_content(compareText, self.currentSampleText, self.highlightingMode and not self.suppressShowChanges)
   
   webview.eval_js('document.getElementById("content").innerHTML = "%s"' % html_content)
   webview.set_needs_display()
   
   self.check_activate_hide_timer()
   self.update_views()
Exemplo n.º 3
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)  
Exemplo n.º 4
0
 def set_reference_mode(self, mode):
   self.referenceMode = mode
   tempStoreMode = rulesets.get_default_mode()
   rulesets.set_default_mode(self.referenceMode.combination)
   self.referenceSampleText = sample_text.get_sample_text()
   rulesets.set_default_mode(tempStoreMode)