dictation-toolbox / dragonfly-scripts

Dragonfly scripts for Dragon NaturallySpeaking
87 stars 30 forks source link

Format functions that can take SCText #7

Closed nirvdrum closed 10 years ago

nirvdrum commented 10 years ago

I found myself wanting to write rules that use the Function action. But because special characters end up being treated oddly by Dragon (e.g., '.' -> '\dot') I'd like to use the custom SCText class. However all of the format functions are hard-coded to use the Text class directly. Perhaps the formatting functions can be augmented to take an optional tax class that be passed from the Function call as extra keywords.

nirvdrum commented 10 years ago

Actually, is there any harm in always using SCText here? Given the primary use case is programming it seems that may be a sane default.

poppe1219 commented 10 years ago

I completely agree, it should be the default.

poppe1219 commented 10 years ago

I thought it would be a slamdunk to just switch the Text class with the SCText class. Unfortunately, it requires little more work. I created a feature branch, feature/format_sctext, that contains a test with the SCText class. I will get back to this issue later, as I have a few other things that are more pressing.

poppe1219 commented 10 years ago

I managed to get the special characters text working for the format methods that take a dictation text as a parameter. The question now is how the camel case and snake case should act around special characters. For instance, should camel case restart with a lowercase after a special character? Right now it keeps capitalizing each word: "someCamel-Text". And snake case wraps the special characters in underscores: "somesnake-_text".

nirvdrum commented 10 years ago

Fantastic news. I tried swapping them out and quickly hit problems with anything that didn't match your predefined patterns. E.g., anything I added to the vocabulary through Dragon proper. I'll have to try this out.

I guess for special characters like '-', maybe remove them? Is that the only case?

poppe1219 commented 10 years ago

I think you will have to elaborate. I don't quite understand what you mean. Can you give an example that doesn't match the predefined patterns? What do you mean by removing special characters like '-'?

nirvdrum commented 10 years ago

Sure. I do a lot with Amazon Web Services, so I added "CloudFront" to my vocabulary, telling Dragon that it sounds like "cloud front." When passed into SCText, it looks something like CloudFront\\Cloud Front (I'm going from memory -- I'll have to check the exact text for you later).

poppe1219 commented 10 years ago

Interesting. I didn't realize that every word from the vocabulary that differs in written form and spoken form behaves like this. It should be possible to come up with a method that can filter this out, and use that instead of a predefined list of patterns. That should be a much better, more generic solution.

poppe1219 commented 10 years ago

I just pushed a new version of the formatting methods. This time it is a more generic method, that should sort out most special characters and custom words from the vocabulary. There are probably a few special cases that are not handled yet. Backslash is one example of a special case.

nirvdrum commented 10 years ago

So far this has been working out great for me. Thank you for taking care of it.

poppe1219 commented 10 years ago

Great! I'm closing the issue. If you find any bugs, just report them as separate issues.