creating a duplicate line then changing it to a phonetic for

General discussions about Advanced Find and Replace
Post Reply
droog
Posts: 6
Joined: Sun Aug 26, 2007 8:01 am

creating a duplicate line then changing it to a phonetic for

Post by droog »

Hi all,

I apologize if this seems obvious but I've never used regular expressions, this is completely alien to me. I'm just trying to find out a way to automate an ongoing task I have. I need to create a phonetic pronunciation for phrases. They are in a single open office file .odt. I have pasted some into a text file to see if AFR can help me but I'm not able to parse the file. This is how the phrases are layed out-

What?
¿Qué?

Excuse me?
¿Perdón?

I don't understand.
No entiendo.

I want to change it to this using a phonetic formula I made.

What?
¿Qué?
¿keh?

Excuse me?
¿Perdón?
¿pehr-dohn?

I don't understand.
No entiendo.
noh ehn-tee-ehndo.

I was told to first create a duplicate line of the foreign phrase then change the duplicate foreign phrase to the phonetic phrase. Take this-

What?
¿Qué?

Make this-

What?
¿Qué?
¿Qué?

Then run AFR again to create this-

What?
¿Qué?
¿keh?

Using regular expressions I tried this to create the duplicate line-

Search for-
\r\n(\w+)\r\n(\w+)\r\n

Replace with -
\r\n<%=$1=%>\r\n<%=$2=%>\r\n<%=$2=%>\r\n

But I keep getting 0 files found. I obviously don't have the string set up correctly.

Once I have the duplicate line set up then I need to change it. If I have my phonetic formula in the batch replace grid then where/how would I set it up so it only replaces the third line (the duplicate) and doesn't modifly the other lines? Is that made in the regular expression builder?

Thanks!

PS... The blank line between each phrase group may contain a white space sometimes.

droog
Posts: 6
Joined: Sun Aug 26, 2007 8:01 am

Re: creating a duplicate line then changing it to a phonetic for

Post by droog »

I have figured out how to create the duplicate line using this-

Search for:
\r\n(.+)\r\n(.+)\r\n

Replace with:
\r\n$1\r\n$2\r\n$2\r\n

So my phrases are set up like this now-

What?
¿Qué?
¿Qué?

Excuse me?
¿Perdón?
¿Perdón?

I don't understand.
No entiendo.
No entiendo.

Now I need to change the third line of every phrase to the pronunciation phrase so it looks like this-

What?
¿Qué?
¿keh?

Excuse me?
¿Perdón?
¿pehrdohn?

etc..

I have put my pronunciation phrase formula into the batch grid but I have not figured out how to set AFR to just change the third line of every phrase and leave the other two lines as they are. With everything I've tried so far it changes every line instead of just the third line.

Thanks

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Re: creating a duplicate line then changing it to a phonetic for

Post by Abacre »

For your situation there are many different solutions.

Anyway in order to work with the third line you should tell AFR which
line is the third. Therefore you should use the regular expressions
for it.

On the first step you may create the third line as a duplicate of
second line using your r.e.:
Search for:
\r\n(.+)\r\n(.+)\r\n

Replace with:
\r\n$1\r\n$2\r\n$2\r\n

Then you may use r.e. like:
Search for:
(\r\n\S*\r\n\S*\r\n.*)Per
Replace with:
$1pehr

So for pronunciations batch grid should contain the r.e. like the one
given above.

But I would do that in the different way:

On the first step I would create the third line as a duplicate and
then mark it with any given label, for example, PRN: (means
pronunciation).

You should use the slightly modified version of you previous r.e.:
Search for:
\r\n(.+)\r\n(.+)\r\n

Replace with:
\r\n$1\r\n$2\r\nPRN:$2\r\n

As result you will have the text:
What?
¿Qué?
PRN:¿Qué?

Excuse me?
¿Perdón?
PRN:¿Perdón?

I don't understand.
No entiendo.
PRN:No entiendo.

Now each third line starts with PRN: and you r.e. will be much easy
for the second step:

Search for:
(^PRN:.*)Per

Replace with:
$1pehr

Note: Modifier S should be unchecked for the second step.

So you should fill the batch grid with r.e. like this.
You cannot avoid using r.e. on this step. Even in this case you should
tell AFR which is "the third line".

On the third step you simply remove PRN: from your text using literal
replace or a simple r.e.

That's all.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

droog
Posts: 6
Joined: Sun Aug 26, 2007 8:01 am

Re: creating a duplicate line then changing it to a phonetic for

Post by droog »

Thank you very much for your response. I have followed your suggestions, including unchecking modifier "s". It has searched and replaced parts but skipped other parts. Also the only way I was able to get this to search and replace was by checking modifier "m".

Here is the phonetic formula-

First an excecution of this-

Search for = Replace with

(^PRN:.*)h = $1
This is to delete all the written "h"s as they are silent in Spanish. This was deleting the phonetic "h"s (a=ah) when ran in the second step.

(^PRN:.*)qu = $1k
This is to delete the "u" that always follows a "q" as it was being changed like a regular "u" when I included it in the second step.


