Ticket #43: repeated_chars.patch

File repeated_chars.patch, 1.4 KB (added by jteh, 4 years ago)

Proof of concept implementation.

  • source/speech.py

    === modified file 'source/speech.py'
     
    6262def terminate(): 
    6363        setSynth(None) 
    6464 
     65RE_REPEATED_CHARS = re.compile(r"(([\W_])\2{3,})") 
     66def _replaceRepeatedChars(m): 
     67        return _("%s %d times ") % (m.group(2), len(m.group(1))) 
     68 
    6569def processTextSymbols(text,expandPunctuation=False): 
    6670        if (text is None) or (len(text)==0) or (isinstance(text,basestring) and (set(text)<=set(characterSymbols.blankList))): 
    6771                return _("blank")  
    6872        #Convert non-breaking spaces to spaces 
    6973        if isinstance(text,basestring): 
    7074                text=text.replace(u'\xa0',u' ') 
     75        text = RE_REPEATED_CHARS.sub(_replaceRepeatedChars, text) 
    7176        text = userDictHandler.processText(text) 
    7277        #expands ^ and ~ so they can be used as protector symbols 
    7378        #Expands special sentence punctuation keeping the origional physical symbol but protected by ^ and ~ 
  • source/userdicts/default.dic

    === modified file 'source/userdicts/default.dic'
     
    11#General NVDA dictionary 
    22#syntax: record fields divided by tab character 
    33 
    4 #Limit groups of the same character to 5 or less. 
    5 ([\W])\1{5,}    \1\1\1\1\1 
    64#break up words that use a capital letter to denote another word 
    75([a-z])([A-Z])  \1 \2 
    86#Break away a word starting with a capital from a fully uppercase word