![]() |
KnowBrainer Speech Recognition | ![]() |
Topic Title: Command to consolidate spaces Topic Summary: Created On: 04/08/2022 01:26 PM Status: Post and Reply |
|
![]() |
![]() |
- wristofdoom | - 04/08/2022 01:26 PM |
![]() |
![]() |
- ax | - 04/08/2022 02:33 PM |
![]() |
![]() |
- R. Wilke | - 04/08/2022 04:17 PM |
![]() |
![]() |
- dilligence | - 04/10/2022 09:28 AM |
![]() |
![]() |
- wristofdoom | - 04/11/2022 05:36 PM |
![]() |
![]() |
- Edgar | - 04/10/2022 10:24 AM |
![]() |
![]() |
- ax | - 04/11/2022 07:21 PM |
![]() |
![]() |
- R. Wilke | - 04/12/2022 01:11 PM |
![]() |
![]() |
- PG LTU | - 04/12/2022 12:34 PM |
![]() |
![]() |
- ax | - 04/12/2022 08:16 PM |
![]() |
![]() |
- Lunis Orcutt | - 04/13/2022 11:48 AM |
![]() |
![]() |
- PG LTU | - 04/13/2022 04:46 PM |
![]() |
![]() |
- Matt_Chambers | - 04/13/2022 05:49 PM |
![]() |
![]() |
- R. Wilke | - 04/13/2022 08:06 PM |
![]() |
|
I have a command called "consolidate that" that I use to get rid of extra spaces and linebreaks that are in the current selected text.
For example, if I had "this example text", I can select the text, under the command "consolidate that", and then the text becomes "this example text"
My current script:
The script that I have works but it is not very smart. Right now, I just search for instances of 4 back to back spaces, 3 spaces, 2 spaces, and consolidate all of that into a single space.
This works for almost all may use cases, but it won't work if I ever have a block of text with a lot of spaces.
What I want to do is replace all instances of Space(x) where X = any number > 1, but I don't know how to express that in Visual Basic.
Any tips?
------------------------- Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017. |
|
|
|
![]() |
|
I suppose you could use a loop of some sort, looping around to check to see if you have gotten rid of any 2-space blocks, recursively. Clipboard := RegExReplace(Clipboard, "([[:blank:]]+)([,;:.!?')/])", "$2") ;Remove any space between words and punctuations. Above are just 3 out a multi-line "post-processing" script I use to "clean up" paragraphs - in non-Select-And-Say situations. Second and third lines can be combined. But leaving them separate is more flexible and easier to maintain. Anyhow, just to give an idea.
Or here:
https://www.vbforums.com/showthread.php?830065-RESOLVED-Remove-All-Whitespace |
|
|
|
![]() |
|
Now that you are mentioning it, I love sudoku, and this is what I always do whenever I take a break from my day job as a loss adjuster. While having a cigarette. As regards handling white spaces programmatically, using regular expressions may be the first thing springing to mind, but your options will always be limited which you will realise sooner or later. The ultimate way to go is using CFG parsing, but that would be even more above the head of the original poster than regular expressions. ------------------------- The New Game in Town: DragonConnect |
|
|
|
![]() |
|
The ultimate way to go is using CFG parsing, but that would be even more above the head of the original poster than regular expressions.
I don't like sudoku and I don't smoke (anymore), but I do like to respond to original forum posters in a decent manner, trying to offer something that is useful.
wristofdoom may be interested in the "Remove Unnecessary Spaces" feature in SP 7 Standard's Zen Editor© and DB Advanced©). This removes any number of spaces > 1. ------------------------- Turbocharge your Dragon productivity with 40+ Power Addons |
|
|
|
![]() |
|
I use regex regularly and for my needs it's usually not too far above or below the level of my head. However, I haven't seen a VBA script using regex in the context of a Dragon script.
An example would be helpful. ------------------------- Dragon Professional Individual v15.6. Windows 10. Knowbrainer 2017. |
|
|
|
![]() |
|
Don't forget, white space can include tabs. Sometimes the combination of spaces and tabs together needs to be consolidated. Generally, multiple back-to-back tabs are intentional. Something that looks like: "space tab" or "tab space" typically wants to be reduced to just "tab". Something like "tab space space tab" might best look as "tab tab". There are no hard and fast rules here. This problem really requires multiple solutions.
------------------------- -Edgar |
|
|
|
![]() |
|
I use regex regularly and for my needs it's usually not too far above or below the level of my head. However, I haven't seen a VBA script using regex in the context of a Dragon script. An example would be helpful.
Indeed regex is not necessarily difficult, just generally "unpleasant", at least to me. Apparently you will need to use your Knowbrainer to pull it off in Dragon scripting indirectly. |
|
|
|
![]() |
|
We do that
Indeed regex is not necessarily difficult, just generally "unpleasant", at least to me. Apparently you will need to use your Knowbrainer to pull it off in Dragon scripting indirectly. https://www.knowbrainer.com/forums/forum/messageview.cfm?catid=12&threadid=32938& https://www.knowbrainer.com/forums/forum/messageview.cfm?catid=12&threadid=33051& AX, It is very kind of you to jump in and try to help out anyone getting lost in confusion in this place, which admittedly happens ever so often, but in the case of "wrist of doom", he only appears to be like the kid posting on programmers forums asking questions such as "hey, I need to get my homework done by tomorrow, anyone give me the code?" And for sure, in places such as "stackoverflow", my initial response to him would have been judged as quite politely rather. (As opposed to what the less than up to the task competitor from the Netherlands tried harping on.) Anyway, anyone should get happy with using regular expressions as long as they can to sort it out, would be my advice. ------------------------- The New Game in Town: DragonConnect |
|
|
|
![]() |
|
Everything you need to know is right here in the forum, real easy. -------------------------
|
|
|
|
![]() |
|
^^^ Let 's not sell ourselves short, RW! I don't think any regular to this forum would seriously dispute that next to Lunis, who may be said to have a "proprietor's" interest in answering questions, you have helped more folks on this forum, cumulatively over the years and counting, than several others combined.
|
|
|
|
![]() |
|
This forum could use some serious upgrading. We chose this particular forum because it was used at Dell, permitted embedded hyperlinks and was the most expensive forum on earth. In other words, we were hedging our bets but we lost. The manufacturer of this forum went out of business well over a decade ago so we can no longer edit or add amenities; like the ability to scroll left and right ------------------------- Change "No" to "Know" w/KnowBrainer 2022 |
|
|
|
![]() |
|
Getting back to the original @wristofdoom post, no need to purchase any "Remove Unnecessary Spaces" product, using my function from the post I linked above, a simple two line command suffices to consolidate any amount of white space (including tabs and blank characters) in a highlighted selection (which can span paragraphs, ymmv):
[[Edited: Removed potentially inflammatory remark (though I'm not sure why it created such offense). I only provide the full detail (beyond my earlier proof-of-concept, which I linked to above) because the earlier answers here are either for a commercial product (not Lunis' KnowBrainer, Lunis never shys away from providing the actual code from his product that can show a poster how to do something), as well as the suggestions that RegEx might be too complicated for Dragon users, which I hope to have dispelled. After all, wristofdoom admitted regex wasn't beyond his or her or their ability so I'm sure the P-O-C was already enough, nonetheless, for others who stumble upon this post who think their only hope is to buy something, well, here it is for free and spoon-fed.]] -------------------------
|
|
|
|
![]() |
|
Excellent Tom Perry reference! That is all. |
|
|
|
![]() |
|
That is all.
As far as programming, the best teachers I have met on the Internet are those who don't give their wisdom away so easily, but instead, put up some barrier which you will have to climb first before getting the knack of it, and realise the value in getting the concept yourself. PG, as an example, sometimes meets this criteria, although not always. For everything else, there will always be the documentation, and thanks to the Internet, Google will always be your friend, but kids who grew up with everything being readily available right away probably don't know what to do with it. At any event, you will never learn anything from just copying snippets of code without understanding the basics of the underlying structure, and everyone is wasting their time in this game, those who ask question after question, and those who answer. ------------------------- The New Game in Town: DragonConnect |
|
|
FuseTalk Standard Edition v4.0 - © 1999-2023 FuseTalk™ Inc. All rights reserved.