![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Java Programming using CamelCase Topic Summary: Advanced Scripting that Mimics "Cap That" Created On: 07/17/2012 02:06 PM Status: Post and Reply |
|
![]() |
![]() |
- Heather92115 | - 07/17/2012 02:06 PM |
![]() |
![]() |
- Lunis Orcutt | - 07/17/2012 03:19 PM |
![]() |
![]() |
- Heather92115 | - 07/17/2012 03:48 PM |
![]() |
![]() |
- rob | - 04/20/2017 10:13 AM |
![]() |
![]() |
- Edgar | - 04/20/2017 10:48 AM |
![]() |
![]() |
- Edgar | - 04/20/2017 10:49 AM |
![]() |
![]() |
- rob | - 04/20/2017 02:46 PM |
![]() |
![]() |
- Edgar | - 04/20/2017 03:15 PM |
![]() |
![]() |
- FranckDernoncourt | - 06/05/2017 10:01 PM |
![]() |
![]() |
- Alan Cantor | - 06/06/2017 11:54 AM |
![]() |
![]() |
- Lunis Orcutt | - 04/20/2017 11:53 AM |
![]() |
![]() |
- Eric_Bain | - 04/21/2017 09:04 PM |
![]() |
![]() |
- MDH | - 04/21/2017 09:13 PM |
![]() |
![]() |
- Alan Cantor | - 04/21/2017 10:13 PM |
![]() |
![]() |
- MDH | - 04/22/2017 09:37 AM |
![]() |
![]() |
- R. Wilke | - 07/17/2012 05:54 PM |
![]() |
![]() |
- Heather92115 | - 07/17/2012 07:08 PM |
![]() |
![]() |
- R. Wilke | - 07/17/2012 07:37 PM |
![]() |
![]() |
- rob | - 04/20/2017 04:57 PM |
![]() |
![]() |
- Edgar | - 04/20/2017 06:54 PM |
![]() |
![]() |
- Alan Cantor | - 06/05/2017 11:24 PM |
![]() |
![]() |
- FranckDernoncourt | - 06/05/2017 11:34 PM |
![]() |
![]() |
- Lunis Orcutt | - 06/06/2017 01:47 PM |
![]() |
![]() |
- FranckDernoncourt | - 06/06/2017 07:34 PM |
![]() |
![]() |
- Lunis Orcutt | - 06/06/2017 08:02 PM |
![]() |
![]() |
- FranckDernoncourt | - 06/06/2017 08:06 PM |
![]() |
![]() |
- Lunis Orcutt | - 06/06/2017 08:55 PM |
![]() |
![]() |
- Alan Cantor | - 06/07/2017 09:43 AM |
![]() |
![]() |
- kkkwj | - 02/03/2021 02:49 PM |
![]() |
![]() |
- Edgar | - 02/03/2021 03:46 PM |
![]() |
![]() |
- kkkwj | - 02/03/2021 05:48 PM |
![]() |
|
Try
Optionally, if you would like to apply the previous formatting to the last spoken phrase (as opposed to having to select the text before deploying your command) simply change your code to
------------------------- Forum Mission Statement |
|
|
|
![]() |
|
Thanks for your help, it works like a charm. I would also like to create is slightly different script based on this one. In Java programming variable names and method names are in Camel case but start without capitalization.
For instance: "my method name" would be changed to "myMethodName" Is there also an easy way to do this? Thanks, Heather ------------------------- Heather |
|
|
|
![]() |
|
Hi Everyone,
Would someone be able to tell me how to do this the methods above compounded the text but did not add any capitalisation?
This is the format I am looking for myMethodName
I'm starting a coding course soon and it would be very helpful to know this because I am paralysed and it speeds up my coding compared to on screen keyword.
Thanks,
Rob ------------------------- Dragon Professional Group 15.6 with knowbrainer 2017 professional and speech start. |
|
|
|
![]() |
|
Try this one out; it CamelCases the previous <1to10> words: CamelCase <1to10> Sub Main Dim camelVariable, dictate, firstCharacter As String Dim wasSpace, isLower, trailingSpace As Boolean Dim dictationLength As Integer For increment = 1 To Val (ListVar1) SendKeys "+^{Left}", 1 Next increment Wait 0.2 SendKeys "^c", 1 Wait 0.3 dictate = Clipboard Wait 0.3 dictationLength = Len (dictate) If Mid (dictate, dictationLength, 1) = " " Then trailingSpace = True 'Dim testing As String 'testing = "#" + Mid (dictate, 1, dictationLength) + "#" 'MsgBox testing dictate = Trim (dictate) firstCharacter = Mid (dictate, 1, 1) firstCharacter = LCase (firstCharacter) camelVariable = firstCharacter dictationLength = Len (dictate) If dictationLength > 1 Then For increment = 2 To dictationLength firstCharacter = Mid (dictate, increment, 1) If firstCharacter = " " Then wasSpace = True Else If wasSpace = True Then firstCharacter = UCase (firstCharacter) camelVariable = camelVariable + firstCharacter wasSpace = False End If Next increment End If If leadingSpace = True Then camelVariable = " " + camelVariable If trailingSpace = True Then camelVariable = camelVariable + " " SendKeys camelVariable End Sub ------------------------- -Edgar |
|
|
|
![]() |
|
Here's another version: CamelCase <dictation> Sub Main Dim camelVariable, dictate, firstCharacter As String Dim wasSpace, isLower As Boolean Dim dictationLength As Integer dictate = ListVar1 dictate = Trim (dictate)' probably unnecessary firstCharacter = Mid (dictate, 1, 1) firstCharacter = LCase (firstCharacter) camelVariable = firstCharacter dictationLength = Len (dictate) If dictationLength > 1 Then For increment = 2 To dictationLength firstCharacter = Mid (dictate, increment, 1) If firstCharacter = " " Then wasSpace = True Else If wasSpace = True Then firstCharacter = UCase (firstCharacter) camelVariable = camelVariable + firstCharacter wasSpace = False End If Next increment End If SendKeys " " + camelVariable + " " End Sub ------------------------- -Edgar |
|
|
|
![]() |
|
CamelCase
Sub Main
Dim camelVariable, dictate, firstCharacter As String
Dim wasSpace, isLower As Boolean
Dim dictationLength As Integer
dictate = ListVar1
dictate = Trim (dictate)' probably unnecessary
firstCharacter = Mid (dictate, 1, 1)
firstCharacter = LCase (firstCharacter)
camelVariable = firstCharacter
dictationLength = Len (dictate)
If dictationLength > 1 Then
For increment = 2 To dictationLength
firstCharacter = Mid (dictate, increment, 1)
If firstCharacter = " " Then
wasSpace = True
Else
If wasSpace = True Then firstCharacter = UCase (firstCharacter)
camelVariable = camelVariable + firstCharacter
wasSpace = False
End If
Next increment
End If
SendKeys " " + camelVariable + " "
End Sub
Hi Edgar,
Lunis, ah I see that works for pascal case now!
Thanks,
Rob ------------------------- Dragon Professional Group 15.6 with knowbrainer 2017 professional and speech start. |
|
|
|
![]() |
|
That was a new one on me - had to look it up! Try changing this line (about line # 20): If wasSpace = True Then firstCharacter = UCase (firstCharacter) so it looks like this: If wasSpace = True Then firstCharacter = "_" + UCase (firstCharacter) to get: first_Second_Third or: If wasSpace = True Then firstCharacter = "_" + LCase (firstCharacter)to get:first_second_thirdgetting:First_second_thirdis left as an excersize for the interested <grin>. ------------------------- -Edgar |
|
|
|
![]() |
|
CamelCase
Sub Main
Dim camelVariable, dictate, firstCharacter As String
Dim wasSpace, isLower As Boolean
Dim dictationLength As Integer
dictate = ListVar1
dictate = Trim (dictate)' probably unnecessary
firstCharacter = Mid (dictate, 1, 1)
firstCharacter = LCase (firstCharacter)
camelVariable = firstCharacter
dictationLength = Len (dictate)
If dictationLength > 1 Then
For increment = 2 To dictationLength
firstCharacter = Mid (dictate, increment, 1)
If firstCharacter = " " Then
wasSpace = True
Else
If wasSpace = True Then firstCharacter = UCase (firstCharacter)
camelVariable = camelVariable + firstCharacter
wasSpace = False
End If
Next increment
End If
SendKeys " " + camelVariable + " "
End Sub
In that version, how should the <dictation> list be defined? ![]()
|
|
|
|
![]() |
|
I believe Nuance introduced the <dictation> variable in Version 13.
|
|
|
|
![]() |
|
The reason why the previous answers no longer work is because the previous command examples were contributed for a much older version of Dragon; probably Dragon 11. Because you have rejuvenated this thread, we have edited Rüdiger's and Lunis's answers. We changed HeardWord "\Cap","that" to HeardWord "\cap","that" which should do what you are looking. Keep in mind that you can't always rely on old answers. Dragon developers often change rules for possibly good reasons that elude us. ------------------------- Forum Mission Statement |
|
|
|
![]() |
|
Hi, I'm new to the forum but I've written advanced scripts and VB commands. I could never get a "Cap" "That" or "No" "Cap "That" HeardWord working, I guess because I was not using the backslash before the Cap. Why do you have to do that? Are there other commands for which you need the \? I'm using Dragon Medical 10.2, so I guess I would use HeardWord "\Cap","that"? thanks, Eric
|
|
|
|
![]() |
|
If you dictate a word, and just after want it capitalized, just say :Cap That. If you want something capped beforehand, you can just say : Cap. Or, use: HeardWord "\Cap" MDH ------------------------- |
|
|
|
![]() |
|
Hi, I'm new to the forum but I've written advanced scripts and VB commands. I could never get a "Cap" "That" or "No" "Cap "That" HeardWord working, I guess because I was not using the backslash before the Cap. Why do you have to do that? Are there other commands for which you need the \?
The rules for using backslashes and capitalization in formatting "commands" changes version to version.
Prior to Version 11, "new line", "cap", and "no caps" were capitalized. Now they are not.
My recolleciton is that fewer formatting commands today use backslashes than in older versions. But "\cap" (or is it "\Cap"?) remains.
Some formatting commands use hyphens, e.g., HeardWord "No-Space" (or is it "no-space"?) |
|
|
|
![]() |
|
Alan, You are correct, but just coincidentally, I use the very same Dragon version that she does, and this is how it happens to work in this paticular scenario. MDH ------------------------- |
|
|
|
![]() |
|
Try it like this: HeardWord "select","back","two","words" HeardWord "\cap","that" HeardWord "select","back","three","words" HeardWord "compound","that" SendKeys "{Right)" Rüdiger -------------------------
|
|
|
|
![]() |
|
I think I finally solved my own problem. I googled around enough to read learn Visual Basic programming after not programming in BASIC for 20 years.
Option Explicit Sub Main Dim engCtrl As New DgnEngineControl Dim Text As String Dim VarText As String HeardWord "cut","that" Text = Clipboard SendDragonKeys "" & CamelCase(Text) End Sub Public Function CamelCase(strInput As String) As String Dim i As Integer Dim sMid As String Dim foundSpace As Boolean For i = 1 To Len(strInput) sMid = Mid(strInput, i, 1) Select Case Asc(sMid) Case 32: foundSpace = True Case 65 To 90: If i = 1 Then CamelCase = CamelCase + LCase(sMid) Else CamelCase = CamelCase + sMid End If foundSpace = False Case 97 To 122: If foundSpace Then CamelCase = CamelCase + UCase(sMid) Else CamelCase = CamelCase + sMid End If foundSpace = False Case Else: CamelCase = CamelCase + sMid foundSpace = False End Select Next i End Function ------------------------- Heather |
|
|
|
![]() |
|
If we had been aware that you are open to Visual Basic... -------------------------
|
|
|
|
![]() |
|
Hi, ------------------------- Dragon Professional Group 15.6 with knowbrainer 2017 professional and speech start. |
|
|
|
![]() |
|
Gold star <grin>! ------------------------- -Edgar |
|
|
|
![]() |
|
The variable is pre-defined. You don't need to anything more. Just click OK and continue.
The variable takes on the value of any combination of words in the Vocabulary, e.g., "Camelcase The variable takes on" will change the first four words in this paragraph to camel case. |
|
|
|
![]() |
|
Thanks. Is it supposed to work in Dragon NaturallySpeaking 12.5 Professional, or did this feature appear in more recent versions?
If it is supposed to work in Dragon NaturallySpeaking 12.5 Professional, which is the version I use, I have the following issue. When I create a new voice command and enter the command name "CamelCase <dictation>", Dragon automatically opens the window:
What am I supposed to do in this window? If I click on `cancel` then the command name is changed to `CamelCase dictation`. |
|
|
|
![]() |
|
Alan nailed it. Far Field algorithms (auto gain control) and open-ended vocabulary command capability (pseudo-artificial intelligence) wasn't introduced until professional versions of Dragon 13 release. Deep Learning was added to DPI 15. KnowBrainer 2017 includes 267 of these open ended artificial intelligence commands. This is just the beginning of the list of features you are missing out on when you don't upgrade to DPI 15 ------------------------- Forum Mission Statement |
|
|
|
![]() |
|
Thanks. Is there any exhaustive change log for Dragon? I'm especially interested in change log for advanced scripting. |
|
|
|
![]() |
|
Sorry but we don't know what you mean by “change log for Advanced-Scripting”. Can you include some additional details? ------------------------- Forum Mission Statement |
|
|
|
![]() |
|
I mean the list of additions, changes and deletions between each version of Dragon NaturalSpeaking Professional / Dragon Professional Individual.
For example, between Dragon NaturallySpeaking 12.5 Professional and Dragon NaturallySpeaking 13 Professional, the variable was added.
Example of changelog: https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md |
|
|
|
![]() |
|
Nuance rarely removes a feature because they are big fans of backward compatibility. About the only features we have seen removed are information features that might cause Dragon end-users to ask questions. Since Nuance technical support phone calls cost Nuance $$$, they try to keep it to a minimum. For example, when running the Audio Check in Ver. 12, you could see a blue bar that would not only let you know that your volume level was acceptable but would even show you what your ideal volume level would be. In Ver. 11, you could even see a numerical grade but these features often generated Nuance support questions so while these features were interesting, Nuance decided to eliminate them. ------------------------- Forum Mission Statement |
|
|
|
![]() |
|
The addition of the <dictation> variable aside, the last major change in the scripting language was around Version 9, maybe 10, when Nuance changed the value of the wait state. It used to be expressed in milliseconds; now it's in seconds.
Nuance's tweaks to the Vocabulary Editor from version to version affect HeardWord statements. A change log would be nice to keep track of which version supports capital letters, backslashes at the start of certain words (e.g., \cap), punctuation marks, digits in command names, etc. When I don't know, I use trial and error experimentation, and turn to this forum as needed! |
|
|
|
![]() |
|
I modified one of Edgar's camel case scripts above to issue an Enter key after the camel case. This makes the script useful for data entry in databases and spreadsheets where you automatically want to move to the next cell down.
' my script is called "camel up enter SendKeys " " + camelVariable + " " ' with SendKeys camelVariable + "{Enter}" It works very well for me. Thanks Edgar! :-) PS. I also made "camel down" and "camel down enter" versions, for camelNames that startWithLowerCaseLetters. My "camel up" scripts ProduceNames that StartWithUpperCaseLetters. ------------------------- Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse |
|
|
|
![]() |
|
For the "camel up" solution I call that "class case" <grin>! I also have "member case": mAClassMemberVariable, "global case": gAGlobalVariable and a few others. I only use this stuff in coding so don't need the versions for database entry. ------------------------- -Edgar |
|
|
|
![]() |
|
Ah, interesting - what a "classy" solution. :-) Being of simple mind, I just figured I needed one for an uppercase and one for a lowercase leading letter. But if you tag the front with m, g, _, or some other symbol, different names are appropriate. (Didn't they used to call that Hungarian notation?) You're definitely much more advanced than I am when it comes to generating code by voice. I am pitiful at it for now. Maybe one day I'll get there, who knows.
------------------------- Win10/x64, AMD Ryzen 7 3700X, 64GB RAM, Dragon 15.3, SP 6 PRO, SpeechStart, Office 365, KB 2017, Dragon Capture, Samson Meteor USB Desk Mic, Klim and JUKSTG earbuds with microphones, 3 BenQ 2560x1440 monitors, Microsoft Sculpt Keyboard and fat mouse |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.