dictation-toolbox / Caster

Dragonfly-Based Voice Programming and Accessibility Toolkit
https://dictation-toolbox.github.io/Caster/
Other
340 stars 121 forks source link

Unable to dictate 5 consecutive numbers #857

Closed MarkRx closed 3 years ago

MarkRx commented 3 years ago

Describe the bug When using "numb" I am only able to dictate up to 4 numbers. The 5th one is always chopped off.

This might be an issue with how dragonfly deals with numbers.

To Reproduce Steps to reproduce the behavior (be sure to include the exact command phrase you are using):

  1. Say "numb one two three four five"
  2. Output is 1234

Expected behavior Output is 12345

System:

kendonB commented 3 years ago

@LexiconCode this is a limitation with the dragonfly class that @mrob95 created. I don't think we should address this one in caster, except to properly document the usage. @mrob95 is there potential to modify ShortIntegerRef in dragonfly to allow for longer single-digit utterances?

LexiconCode commented 3 years ago

Would be best to switch it to IntegerRef.

kendonB commented 3 years ago

IntegerRef is less general than ShortIntegerRef. ShortIntegerRef is IntegerRef (where you can say "one thousand two hundred and thirty four" with the added feature that you can say "one two three four" for numbers up to 9999

LexiconCode commented 3 years ago

The following parses free dictation to output a single number. Perhaps this can be used as replacement as it is at least as flexible if not more for Python 3.


import re

from text_to_num import text2num
from text_to_num import alpha2digit

def words_to_num(numdict):
    print("Raw:{} ".format(numdict)) 
    text_list = numdict.replace(r"\number", "").split() # Remove substring "\number" from DPI formatting
    transform_dict = {'one': '1', 'and': '', 'dot':'.', 'oh': 'zero', 'nintey': 'ninety'}
    try:
        #Simple: words to numbers `five hundred sixty three`
        numb = text2num(numdict, "en") 
        print("text2num:{} ".format(numdict)) 
    except ValueError:
        # Reduces complex dictation down to just numerics as a single number 
        for index, word in enumerate(text_list):
            if word in transform_dict.keys():
                text_list[index] = transform_dict[word]
        text = ' '.join(map(str, text_list))
        print("PreProcessed:{} ".format(text)) 
        numb =''.join(re.findall(r"[\d./\-\+]", alpha2digit(text, "en")))
    print("Final: {}".format(numb))
    #Text(str(numb)).execute()

words_to_num("One zero two three eight")
print(10238)

words_to_num("ten thousand two hundred thirty eight")
print(10238)

words_to_num("ten thousand two hundred and thirty eight")
print(10238)

words_to_num("ten two thirty eight")
print(10238)

words_to_num("one oh two thirty eight dot seven five")
print(10238.75)

words_to_num("one hundred two thirty eight point seventy five")
print(10238.75)

words_to_num("one million two hundred seven thousand eight hundred nintey")
print(1207890)
MarkRx commented 3 years ago

I can't tell because I don't have text_to_numlocally. Do these work?

One zero two three eight

10238

Ten thousand two hundred thirty eight

10238

Ten thousand two hundred and thirty eight

10238

Ten two thirty eight

10238

One oh two thirty eight dot seven five

10238.75

One hundred two thirty eight point seventy five

10238.75

One million two hundred seven thousand eight hundred nintey

1207890

LexiconCode commented 3 years ago

@MarkRx

1 zero two three eight
numb: 10238
10238
ten thousand two hundred thirty eight
text2num:10238 
10238
ten thousand two hundred  thirty eight
text2num:10238 
10238
ten two thirty eight
numb: 10238
10238
1 zero two thirty eight . seven five
numb: 10238.75
10238.75
1 hundred two thirty eight point seventy five
numb: 110238.75
10238.75
1 million two hundred seven thousand eight hundred ninety
numb: 1207890
1207890

The edge cases have been worked out above. It could allow for operators as well.

ten thousand + two hundred thirty eight
numb: 10000+238

However there are still two edge cases.

Extraneous my cat

1 million two my cat hundred seven thousand eight hundred ninety
alpha2digit: 1 million 2 my cat 107890
numb: 12107890
1207890
LexiconCode commented 3 years ago

@MarkRx @kendonB I have a fix for this in https://github.com/dictation-toolbox/Caster/pull/878 utilizing Dragon's native ShortIntegerRef which allows for greater flexibility than IntegerRef.

LexiconCode commented 3 years ago

Should be fixed, reopen if there's issues.

BawdyInkSlinger commented 1 year ago

The following parses free dictation to output a single number. Perhaps this can be used as replacement as it is at least as flexible if not more for Python 3...

Should be fixed, reopen if there's issues.

Is this only fixed if you use Python 3? I'm using Python 2 and I can still reproduce the issue. The following line is what prints if I say numb 1 2 3 4 5 6 7 8 9:

1234seven eight nine

The caster status window prints:

Numbers: [] numb , , 1234 Navigation: ( | | ) [(bow|bowel)] [brunt], 6, 0, 6, 0, seven eight

Additional information:

Python 2.7.18 Running DNS/DPI from Dragonfly CLI with Natlink. DPI version 15 My version.py file says __version__ = "1.7.0"