View Single Post
Old 08-18-2025, 04:45 PM   #5
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 169
Karma: 1497966
Join Date: Jul 2021
Device: N/A
Quote:
Originally Posted by Phssthpok View Post
Hmm, having done this I realise that what I really need is a way to *find* things which are not in the dictionary, not all hyphenated words.
Try to replace the sub-function replace_word() that is inside the code of the example by this one, that does a replace when the compound word is NOT is the dict:
Code:
    def replace_word(wmatch):
        # if word1-word2 is not is not recognized by the dictionary, replace dash by em-dash
        with_em_dash = wmatch.group(1) + "—" + wmatch.group(2)
        if not dictionaries.recognized(wmatch.group()):
            return with_em_dash
        return wmatch.group()
lomkiri is offline   Reply With Quote