View Single Post
Old 08-14-2014, 12:54 PM   #15
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
In fact, just for giggles, since the function mode is actually arbitrarily powerful, you could do this:

Code:
from calibre.gui2.tweak_book import dictionaries

def replace(match, context):
    word = match.group()
    if not dictionaries.recognized(word):
         word = word.upper()
    return word
Which even gets rid of the need to define your own list of common words, it will use the dictionary for whatever language is specified in the books opf file (provided of course you have installed such a dictionary).
kovidgoyal is offline   Reply With Quote