Commit 9f1a25cd authored by tu's avatar tu

annotation of speaker is now possible for every STWR; annotation of

speaker is now possible for speakers outside STWRs; annotation of
intExpr is now possible for reported STWRs
parent 1cb8f917
Pipeline #12040 passed with stage
in 5 minutes and 20 seconds
......@@ -909,68 +909,93 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart {
}
// methods that are required by the view
public void createSpeaker() {
int counter = 0;
AnnotationFS selected = null;
if (editor.getSelectionOfVisibleAnnotations().size() > 0) {
for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) {
if (anno.getType().equals(speakerType)) {
selected = anno;
boolean speakerIDFlag = false;
for (AnnotationFS speaker : speakerList){
if (speaker.getFeatureValueAsString(speakerIDFeat) == null){
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please assign an ID to the speaker " + "\"" + speaker.getFeatureValueAsString(speakerFeat) + "\"" + ".", "Attention", JOptionPane.WARNING_MESSAGE);
speakerIDFlag = true;
}
}
if (speakerIDFlag == false)
{
//int counter = 0;
AnnotationFS selected = null;
if (editor.getSelectionOfVisibleAnnotations().size() > 0) {
for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) {
if (anno.getType().equals(speakerType)) {
selected = anno;
}
}
}
}
// remove vorschlag
CAS cas = editor.getCas();
Type t = speakerType;
// get the selection
// remove vorschlag
CAS cas = editor.getCas();
Type t = speakerType;
// get the selection
if (selected == null) {
if (selected == null) {
Point selection = editor.getActualSelectedText();
if (selection == null || selection.x == selection.y) {
return;
}
AnnotationFS anno = cas.createAnnotation(t, selection.x, selection.y);
anno.getFeatureValueAsString(speakerFeat);
String speakerFeatValue = anno.getFeatureValueAsString(speakerFeat);
speakerFeatValue = anno.getCoveredText();
updateAnnotation(anno, speakerFeat, speakerFeatValue, true);
for (AnnotationFS frame : frameList)
{
if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd())
{
anno.getFeatureValueAsString(speakerFeat);
addAnnotation(anno);
updateAnnotation(anno, speakerIDFeat, frame.getFeatureValueAsString(frameIDFeat), true);
Point selection = editor.getActualSelectedText();
if (selection == null || selection.x == selection.y) {
return;
}
else
AnnotationFS anno = cas.createAnnotation(t, selection.x, selection.y);
anno.getFeatureValueAsString(speakerFeat);
String speakerFeatValue = anno.getFeatureValueAsString(speakerFeat);
speakerFeatValue = anno.getCoveredText();
updateAnnotation(anno, speakerFeat, speakerFeatValue, true);
addAnnotation(anno);
for (AnnotationFS frame : frameList)
{
counter++;
if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd())
{
anno.getFeatureValueAsString(speakerFeat);
addAnnotation(anno);
updateAnnotation(anno, speakerIDFeat, frame.getFeatureValueAsString(frameIDFeat), true);
}
for (AnnotationFS stwr : stwrList){
if (anno.getBegin() >= stwr.getBegin() && anno.getEnd() <= stwr.getEnd())
{
anno.getFeatureValueAsString(speakerFeat);
addAnnotation(anno);
updateAnnotation(anno, speakerIDFeat, stwr.getFeatureValueAsString(stwrIDFeat), true);
}
}
if (counter == frameList.size())
{
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE);
/*
else
{
counter++;
}
if (counter == frameList.size())
{
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE);
}
*/
}
}
}
/*
Display.getCurrent().asyncExec(() -> {
/*
Display.getCurrent().asyncExec(() -> {
renewPage();
});
*/
renewPage();
});
*/
renewPage();
}
}
public void correctSpeakerExp(AnnotationFS selected)
public void speakerOutsideFrame(AnnotationFS selected)
{
List<AnnotationFS> speakerSelection = editor.getCurrentSelectionOfType(speakerType);
List<AnnotationFS> expSelection = editor.getCurrentSelectionOfType(expressionType);
......@@ -981,6 +1006,7 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart {
updateAnnotation(anno, speakerIDFeat, selected.getFeatureValueAsString(frameIDFeat), true);
}
if (expSelection != null && expSelection.size() > 0)
{
AnnotationFS anno = expSelection.get(0);
......@@ -988,9 +1014,21 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart {
}
}
// methods that are required by the view
public void speakerOutsideStwr(AnnotationFS selected)
{
List<AnnotationFS> speakerSelection = editor.getCurrentSelectionOfType(speakerType);
if (speakerSelection != null && speakerSelection.size() > 0)
{
AnnotationFS anno = speakerSelection.get(0);
updateAnnotation(anno, speakerIDFeat, selected.getFeatureValueAsString(stwrIDFeat), true);
}
}
public void createExpression() {
int counter = 0;
int frameCounter = 0;
int repCounter = 0;
AnnotationFS selected = null;
if (editor.getSelectionOfVisibleAnnotations().size() > 0) {
for (AnnotationFS anno : editor.getSelectionOfVisibleAnnotations()) {
......@@ -1001,7 +1039,6 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart {
}
}
// remove vorschlag
CAS cas = editor.getCas();
Type t = expressionType;
// get the selection
......@@ -1018,34 +1055,56 @@ public class RedeWiedergabeView extends AEditorSubordinateViewPart {
expFeatValue = anno.getCoveredText();
updateAnnotation(anno, expressionFeat, expFeatValue, true);
for (AnnotationFS frame : frameList)
{
if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd())
{
for (AnnotationFS frame : frameList){
if (anno.getBegin() >= frame.getBegin() && anno.getEnd() <= frame.getEnd()){
anno.getFeatureValueAsString(expressionFeat);
updateAnnotation(anno, expressionIDFeat, frame.getFeatureValueAsString(frameIDFeat), true);
addAnnotation(anno);
}
}
else
{
counter++;
}
if (counter == frameList.size())
frameCounter++;
}
/*
if (frameCounter == frameList.size())
{
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame.", "Attention", JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame or a reported STWR.", "Attention", JOptionPane.WARNING_MESSAGE);
}
*/
}
ArrayList<AnnotationFS> repAnnoList = getReportedAnno(stwrList);
for (AnnotationFS repAnno : repAnnoList){
if (anno.getBegin() >= repAnno.getBegin() && anno.getEnd() <= repAnno.getEnd()){
anno.getFeatureValueAsString(expressionFeat);
updateAnnotation(anno, expressionIDFeat, repAnno.getFeatureValueAsString(stwrIDFeat), true);
addAnnotation(anno);
}
else
{
repCounter++;
}
}
if (repCounter == repAnnoList.size() && frameCounter == frameList.size())
{
JFrame jFrame = new JFrame("Information");
JOptionPane.showMessageDialog(jFrame, "Please mark a string in a frame or a reported STWR.", "Attention", JOptionPane.WARNING_MESSAGE);
}
}
/*
Display.getCurrent().asyncExec(() -> {
renewPage();
});
*/
renewPage();
}
public ArrayList<AnnotationFS> getReportedAnno(List<AnnotationFS>stwrList){
ArrayList<AnnotationFS> reportedList = new ArrayList<AnnotationFS>();
for (AnnotationFS stwr : stwrList){
if (stwr.getFeatureValueAsString(rTypeFeat).equals("reported")){
reportedList.add(stwr);
}
}
return reportedList;
}
public void createSpeech() {
ambigMediumDialog.speechFlag = false;
ambigMediumDialog.thoughtFlag = false;
......
......@@ -201,7 +201,7 @@ public class RwFrameTableComposite extends Composite{
{
IStructuredSelection sel = (IStructuredSelection) frameViewer.getSelection();
AnnotationFS selected = (AnnotationFS) sel.getFirstElement();
part.correctSpeakerExp(selected);
part.speakerOutsideFrame(selected);
}
// small utility method
......
......@@ -203,6 +203,8 @@ public class RwStwrTableComposite extends Composite{
// table got a key listener
stwrViewer.getTable().addListener(SWT.KeyDown, (Event e) -> handleTableKeyDown(e));
stwrViewer.getTable().addListener(SWT.MouseDoubleClick, (Event e) -> handleTableDoubleClick(e));
}
private void handleTableKeyDown(Event e) {
......@@ -252,6 +254,13 @@ public class RwStwrTableComposite extends Composite{
part.toggleMetaph(selectedAnnos);
}
}
private void handleTableDoubleClick (Event e)
{
IStructuredSelection sel = (IStructuredSelection) stwrViewer.getSelection();
AnnotationFS selected = (AnnotationFS) sel.getFirstElement();
part.speakerOutsideStwr(selected);
}
// small utility method
private List<AnnotationFS> getSelectedAnnotationsFromTable() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment