Batch editing participant IDs

14 views
Skip to the first unread message

Elnaz Kia

unread,
11 Aug 2021, 20:11:5111/08/2021
to chibolts
Dear Leonid,

I have one more question about my recent inquiry. Per Brian's and your advice, I am in the process of changing the participant IDs and making other necessary revisions. In order to change the transcriptions from form A to form B (see below), I created the following commands. I couldn't find a more dignified path. :-) 

Form A
@Begin
@Languages: fra
@Participants: F0001 IDf0001 Student
@ID: fra|corpus|F0001|0;00.00|male|||Student|||
@Media: f0001c05ri4_1, audio
@Transcriber: Matteo Fiorini
@Comment: euh signals hesitation
@Situation: Introductions
*F0001: je m' appelle (..) NAME NAME (.) euh (.) .
*F0001: NAME c' est mon dernier nom [:: nom de famille] .
*F0001: et ça vienne <de> [/] de Allemagne parce que mon maman <et> [/] et
mon papa est Allemagne [:: allemands] .
*F0001: <et alors je> [//] euh (.) alors mon dernier nom
[:: nom de famille] NAME est Allemagne [:: allemand] .
@End

Form B
@Begin
@Languages: fra
@Participants: STU IDf0001 Student
@ID: fra|mussel|STU|0;00.00|male|||Student||IDf0001|
@Media: f0001c05ri4_1, audio
@Transcriber: Matteo Fiorini
@Comment: euh signals hesitation
@Situation: Introductions
*STU: je m' appelle (..) NAME NAME (.) euh (.) .
*STU: NAME c' est mon dernier nom [:: nom de famille] .
*STU: et ça vienne <de> [/] de Allemagne parce que mon maman <et> [/] et
mon papa est Allemagne [:: allemands] .
*STU: <et alors je> [//] euh (.) alors mon dernier nom
[:: nom de famille] NAME est Allemagne [:: allemand] .
@End

1. To change the participant ID in the main lines in chat & text files (applies to all languages):

chstring +re +w +t* +l +s"\**:" "\*STU:" *.cha

ren +re -f *.chstr.cex *.cha

 

chstring +re +w +y +s"\**:" "\*STU:" *.txt

ren +re -f *.chstr.cex *.txt


2. To change the corpus name and the next field in line @ID in chat & text files (applies to all languages):

chstring +re +w +t@ +s"|corpus|*|" "|mussel|STU|" *.cha

ren +re -f *.chstr.cex *.cha

 

chstring +re +w +y +s"|corpus|*|" "|mussel|STU|" *.txt

ren +re -f *.chstr.cex *.txt


3. To change the optional speaker name (last field) in line @ID

*Note: These commands has to be run separately for each folder, since the ID changes in each folder.

chstring +re +w +t@ +s"|Student|||" "|Student||IDc0002|" *.cha

ren +re -f *.chstr.cex *.cha

 

chstring +re +w +y +s"|Student|||" "|Student||IDc0002|" *.txt

ren +re -f *.chstr.cex *.txt


4. To change the 1st field in line @Participant
*Note: These commands have to be run separately for each folder, since the ID changes in each folder.
Tried this command and a few others, no chance!
chstring +w +d +s"F0010 IDf0010 Student" "STU IDf0010 Student" *.cha

Questions:
a) how can I achieve the last change (4)?
b) I am using batch to run the commands in 1 and 2 (highlighted in yellow). Is it possible to create the search strings for 3 and 4 in a way that it is not dependent on specific IDs so I could run all the commands in batch for all the directories and subdirectories instead of running them on individual folders?

I am so sorry for asking so many questions. I spend hours digging in the manuals and playing with the commands before asking you. :-(

Thank you so much for your help!
Elnaz


Leonid Spektor

unread,
11 Aug 2021, 21:06:1011/08/2021
to chib...@googlegroups.com
Hi Elnaz,

For the number 4. you can try command chstring -w +t@Participants: +s"@Participants: * " "@Participants:STU " *.cha 

For the number 3., if each file or even each folder has its own unique ID*, then there isn't much automation you can achieve. You can create a batch file with multiple CHSTRING commands with different IDs pointing to different subdirectories of corresponding data files. But, to be more specific I need to know what system you are using, i.e. Mac or PC, and the layout of your data files directory tree structure.

I would suggest that you email to me directly instead of chibolts about it, since this is getting much more specific to your particular situation. My email address is spe...@andrew.cmu.edu.



Leonid.

--
You received this message because you are subscribed to the Google Groups "chibolts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chibolts+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chibolts/CAOwOJY%3Df6JUMXRFvKkshZ609pnWUq1tNHRsQbX_VKm8q7WxNuw%40mail.gmail.com.

Brian Macwhinney

unread,
11 Aug 2021, 21:48:1411/08/2021
to ChiBolts
These changes seem okay. I use regex expression changes in BBEdit instead of relying on CHSTRING for things like this, because it gives you fuller control. Similar options are Atom, Sublime Text and so on.

— Brian

Elnaz Kia

unread,
12 Aug 2021, 02:00:1812/08/2021
to chibolts
Hi Brian,

You are right. Using regular expressions in other editors is much easier and more controlled. Thanks for the great advice!

Best,
Elnaz



Elnaz Kia

unread,
12 Aug 2021, 02:03:4812/08/2021
to chibolts
Hi Leonid,

Thank you so much for the help. Your command expression fixed the 4th problem.:-)

Awesome, I will email you for more details on batch editing those folders. 

Thank you very much for being so generous with your time and knowledge.

Best,
Elnaz 




Reply all
Reply to author
Forward
0 new messages