talonhub / community

Voice command set for Talon, community-supported.
MIT License
621 stars 770 forks source link

Words that should be merged into one are separated by spaces #268

Closed JSenecal2 closed 3 years ago

JSenecal2 commented 3 years ago

This may not be a problem for those not using Dragon, but I’ve noticed that when dictating text, sometimes spaces are inserted between words that should be combined. The specific cases are prefixes ending with “-” such as “non-“, adding a possessive “‘s” (which Dragon often recognizes as a separate word), and suffixes such as “.com”.

This was easy enough to fix by making changes in format_phrase_no_history in formatters.py. I thought I would share my change in case anyone else is having that problem. Note that my fix is only intended for formatted text (including say). When I tried this with dictation mode, it already handles merging words with hyphens and quotes.

def format_phrase_no_history(word_list, fmtrs: str):
    fmtr_list = fmtrs.split(",")
    phrase = ""
    spaces = True
    for i, w in enumerate(word_list):
        for name in reversed(fmtr_list):
            smash, func = all_formatters[name]
            w = func(i, w, i == len(word_list) - 1)
            spaces = spaces and not smash
        if i > 0 and spaces and not phrase.endswith('-') and not w.startswith("'") and not w.startswith('.'):
            phrase += ' '
        phrase += w
    return phrase
knausj85 commented 3 years ago

Thanks!