corpus-services  1.0
GATListHTML.java
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
7 package de.uni_hamburg.corpora.visualization;
8 
11 import java.util.logging.Level;
12 import java.util.logging.Logger;
13 import javax.xml.transform.TransformerConfigurationException;
14 import javax.xml.transform.TransformerException;
15 import org.exmaralda.partitureditor.fsm.FSMException;
16 import org.exmaralda.partitureditor.jexmaralda.BasicTranscription;
17 import org.exmaralda.partitureditor.jexmaralda.JexmaraldaException;
18 import org.exmaralda.partitureditor.jexmaralda.ListTranscription;
19 import org.exmaralda.partitureditor.jexmaralda.segment.GATSegmentation;
20 import org.xml.sax.SAXException;
21 
26 public class GATListHTML extends ListHTML {
27 
28  private static final String segmentationAlgorithm = "GAT";
29 
30  // resources loaded from directory supplied in pom.xml
31  static final String STYLESHEET_PATH = "/xsl/GAT2ListHTML.xsl";
32  private static final String SERVICE_NAME = "GATListHTML";
33 
34 
35  public GATListHTML(String btAsString) {
36  super(btAsString, "GAT");
37  createFromBasicTranscription(btAsString);
38  }
39 
40 
47  private void createFromBasicTranscription(String btAsString){
48 
49  basicTranscriptionString = btAsString;
51 
52  String result = null;
53 
54  try {
55 
56  BasicTranscription bt = basicTranscription;
57 
58  // segment the basic transcription and transform it into a list transcription
59  GATSegmentation segmenter = new org.exmaralda.partitureditor.jexmaralda.segment.GATSegmentation("");
60  ListTranscription lt;
61  lt = segmenter.BasicToIntonationUnitList(bt);
62 
63  // read the XSL stylesheet into a String
64  String xsl = TypeConverter.InputStream2String(getClass().getResourceAsStream(STYLESHEET_PATH));
65 
66  // read segmented transcription into String
67  String xml = TypeConverter.JdomDocument2String(GATSegmentation.toXML(lt));
68 
69  XSLTransformer xt = new XSLTransformer();
70  result = xt.transform(xml, xsl);
71 
72  } catch (FSMException ex) {
73  Logger.getLogger(GATListHTML.class.getName()).log(Level.SEVERE, null, ex);
74  } catch (SAXException ex) {
75  Logger.getLogger(GATListHTML.class.getName()).log(Level.SEVERE, null, ex);
76  } catch (JexmaraldaException ex) {
77  Logger.getLogger(GATListHTML.class.getName()).log(Level.SEVERE, null, ex);
78  } catch (TransformerConfigurationException ex) {
79  Logger.getLogger(GATListHTML.class.getName()).log(Level.SEVERE, null, ex);
80  } catch (TransformerException ex) {
81  Logger.getLogger(GATListHTML.class.getName()).log(Level.SEVERE, null, ex);
82  }
83 
84  setHTML(result);
85 
86  }
87 
88 }
static BasicTranscription String2BasicTranscription(String btAsString)
static String InputStream2String(InputStream is)
static String JdomDocument2String(org.jdom.Document jdomDocument)