Here is the execution of the second step-

Search for = Replace with
(^PRN:.*)e = $1eh
(^PRN:.*)o = $1oh
(^PRN:.*)i = $1ee
(^PRN:.*)a = $1ah
(^PRN:.*)u = $1oo
(^PRN:.*)y = $1ee
(^PRN:.*)c = $1k
(^PRN:.*)j = $1h
(^PRN:.*)ll = $1y
(^PRN:.*)ñ = $1ny
(^PRN:.*)x = $1ks
(^PRN:.*)z = $1s
(^PRN:.*)á = $1AH
(^PRN:.*)ó = $1OH
(^PRN:.*)é = $1EH
(^PRN:.*)í = $1EE
(^PRN:.*)á = $1OH

In the examples below, I've put parenthesis where it did not make the changes. For example, any "a" should be replaced with "ah" (a=ah). Some were replaced, others were not. I have deleted the first and second line of each phrase so it is easier to read here.


PRN:¿kEH?

PRN:¿kOHmoh?

PRN:¿PehrdOHn?

PRN:Lo(o=oh) seeehntoh....

PRN:No(o=oh) enteeehndoh.

PRN:¿kEH di(i=ee)heesteh?

PRN:¿kEH dehseeahs?

PRN:¿Pooe(e=eh)de(e=eh)s re(e=eh)pehteerloh?

PRN:¿Me(e=eh) loh vooe(e=eh)lve(e=eh)s a(a=ah) ehkspleekahr?

PRN:No(o=oh) te(e=eh) e(e=eh) e(e=eh)ntehndeedoh.

PRN:No(o=oh) lo(o=oh) eh ka(a=ah)ptahdoh.

PRN:¿Pooe(e=eh)dehs a(a=ah)bla(a=ah)r mAHs ahltoh?

PRN:¿Pooe(e=eh)de(e=eh)s a(a=ah)bla(a=ah)r mAHs dehspahseeoh?

PRN:¡MAHs dehspa(a=ah)seeo(o=oh), po(o=oh)r fahvohr!

PRN:¿kEH si(i=ee)gni(i=ee)feekah ___?

PRN:¿Si(i=ee)gni(i=ee)feekah keh ___?

PRN:¿COHmo(o=oh) se(e=eh) deeseh ___ e(e=eh)n ehspahnyohl?

PRN:¿kEH ki(i=ee)e(e=eh)re(e=eh) dehseer la(a=ah) pa(a=ah)la(a=ah)brah ___?

PRN:¿Ti(i=ee)e(e=eh)nehs di(i=ee)c(c=k)ki(i=ee)o(o=oh)nahreeoh?

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Re: creating a duplicate line then changing it to a phonetic for

Post by Abacre »

To replace all items:
Go to menu Action - Options - Batch Replace
and check "Replace Until Found" option.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

droog
Posts: 6
Joined: Sun Aug 26, 2007 8:01 am

Re: creating a duplicate line then changing it to a phonetic for

Post by droog »

That's not working. It repeats some parts and still does not replace other parts. Here's an example-

PRN:¿Me lo vuelves a explicar?

Parenthesis shows parts it is still not replacing.

PRN:¿Me(e=eh)lohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh vooe(e=eh)lve(e=eh)s a(a=ah) ehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhkspleekahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhr?


I have tried changing the max number of replacements found. The above is for 100. I've tried 10, 100 and 1000. At 1000 the software just hangs.

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Re: creating a duplicate line then changing it to a phonetic for

Post by Abacre »

I will send you alternative solution later on today.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

droog
Posts: 6
Joined: Sun Aug 26, 2007 8:01 am

Re: creating a duplicate line then changing it to a phonetic for

Post by droog »

cool, thanks a lot.

droog
Posts: 6
Joined: Sun Aug 26, 2007 8:01 am

Re: creating a duplicate line then changing it to a phonetic for

Post by droog »

Please post alternative solution that was to be posted Saturday. Thanks.........

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Re: creating a duplicate line then changing it to a phonetic for

Post by Abacre »

The alternative solution is the following:

To create duplicate line use:

Code: Select all

Search for:
\r\n(.+)\r\n(.+)\r\n

Replace with:
\r\n$1\r\n$2\r\nPRN:$2:PRN\r\n
Thus: third line will be surrounded by PRN

The next step:
Check "Replace until found" on Batch replace options
and uncheck Modifier S.

Then fill the batch grid with the following:

Code: Select all

Search for:
(PRN.*[^<])e([^>].*PRN)

Replace with:
$1<eh>$2

Search for:
(PRN.*[^<])o([^>].*PRN)

Replace with:
$1<oh>$2
etc.

On the next step:
Uncheck "Use Regular expressions"
Put into Batch Grid:

Code: Select all

Search For:
<
Replace with:
(empty)

Search For:
 >
Replace with:
(empty)

Search For:
PRN:
Replace with:
(empty)

Search For:
:PRN
Replace with:
(empty)
So you will remove these temp strings from your file.

I verified: it did work.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Post Reply