Skip to content

Commit

Permalink
Addition speaker tag export
Browse files Browse the repository at this point in the history
  • Loading branch information
pagelj committed Jun 7, 2019
1 parent 1302c9b commit 7cb35fd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* re-maps the views so that tokenization can be done on the speaker view
* {@link SP#SOFA_SPEAKERS}.
*
* @author Nils Reiter
*
*/
public class SP {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import de.unistuttgart.ims.drama.api.Mention;
import de.unistuttgart.ims.drama.api.Scene;
import de.unistuttgart.ims.drama.api.Speaker;
import de.unistuttgart.ims.drama.api.Speech;
import de.unistuttgart.ims.drama.api.StageDirection;
import de.unistuttgart.ims.drama.api.Translator;
import de.unistuttgart.ims.drama.api.Utterance;
Expand Down Expand Up @@ -59,10 +60,8 @@ public enum CSVVariant {
/**
* Prints a record representing the header onto p
*
* @param p
* The target
* @throws IOException
* If an I/O error occurs
* @param p The target
* @throws IOException If an I/O error occurs
*/
public void header(CSVPrinter p) throws IOException {
switch (this) {
Expand Down Expand Up @@ -234,61 +233,63 @@ private void convertUtterancesWithTokens(JCas jcas, CSVPrinter p) throws IOExcep
for (Utterance utterance : JCasUtil.select(jcas, Utterance.class)) {
for (Speaker speaker : DramaUtil.getSpeakers(utterance)) {
for (int i = 0; i < speaker.getCastFigure().size(); i++) {
for (Token token : JCasUtil.selectCovered(Token.class, utterance)) {
if (stageMap.containsKey(token)) {
continue;
}
used.clear();
p.print(drama.getCollectionId());
p.print(drama.getDocumentId());
p.print(utterance.getBegin());
p.print(utterance.getEnd());
try {
p.print(speaker.getCastFigure(i).getNames(0));
} catch (NullPointerException e) {
p.print(null);
}
try {
p.print(speaker.getCastFigure(i).getXmlId(0));
} catch (NullPointerException e) {
p.print(null);
}
p.print(token.getCoveredText());
p.print(token.getPos().getPosValue());
p.print(token.getLemma().getValue());
p.print(length);
String printSurface = null;
String printId = null;
if (mentionMap.containsKey(token)) {
Collection<Mention> mList = mentionMap.get(token);
for (Mention m : mList) {
if (m.getEntity() == null) {
printSurface = null;
printId = null;
} else {
if (!used.contains(m)) {
if (m.getEntity() instanceof CastFigure) {
printSurface = m.getEntity().getDisplayName();
}
try {
if (printId == null) {
printId = createBrackets(printId, m, token);
} else {
printId = printId + "|" + createBrackets(printId, m, token);
for (Speech speech : JCasUtil.selectCovered(Speech.class, utterance)) {
for (Token token : JCasUtil.selectCovered(Token.class, speech)) {
if (stageMap.containsKey(token)) {
continue;
}
used.clear();
p.print(drama.getCollectionId());
p.print(drama.getDocumentId());
p.print(utterance.getBegin());
p.print(utterance.getEnd());
try {
p.print(speaker.getCastFigure(i).getNames(0));
} catch (NullPointerException e) {
p.print(null);
}
try {
p.print(speaker.getCastFigure(i).getXmlId(0));
} catch (NullPointerException e) {
p.print(null);
}
p.print(token.getCoveredText());
p.print(token.getPos().getPosValue());
p.print(token.getLemma().getValue());
p.print(length);
String printSurface = null;
String printId = null;
if (mentionMap.containsKey(token)) {
Collection<Mention> mList = mentionMap.get(token);
for (Mention m : mList) {
if (m.getEntity() == null) {
printSurface = null;
printId = null;
} else {
if (!used.contains(m)) {
if (m.getEntity() instanceof CastFigure) {
printSurface = m.getEntity().getDisplayName();
}
try {
if (printId == null) {
printId = createBrackets(printId, m, token);
} else {
printId = printId + "|" + createBrackets(printId, m, token);
}
used.add(m);
} catch (NullPointerException e) {
//
}
used.add(m);
} catch (NullPointerException e) {
//
}
}
}
} else {
//
}
} else {
//
p.print(printSurface);
p.print(printId);
p.println();
}
p.print(printSurface);
p.print(printId);
p.println();
}
}
}
Expand Down Expand Up @@ -392,8 +393,7 @@ private void convertEntities(JCas jcas, CSVPrinter p) throws IOException {
* This function returns the longest from a given collection of annotations.
* Length measured as <code>end - begin</code>.
*
* @param coll
* The annotation collection
* @param coll The annotation collection
* @return The longest of the annotation.
*/
@Deprecated
Expand Down

0 comments on commit 7cb35fd

Please sign in to comment.