View Single Post
Old 09-29-2022, 05:32 PM   #114
pzack
Connoisseur
pzack began at the beginning.
 
Posts: 79
Karma: 10
Join Date: Aug 2022
Device: kobo sage,elipsa
Pyglossary conversion to stardict Codes

Hello, M Sarmat89,

I thought it best to add to the message just sent to you. Here are the codes as I understand that I am to use;

^([^[]+?) *(?=\[)

replaced with
Code:

\1\t

The codes above were from one of your earlier posts. I don't think that I am to use the above codes as I think that you provided me some code that supercedes the above.

This is for unfolding the lines and to be used first;

(?<=\S)\n(?=\S)

Then I use these 4 lines of code;

erl -pe 's/\n\n+/\|\|/sg' <original.txt> output1.txt
perl -pe 's/\n/ /sg' <output1.txt> output2.txt
perl -pe 's/\|\|/\n/sg' <output2.txt> output3.txt
perl -pe 's/^(\S+)/$1 /sg' <output3.txt> output4.csv

Finally, I use this line of code which produces the final file for use in pyglossary;

perl -pe "s:^([^[]+?) *(?=\[):\1\t:" <your-file-here >destination.tsv

Kindly, please let me know if all this is correct otherwise please point out the errors/s.

Once again, please indicate what file I am to use to begin this process that begins with the line unfolding.

You had provided some other pieces of code in earlier posts but I assume that what is above supercedes the other code.

Thank you for your patience with all this.

Cordially,
pz

Last edited by pzack; 09-29-2022 at 05:35 PM.
pzack is offline