Reply to topic  [ 4 posts ] 
Macro for linguists: CAPS to Small Glosses 
Author Message

Joined: 2008-05-27 08:39:25
Posts: 8
The macro below takes two or more CAPS + [MFN] followed by Punctuation ans transforms them to Small Caps.
This is an easy way to transform easy, rtf GLOSSES to fancy layout glosses.

It's rather simple, but should be helpful enough.
I hope that'll save some time for someone else, too.

Quote:
Find All '[A-Z]{2,}', 'E-i'
Menu "To lowercase"
Menu "Display as Small Caps"

Find All '[MFN][-:.) ]', 'E-i'
Menu "To lowercase"
Menu "Display as Small Caps"


Okay, remembering Kino's help in May would have saved even more time. Back then, I just took the commands and forgot about the macro:
http://www.nisus.com/forum/viewtopic.php?f=18&t=3027
:oops:

thyx


2008-10-16 12:44:13
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
As I'm not a linguist, I may misunderstand the purpose of your macro but you can combine the two Find All commands using | (OR operator).
Code:
Find All '[A-Z]{2,}|[MFN][-:.) ]', 'E-i'
And if you want to apply To lowercase and Display as Small Caps on [MFN] but not on the following [-:.) ], you can use [MFN](?=[-:.) ]) instead of [MFN][-:.) ]. (?=expression) is Look-Ahead you can insert from the action menu (gear) of the Find panel.

Also, perhaps it would be safer to check if those strings have been actually found and selected. It would not be very likely to occur but [1] if there is a selection before running the macro and [2] if nothing matching the find expression has been found, To lowercase and Display as Small Caps will be applied on the original selection. You can prevent it by checking the value returned by Find All command in the following way.
Code:
$numFound = Find All '[A-Z]{2,}|[MFN](?=[-:.) ])', 'E-i'
if $numFound > 0  # Just 'if $numFound' will do the same
   Menu "To lowercase"
   Menu "Display as Small Caps"
end


2008-10-18 05:14:08
Profile

Joined: 2008-05-27 08:39:25
Posts: 8
Many thanks again!

Quote:
As I'm not a linguist, I may misunderstand the purpose of your macro but you can combine the two Find All commands using | (OR operator).

Of course you're just right. I'm just starting to use RegEx etc. And I shouldn't spend too much time with technical stuff like that :-)

Quote:
And if you want to apply To lowercase and Display as Small Caps on [MFN] but not on the following [-:.) ], you can use [MFN](?=[-:.) ]) instead of [MFN][-:.) ]. (?=expression) is Look-Ahead you can insert from the action menu (gear) of the Find panel.

Your solution is definitely better: if one wants to add something after the interpunction, it's back to standard = non-small caps. I think I saw that in the macro description of Find. I haven't been aware that I could add this in the Find panel. 8)

And good idea to check if anything's found at all. Well, better to stay on the safe side.
Anyway, one cannot use this as a macro for whole texts, because there are some acronyms in CAPS around in the normal text.

So, back to work, entering data on some languages literally around the world.

Thomas

PS It looks like that (from our database, with CAPS, but as nice tables)
‘Axrey ha-pgisha hem hitlonenu exad ‘al ha-sheni
after DEF-meeting 3PL:M complain:PAST:3PL one on DEF-two:ORD
After the meeting they complained about each other.

_________________
Thomas Hanke


2008-10-18 08:08:40
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
Hello again,

Quote:
I haven't been aware that I could add this in the Find panel.
Since the version 1.0.1, Nisus Writer Pro began to use a new regex engine. Unfortunately, help.pdf is not very up-to-date. Features supported by it and its syntax is documented in
http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt

A while ago, I wrote an explanatory document, that you may find interesting if not useful.
http://www2.odn.ne.jp/alt-quinon/files/NWPro/PowerFindPro_rtf.zip

Quote:
Anyway, one cannot use this as a macro for whole texts, because there are some acronyms in CAPS around in the normal text.
Ah, I understand. Then, it would be better to add s to the find option so that the macro work in selection(s) only. Probably you have already done so, though.
Code:
$numFound = Find All '[A-Z]{2,}|[MFN](?=[-:.) ])', 'E-is'

Quote:
PS It looks like that
If M , F and N are always preceded by a colon, you can use (?<=:)[MFN](?=[-:.) ]) instead of [MFN](?=[-:.) ]) to reduce/avoid unexpected matchings.
Code:
$numFound = Find All '[A-Z]{2,}|(?<=:)[MFN](?=[-:.) ])', 'E-is'
(?<=expression) is called look-behind which is available in the action menu of the Find panel too.


2008-10-19 08:38:46
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software