Skip to content

Language Archiving Technology

Sections
Personal tools
You are here: Home » Tools » Elan » ELAN Forum » PATCH: Exported Praat TextGrids don't escape quotation marks

PATCH: Exported Praat TextGrids don't escape quotation marks

Up one level

PATCH: Exported Praat TextGrids don't escape quotation marks

Posted by cdcox at 2009-01-25 16:46  

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.&nbsp; 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.&nbsp; 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&nbsp;&nbsp;&nbsp; 2008-08-13 11:21:48.000000000 -0600<br>+++ PraatTextGridEncoder.java&nbsp;&nbsp;&nbsp; 2009-01-25 08:27:13.000000000 -0700<br>@@ -254,9 +254,11 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write(NEW_LINE);<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AnnotationDataRecord record = null;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String value = null;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int j = 0; j &lt; annotations.size(); j++) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; record = (AnnotationDataRecord) annotations.get(j);<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = record.getValue().replaceAll("\"", "\"\"");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write(indent2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write(intervals + (j + 1) + "]");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write(NEW_LINE);<br>@@ -270,7 +272,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write(NEW_LINE);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write(indent3);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write(tx);<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write("\"" + record.getValue() + "\"");<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write("\"" + value + "\"");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out.write(NEW_LINE);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>Hope this helps,<br><br><br>-- <br>cdcox<br>

Re: PATCH: Exported Praat TextGrids don't escape quotation marks

Posted by cdcox at 2009-01-25 16:56  

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

Posted by hasloe at 2009-01-26 09:36  

Thanks a lot, I hadn't noticed this before.
I'll include your fix in the next release of ELAN.

Thanks again,
-Han

 

Powered by Plone

This site conforms to the following standards: