I have a large file which contains hundreds of English phrases in the following form:
\phrase {. . . * * } {I shoul-d've stayed home.} {aɪ ʃʊd‿əv ˈsteɪd ˈhoʊm.} <- only replace on this line \phrase { . . * } {Did you eat?} {dɪdʒjʊʷˈit? ↗} <- only replace on this line \phrase { * . * . * . . . * . } {Yeah, I made some pas-ta if you're hun-gry.} {ˈjɛə, aɪ ˈmeɪd səm ˈpɑ stəʷɪf jər ˈhʌŋ gri.} <- only replace on this line
It's a LaTeX .tex
file. I would like to replace all r
characters in each phonetic transcription (by phonetic transcription I mean every third line after the \phrase
line) with the ɹ
symbol (hex code U+0279
).
Doing it by hand in Emacs is cumbersome for me. I was wondering if there is a way to target those lines somehow and do the replacement automatically.
All r
characters have to be replaced with ɹ
, there is no exception, but only in the phonetic transcription, leave the r
as-is in the English/non-phonetic text.
Is it possible to do that somehow by using a script or something? There are no line breaks in my document so the transcription is alway the third line after \phrase
. Thank you!
sed '/^\\phrase/,+3 { /^\\phrase/,+2 !{ s/r/ɹ/g } }'