Skip to content

Commit

Permalink
#496 and then some
Browse files Browse the repository at this point in the history
  • Loading branch information
berndmoos committed Nov 5, 2024
1 parent 52b463e commit aa569e3
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 24 deletions.
14 changes: 4 additions & 10 deletions src/org/exmaralda/coma/actions/CorpusStatisticsAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public CorpusStatisticsAction(String text, ImageIcon icon, Coma c) {
super(text, icon, c);
}

@Override
public void actionPerformed(ActionEvent e) {
final File file = coma.getData().getOpenFile();
if (file == null) {
Expand All @@ -58,6 +59,7 @@ public void actionPerformed(ActionEvent e) {
pbd.setVisible(true);

final Runnable doDisplaySaveDialog = new Runnable() {
@Override
public void run() {
displaySaveDialog(counter);
}
Expand All @@ -71,15 +73,7 @@ public void run() {
file.getParentFile());
javax.swing.SwingUtilities
.invokeLater(doDisplaySaveDialog);
} catch (IOException ex) {
ex.printStackTrace();
} catch (SAXException ex) {
ex.printStackTrace();
} catch (JexmaraldaException ex) {
ex.printStackTrace();
} catch (URISyntaxException ex) {
ex.printStackTrace();
} catch (JDOMException ex) {
} catch (IOException | SAXException | JexmaraldaException | URISyntaxException | JDOMException ex) {
ex.printStackTrace();
}
}
Expand All @@ -94,7 +88,7 @@ public void run() {
}

private void displaySaveDialog(SegmentsCounter counter) {
if (counter.getErrorList().size() > 0) {
if (!counter.getErrorList().isEmpty()) {
String out = "<html>" + Ui.getText("err.processingFiles") + "<br/>";
int countErr = 0;
for (String error : counter.getErrorList()) {
Expand Down
5 changes: 4 additions & 1 deletion src/org/exmaralda/common/corpusbuild/TEIMerger.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ public static Vector TEIMerge(Document segmentedTranscription,
// go through all top level segment chains
for (Object segmentChain : segmentChains) {
Element sc = (Element) (segmentChain);
sc.setAttribute("speaker", sc.getParentElement().getParentElement().getAttributeValue("speaker"));
String parentSpeaker = sc.getParentElement().getParentElement().getAttributeValue("speaker");
if (parentSpeaker!=null){
sc.setAttribute("speaker", parentSpeaker);
}
String tierref = sc.getParentElement().getAttributeValue("tierref");
String start = sc.getAttributeValue("s");
String end = sc.getAttributeValue("e");
Expand Down
3 changes: 0 additions & 3 deletions src/org/exmaralda/exakt/exmaraldaSearch/swing/EXAKT.form
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,6 @@
</Component>
<Component class="javax.swing.JButton" name="openPartiturEditorButton">
<Properties>
<Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="null"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/org/exmaralda/exakt/exmaraldaSearch/swing/resources/pe_small.png"/>
</Property>
Expand Down
1 change: 1 addition & 0 deletions src/org/exmaralda/exakt/exmaraldaSearch/swing/EXAKT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,7 @@ public void showPartitur(KWICTableEvent event) {
playButton.setEnabled(success);
stopButton.setEnabled(false);
getPartitur().getModel().setTranscriptionAndTierFormatTable(bt,tft);

//getPartitur().setPlaybackMode(true);
}
System.out.println(tierID + " " + timeID2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private void webMAUS() throws JexmaraldaException, IOException, JDOMException, S
mausParameterDialog.setVisible(true);
if (!mausParameterDialog.approved) return;
final HashMap<String, Object> mausParameters = mausParameterDialog.getMAUSParameters();


// get the transcription and the current selection
final BasicTranscription bt = table.getModel().getTranscription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class TreeTaggableISOTEITranscription implements TreeTaggableDocument {

public static String XPATH_TO_SEGS = "//tei:seg";
public static String XPATH_TO_SEGS = "//tei:seg[not(tei:seg)]";
public static String XPATH_ALL_WORDS_AND_PUNCTUATION = "descendant::*[self::tei:w or self::tei:pc]";
public static String XPATH_NO_XY = "descendant::*[(self::tei:w and not(@norm='&')) or self::tei:pc]";
public static String XPATH_NO_DUMMIES = "descendant::*[(self::tei:w and not(@norm='&' or @norm='%' or @norm='§' or @norm='äh')) or self::pc]";
Expand Down
54 changes: 54 additions & 0 deletions src/org/exmaralda/tei/xml/gatIntonationUnits.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
xmlns:tei="http://www.tei-c.org/ns/1.0"
exclude-result-prefixes="xs math"
version="3.0">

<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="tei:seg[@type='contribution']">
<xsl:variable name="TOKENS">
<seg>
<xsl:for-each select="*">
<xsl:copy>
<xsl:attribute name="count-iu">
<xsl:choose>
<xsl:when test="not(self::tei:anchor)">
<xsl:value-of select="count(preceding-sibling::tei:pc[matches(text(),'[\.\?\-;,]')]) + 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(preceding-sibling::tei:pc[matches(text(),'[\.\?\-;,]')])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:for-each>
</seg>
</xsl:variable>

<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:for-each-group select="$TOKENS/seg/*" group-by="@count-iu">
<xsl:apply-templates select="current-group()[1]/preceding-sibling::tei:anchor[1]"/>
<xsl:if test="not(current-grouping-key()='0')">
<tei:seg type="intonation-unit">
<xsl:apply-templates select="current-group()[not(self::tei:anchor)]"/>
</tei:seg>
</xsl:if>
</xsl:for-each-group>
<xsl:copy-of select="tei:anchor[last()]"/>
</xsl:copy>


</xsl:template>

<xsl:template match="@count-iu"/>

</xsl:stylesheet>
12 changes: 10 additions & 2 deletions src/org/exmaralda/webservices/MAUSConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class MAUSConnector {

private boolean useGeneralMAUSVersion = false;

public String webMausBasicURL = "http://clarin.phonetik.uni-muenchen.de/BASWebServices/services/runMAUSBasic";
public String webMausGeneralURL = "http://clarin.phonetik.uni-muenchen.de/BASWebServices/services/runMAUS";
public String webMausBasicURL = "https://clarin.phonetik.uni-muenchen.de/BASWebServices/services/runMAUSBasic";
public String webMausGeneralURL = "https://clarin.phonetik.uni-muenchen.de/BASWebServices/services/runMAUS";

public MAUSConnector() {
}
Expand Down Expand Up @@ -88,11 +88,19 @@ public String callMAUS(File textFile, File audioFile, HashMap<String, Object> ot
//httpPost.setEntity(entity); // deprecated
httpPost.setEntity(builder.build());
HttpResponse response = httpClient.execute(httpPost);
System.out.println("Now calling " + httpPost.toString());
HttpEntity result = response.getEntity();

StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();

System.out.println("Got result! Status is " + statusCode);

if (statusCode==302) {
String location = response.getFirstHeader("Location").getValue();
System.out.println("LOCATION: " + location);
}

if (statusCode==200 && result != null) {
String resultAsString = EntityUtils.toString(result);
// should look something like this
Expand Down
12 changes: 5 additions & 7 deletions src/org/exmaralda/webservices/TestMAUSConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@ public class TestMAUSConnector {
public static void main(String[] args) {
try {
new TestMAUSConnector().doit();
} catch (IOException ex) {
Logger.getLogger(TestMAUSConnector.class.getName()).log(Level.SEVERE, null, ex);
} catch (JDOMException ex) {
} catch (IOException | JDOMException ex) {
Logger.getLogger(TestMAUSConnector.class.getName()).log(Level.SEVERE, null, ex);
}
}

private void doit() throws IOException, JDOMException {
MAUSConnector mc = new MAUSConnector(true);
MAUSConnector mc = new MAUSConnector(false);

File textFile = new File("C:\\Users\\bernd\\OneDrive\\Desktop\\MAUS_TEST.TXT");
File signalFile = new File("C:\\Users\\bernd\\OneDrive\\Desktop\\MAUS_TEST.WAV");
File textFile = new File("C:\\Users\\bernd\\OneDrive\\Desktop\\TEST_MAUS\\TEST.TXT");
File signalFile = new File("C:\\Users\\bernd\\OneDrive\\Desktop\\TEST_MAUS\\TEST.WAV");

String[][] parameters = {
{"LANGUAGE","deu"}
Expand All @@ -52,7 +50,7 @@ private void doit() throws IOException, JDOMException {

PraatConverter pc = new PraatConverter();
BasicTranscription bt = pc.readPraatFromFile(temp.getAbsolutePath(), "UTF-8");
bt.writeXMLToFile("C:\\Users\\bernd\\OneDrive\\Desktop\\MAUS_TEST.exb", "none");
bt.writeXMLToFile("C:\\Users\\bernd\\OneDrive\\Desktop\\TEST_MAUS\\MAUS_TEST.exb", "none");

System.out.println(result);
}
Expand Down

0 comments on commit aa569e3

Please sign in to comment.