topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday December 14, 2024, 9:46 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Is this a worthwhile idea for a program?  (Read 23934 times)

tranglos

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,081
    • View Profile
    • Donate to Member
Is this a worthwhile idea for a program?
« on: October 07, 2011, 02:12 PM »
(How does one create a poll?)

OK, I'm thinking out loud here, so please bear with me or ignore :) Here's a scenario I've had to contend with countless times. I'm translating a large document that contains innumerable specifications, such as power consumption, capacity, operating temperatures, dimensions, weight etc. So, lots of numbers. When translating between English and Polish it involves endless tweaking of punctuation. English "1.5" becomes "1,5" in Polish (decimal separator). English 12,000 becomes "12<non-breaking-space>000" in Polish (thousands separator). Then there are other little tweaks of spacing (we don't put a space before the degree ° sign, for example) and units of measure. You can imagine it gets tedious quickly. Today I've gone though well over a hundred of such lines.

This needs to be automated, and implemented in such a way that it works with any text editing application.  Plus, the solution needs to be abstracted enough to be generally useful.

For a long time I've looked for an excuse to write an app that executes user-created scripts. (At the moment there seems to be a dearth of Delphi scripting solutions that handle Unicode, so this might present a big obstacle, but right now I want to think positive for once :-) Would this be useful at all? Here's what I'm imagining:

1) You press a hotkey, and the as-yet-unnamed app acquires text from the application you are working in. This can be done via the clipboard or (better, harder) by accessing the text directly. So the app grabs the text and:

2) executes a script that you preselected when starting your work. In my case the script would do the appropriate replacements on the various numeric values, but it could do anything. Then:

3) the app puts the result back on clipboard or injects it directly into your editor.

Questions:

So, does this seem like a worthwhile standalone project? Assume the app does nothing else except the points above.

What existing solutions could be used to achieve the same goal? I suppose AHK could be coerced to do that. Anything else? Is it even remotely interesting?

(Yes, I've considered adding this to Echo, but I am not convinced it's a good idea. For one thing, Echo would be capturing the clipboard and modifying its contents nearly instantly, and that would play badly with other apps that monitor the clipboard. In general, I think it'd create a mess, but I haven't excluded that route just yet.)
« Last Edit: October 07, 2011, 02:44 PM by tranglos »

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,629
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #1 on: October 07, 2011, 02:19 PM »
Might I drop the suggestion 'regex replace' at just in front of your shoes? The source-capturing and result-presenting would be the next challenge ofcourse, but this is just a quicky suggestion ;)

tranglos

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,081
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #2 on: October 07, 2011, 02:24 PM »
Might I drop the suggestion 'regex replace' at just in front of your shoes? The source-capturing and result-presenting would be the next challenge ofcourse, but this is just a quicky suggestion ;)

A script can do anything, so it can certainly do regex replacement, as long as the scripting language (or its libraries) have support for regular expressions.

It would be another matter to ask for user input every time. Possible of course, but not as automated as I would like.

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #3 on: October 07, 2011, 02:40 PM »
I sure would use such a program  :-*

However, the Anglophile part of the world makes it difficult to simply make one rule. Many or even most Americans have erroneous learned to say and write "kgs" for kilograms. You and I are using "kg", because we know it never is plural; 1 gram, 2 gram. Are you ready to double the set of rules?

tranglos

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,081
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #4 on: October 07, 2011, 02:48 PM »
However, the Anglophile part of the world makes it difficult to simply make one rule. Many or even most Americans have erroneous learned to say and write "kgs" for kilograms. You and I are using "kg", because we know it never is plural; 1 gram, 2 gram. Are you ready to double the set of rules?

That goes in the script :)

All the program itself does is grab text, pass it on to the script, then put the changed text back. In the script you can do whatever. You are right of course, and then there are different rules for different languages - which is why for the application to be useful to anyone but me, it has to be script based. Then there is no limit to the transformation rules you can create.




MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #5 on: October 07, 2011, 02:50 PM »
You may be better off using a programmable editor like Vim. The mechanism is already debugged. You may be able to find scripts to do some or all of your substitutions. Windows ports of other Linux tools are available such as sed and nawk.

You could check out the available scripts. If you get stuck you could likely find forums of enthusiasts who tinker with scripts or know where to find more that may help you get over the hurdle.

