Skip to content

Commit

Permalink
Merge branch 'release/1.14.4'
Browse files Browse the repository at this point in the history
* release/1.14.4:
  1.14.4
  Updated changelog
  1.14.4
  Fixes #340
  • Loading branch information
Nils Reiter committed Nov 4, 2020
2 parents e4f8970 + fc18ce5 commit 52171a0
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Issue numbers (e.g., #43) refer to GitHub issues:
https://github.com/nilsreiter/CorefAnnotator/issues

## 1.14.4

- Fixed a bug caused by old flags no longer being generated
automatically #340

## 1.14.3

- Added that wide-spaced text is now displayed with a serif font #315
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.unistuttgart.ims</groupId>
<artifactId>coref.annotator</artifactId>
<version>1.14.3</version>
<version>1.14.4</version>
<packaging>jar</packaging>
<name>CorefAnnotator</name>
<url>https://github.com/nilsreiter/CorefAnnotator/</url>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package de.unistuttgart.ims.coref.annotator.uima;

import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.eclipse.collections.api.set.MutableSet;
import org.eclipse.collections.impl.factory.Sets;
import org.kordamp.ikonli.materialdesign.MaterialDesign;

import de.unistuttgart.ims.coref.annotator.api.v1.Entity;
import de.unistuttgart.ims.coref.annotator.api.v1.Flag;
import de.unistuttgart.ims.coref.annotator.api.v1.Mention;

public class VerifyFlagObjects extends JCasAnnotator_ImplBase {

@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {

MutableSet<Flag> flags = Sets.mutable.ofAll(JCasUtil.select(jcas, Flag.class));

for (Entity entity : JCasUtil.select(jcas, Entity.class)) {
if (entity.getFlags() != null)
for (String flagKey : entity.getFlags()) {
boolean ok = false;
for (Flag flag : flags) {
if (flag.getKey().equalsIgnoreCase(flagKey)
&& flag.getTargetClass().equalsIgnoreCase(Entity.class.getName())) {
ok = true;
}
}
if (!ok) {
Flag flag = new Flag(jcas);
flag.setKey(flagKey);
flag.setIcon(MaterialDesign.MDI_FLAG.name());
flag.setTargetClass(Entity.class.getName());
flag.setLabel(flagKey);
flag.addToIndexes();
flags.add(flag);
}
}
}

for (Mention mention : JCasUtil.select(jcas, Mention.class)) {
if (mention.getFlags() != null)
for (String flagKey : mention.getFlags()) {
boolean ok = false;
for (Flag flag : flags) {
if (flag.getKey().equalsIgnoreCase(flagKey)
&& flag.getTargetClass().equalsIgnoreCase(Mention.class.getName())) {
ok = true;
}
}
if (!ok) {
Flag flag = new Flag(jcas);
flag.setKey(flagKey);
flag.setIcon(MaterialDesign.MDI_FLAG.name());
flag.setTargetClass(Mention.class.getName());
flag.setLabel(flagKey);
flag.addToIndexes();
flags.add(flag);
}
}
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import de.unistuttgart.ims.coref.annotator.plugins.UimaImportPlugin;
import de.unistuttgart.ims.coref.annotator.uima.EnsureMeta;
import de.unistuttgart.ims.coref.annotator.uima.Fix131;
import de.unistuttgart.ims.coref.annotator.uima.VerifyFlagObjects;
import de.unistuttgart.ims.uimautil.SetJCasLanguage;

public class JCasLoader extends SwingWorker<JCas, Object> {
Expand Down Expand Up @@ -108,6 +109,7 @@ private JCas readFile() throws IOException, UIMAException {
SetJCasLanguage.PARAM_LANGUAGE, getLanguage()));
b.add(flavor.getImporter());
b.add(AnalysisEngineFactory.createEngineDescription(Fix131.class));
b.add(AnalysisEngineFactory.createEngineDescription(VerifyFlagObjects.class));

SimplePipeline.runPipeline(jcas, b.createAggregateDescription());
return jcas;
Expand All @@ -120,6 +122,7 @@ private JCas readFile() throws IOException, UIMAException {
SetJCasLanguage.PARAM_LANGUAGE, getLanguage()));
b.add(flavor.getImporter());
b.add(AnalysisEngineFactory.createEngineDescription(Fix131.class));
b.add(AnalysisEngineFactory.createEngineDescription(VerifyFlagObjects.class));

iter = SimplePipeline.iteratePipeline(crd, b.createAggregateDescription()).iterator();
if (iter.hasNext()) {
Expand Down

0 comments on commit 52171a0

Please sign in to comment.