View Single Post
Old 12-19-2024, 12:09 PM   #69
maxthegold
Member
maxthegold began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Mar 2011
Location: Weston-super-Mare, U.K.
Device: Kobo Libra 2
Rather than repeat all the words in the lookup file I have added some code to the search and replace. After the find and replace and incrementing of counts I put the following,
Code:
       # Do it again for capitalised words    
        m, n = regex.subn(rgx.format(key.capitalize()), new_name.capitalize(), m)
        if do_count and n:
            data['total'] += n
            data['counters'][key] = data['counters'].get(key) + n
This will add the count for the capitalised word to the count for the non capitalised word.

Other than that, thank-you lomkiri for a splendid piece of coding that does exactly what I was looking to do.

Last edited by maxthegold; 12-19-2024 at 12:14 PM.
maxthegold is offline   Reply With Quote