PATCH: Exported Praat TextGrids don't escape quotation marks
Up one level
PATCH: Exported Praat TextGrids don't escape quotation marks
Hi,<br><br>There would seem to be a small bug in the way ELAN 3.6.0 exports its transcripts to Praat TextGrid format. When exported as a text grid, any ELAN transcript which contains a quotation mark (") in one of its annotations will produce output unopenable in Praat.<br><br>One solution is to escape the quotation mark in the annotation by doubling it, which would seem to be how Praat expects in-line quotation marks to be presented in text grids. Below is a patch to "src/java/mpi/eudico/server/corpora/clomimpl/praat/PraatTextGridEncoder.java" for 3.6.0 which should hopefully fix the problem.<br><br>--- PraatTextGridEncoder.java.orig 2008-08-13 11:21:48.000000000 -0600<br>+++ PraatTextGridEncoder.java 2009-01-25 08:27:13.000000000 -0700<br>@@ -254,9 +254,11 @@<br> out.write(NEW_LINE);<br> <br> AnnotationDataRecord record = null;<br>+ String value = null;<br> <br> for (int j = 0; j < annotations.size(); j++) {<br> record = (AnnotationDataRecord) annotations.get(j);<br>+ value = record.getValue().replaceAll("\"", "\"\"");<br> out.write(indent2);<br> out.write(intervals + (j + 1) + "]");<br> out.write(NEW_LINE);<br>@@ -270,7 +272,7 @@<br> out.write(NEW_LINE);<br> out.write(indent3);<br> out.write(tx);<br>- out.write("\"" + record.getValue() + "\"");<br>+ out.write("\"" + value + "\"");<br> out.write(NEW_LINE);<br> }<br> }<br><br>Hope this helps,<br><br><br>-- <br>cdcox<br>
Re: PATCH: Exported Praat TextGrids don't escape quotation marks
Hello,
(Apologies for the mess above; something seems to have gone wrong with the editor, and I couldn't find any way to edit or remove an existing post. Even the "Undo" option wouldn't allow me roll back the previous posting.)
There would seem to be a small bug in the way ELAN 3.6.0 exports its transcripts to Praat TextGrid format. When exported as a text grid, any ELAN transcript which contains a quotation mark (") in one of its annotations will produce output unopenable in Praat.
One solution is to escape the quotation mark in the annotation by doubling it, which would seem to be how Praat expects in-line quotation marks to be presented in text grids. Below is a patch to "src/java/mpi/eudico/server/corpora/clomimpl/praat/PraatTextGridEncoder.java" for 3.6.0 which should hopefully fix the problem.
--- PraatTextGridEncoder.java.orig 2008-08-13 11:21:48.000000000 -0600
+++ PraatTextGridEncoder.java 2009-01-25 08:27:13.000000000 -0700
@@ -254,9 +254,11 @@
out.write(NEW_LINE);
AnnotationDataRecord record = null;
+ String value = null;
for (int j = 0; j < annotations.size(); j++) {
record = (AnnotationDataRecord) annotations.get(j);
+ value = record.getValue().replaceAll("\"", "\"\"");
out.write(indent2);
out.write(intervals + (j + 1) + "]");
out.write(NEW_LINE);
@@ -270,7 +272,7 @@
out.write(NEW_LINE);
out.write(indent3);
out.write(tx);
- out.write("\"" + record.getValue() + "\"");
+ out.write("\"" + value + "\"");
out.write(NEW_LINE);
}
}
Hope this helps,
--
cdcox
Re: Re: PATCH: Exported Praat TextGrids don't escape quotation marks
Thanks a lot, I hadn't noticed this before.
I'll include your fix in the next release of ELAN.
Thanks again,
-Han