Windows ports of bash shell are available if you need to pipe the output of one into the input of another. It sounds like the type of task that someone would have automated already.  At least partially.


Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #6 on: October 07, 2011, 03:03 PM »
(How does one create a poll?)

2011-10-07_220159.gif


tranglos

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,081
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #7 on: October 07, 2011, 03:17 PM »
(How does one create a poll?)
(see attachment in previous post)

Thanks, Curt!

tranglos

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,081
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #8 on: October 07, 2011, 03:21 PM »
You may be better off using a programmable editor like Vim.

I wish! :) I could do that in EmEditor or UltraEdit as well, seeing as they both come with JavaScript built in. Trouble is, for my specific needs, I work in a highly specialized "vertical" app called Trados (most translators know (of) it; most non-translators don't). Using it is a requirement, and it is actually a good thing, but it lacks certain features. Anyway, I don't have the liberty of using an editor of choice, hence the idea for a sidekick app.

superboyac

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,347
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #9 on: October 07, 2011, 03:38 PM »
I think it would be a great application, I would use it a lot.

It would be similar to TextMonkey except for being more open and flexible.  Textmonkey has predefined scripts and no ability to change them in any way.  But the rest of the functionality is there as far as reading a clip, processing it, and putting the new clip back in the clipboard.

It's sort of a super-charged find&replace program.  skwire's "list numberer" is also a very specialized version of something like that.  The key point to me is, how do you make something like that easy to use while being flexible enough to be generally appealing?  usually things like this are handled with regex, which nobody really knows how to use, nor would want to use without a gun placed to their head.

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #10 on: October 07, 2011, 03:48 PM »
Several utilities for modifying clipboard text (as opposed to saving clips) already exist.  Take a look at my post here in anandcoral's thread NANY 2012 Pledge & Early Beta: Paste Text Like.  In particular I'd recommend you look at Clippy, for two reasons.  One is that you can already set it up with multiple search-and-replace strings, though I doubt Unicode.  The other is for its streamlined operation.  You mark your text in the usual way, press the Clippy hotkey, then Ctrl-V, and your modified text is pasted back over the marked text.  I found simple and convenient.  You might find it interesting to compare Clippy with your current concepts.

Be aware that the Clippy Web site is often down.  It's a small program, and I've attached it to the referenced post.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #11 on: October 07, 2011, 03:56 PM »
cough cough..

My Clipboard Help+Spell program can do all of this already.

In addition to what you are asking for (running a user-written script, written in any scripting language; copying text before running script, pasting after it finished), it can also apply a large number of built in operations on text (trimming, adding line numbers, etc.) without using any script.

Plus it will allow you to list your saved transformation operations in a menu that you can trigger, or assign them to specific hotkeys for really quick work.

NOTE: Using scripts is an advanced feature in CHS, and not one heavily documented or used by many people.  But it was set up for exactly this kind of use.

[edit: i should say that because no one ever uses this feature it may be rough around the edges and not very tested.. so i probably need to do a little improvement on it if people actually plan to use it]

ps. CHS runs "scripts" in a very simple way but one that gives most flexibility.  It saves the input text to a temp file, invokes the specified script/executable and passes it temp input file path, desired output file path, and any other arguments.  When the launched script/executable finishes it grabs the output file and puts it back onto clipboard.
« Last Edit: October 07, 2011, 04:11 PM by mouser »

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #12 on: October 07, 2011, 04:04 PM »
mouser, is CHS Unicode, as tranglos requires?

cranioscopical

  • Friend of the Site
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,776
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #13 on: October 07, 2011, 04:09 PM »
no one ever uses this feature
But I use your built-in stuff umpteen times a day (and here I use "umpteen" in its pure form).

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #14 on: October 07, 2011, 04:09 PM »
Good point, CHS is *not* unicode.

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #15 on: October 07, 2011, 04:14 PM »
mouser, I think the scripting configuration might be buried too deep.  You have to pick an individual clip, then Modify Format/Case -> User tools -> Configure user tools in order to enter scripts.  It's certainly not obvious script-running possibilities exist from the main menu.  Should script configuration be an item on the main configuration menu instead?

superboyac

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 6,347
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #16 on: October 07, 2011, 04:23 PM »
mouser, I didn't even realize CHS could do this until maybe last week or so.  Guys, check it out, it's freaking awesome:
I0527_ 008.png

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #17 on: October 07, 2011, 04:34 PM »
mouser, I think the scripting configuration might be buried too deep.


actually i think that's being too kind.  it's pretty horrible and confusing the way it is now.

i think the solution is just to move it as just another option in the configuration dialog above, so you can combine it with any other configured built-in modifier you create, to run before or after the built-in transformations.

the real problem is simply that no one has shown much interest in the feature so i haven't bothered to improve it.

maybe what i can do is change that modification dialog to be a tree-based configuration like the main options are, which would give me a little more room to explain options, and then make it a page there.

anyway -- i don't want to take away from this thread, but i'd be happy to discuss it in the CHS forum section -- and i'd be happy to make some improvements to the script running feature if i can find someone who plans to use it.

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #18 on: October 07, 2011, 04:51 PM »
no one has shown much interest in the feature so i haven't bothered to improve it.
Maybe IainB hasn't discovered it yet  :D

i don't want to take away from this thread, but i'd be happy to discuss it in the CHS forum section
Is there any way to sort of transfer the CHS-related posts above to a new thread over there, preferably retaining a link to this as the origin?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #19 on: October 07, 2011, 05:01 PM »
yeah i'll split starting at your first post about chs scripting, and link back to this one.

40hz

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 11,859
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #20 on: October 07, 2011, 06:16 PM »
mouser, I didn't even realize CHS could do this

Wow! Me neither.

Guys, check it out, it's freaking awesome

Understatement. Bravo Mouser!

(I really have to stop blathering so much in the forum and start checking out DoCo's software section more carefully. There are some true gems to be found in there.  :-[ )


MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #21 on: October 07, 2011, 06:35 PM »
You may be better off using a programmable editor like Vim.

I wish! :) I could do that in EmEditor or UltraEdit as well, seeing as they both come with JavaScript built in. Trouble is, for my specific needs, I work in a highly specialized "vertical" app called Trados (most translators know (of) it; most non-translators don't). Using it is a requirement, and it is actually a good thing, but it lacks certain features. Anyway, I don't have the liberty of using an editor of choice, hence the idea for a sidekick app.


I don't get it. If you can clipboard stuff out, then paste it back in after transformations, you can paste it into a programmable editor and paste it back?  Maybe I have to be there to see the obstacle.

edit: Maybe that Text Editor Anywhere could bridge the gap between the specialized editor and one of your programmable ones?


« Last Edit: October 07, 2011, 06:47 PM by MilesAhead »

rjbull

  • Charter Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 3,205
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #22 on: October 08, 2011, 03:42 PM »
I don't get it. If you can clipboard stuff out, then paste it back in after transformations, you can paste it into a programmable editor and paste it back?  Maybe I have to be there to see the obstacle.
Think of it in terms of streamlined workflow.  As in my earlier post re.: Clippy, mark text, press Ctrl-C, press Clippy hotkey, press Ctrl-V, job done.  Fewer actions than doing the same job via an editor.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,914
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #23 on: October 08, 2011, 03:49 PM »
It's not that hard to see why this kind of operation can save a huge amount of time, compare the two workflows:

I have 10 paragraphs of text, for each one i need to perform some formatting on it (like line wrap to 70 columns).

Method 1: For each section of text (say 10 sections):
  • Select it with cursor
  • Hit hotkey assigned to formatter.

Method 2: For each section of text (say 10 sections):
  • Select it with cursor
  • Hit Ctrl+C to copy to clipboard
  • Find formatter tool window, click on it
  • Clear existing text in it (ctrl+A then delete)
  • Paste new clipboard text into it with Ctrl+V
  • Activate desired formatting with menu or button
  • Select it and Ctrl+C to copy new text to clipboard
  • Find previous window
  • Ctrl+V to paste the newly formatted text

Which would you rather do over and over?

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: Is this a worthwhile idea for a program?
« Reply #24 on: October 08, 2011, 04:06 PM »
Yes but what's the difference between a "formatting program" and an editor that has a script loaded sitting there waiting for the paste? For all purposes the editor is an interpreter running your "formatting program."

Set it as default in Text Editor Anywhere.  Select text, hit the hotkey. Hit Go to run the script in the editor.  What's the difference?