Skip to content

Commit

Permalink
#3732 - Improve confirmation dialogs
Browse files Browse the repository at this point in the history
- Format source code and organize imports
  • Loading branch information
reckart committed Jan 22, 2023
1 parent 5c98bed commit 683723b
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ private void openHistoryItemRemovalConfirmationDialog(AjaxRequestTarget aTarget,
}
deleteAnnotationByHistory(_t, aRecord);
});

dialogContent.setCancelAction(_t -> {
if (alStateModel.getObject().getSuggestion().isPresent()) {
setActiveLearningHighlight(alStateModel.getObject().getSuggestion().get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public HistoryItemDeleteConfirmationDialogPanel(String aId)
{
super(aId);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ private void renderLayers(GetDocumentResponse aResponse, VDocument aVDoc)
}) //
.collect(toList());

Entity entity = new Entity(vspan.getVid(), getBratTypeName(vspan.getLayer()),
offsets, vspan.getLabelHint(), vspan.getColorHint(),
vspan.isActionButtons());
Entity entity = new Entity(vspan.getVid(), getBratTypeName(vspan.getLayer()), offsets,
vspan.getLabelHint(), vspan.getColorHint(), vspan.isActionButtons());
if (!layer.isShowTextInHover()) {
// If the layer is configured not to display the span text in the popup, then
// we simply set the popup to the empty string here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public DeleteGuidelinesConfirmationDialogPanel(String aId, IModel<String> aModel
super(aId);
queue(new Label("name", aModel));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@
*/
@ResourceMetaData(name = "NLP Interchange Format (NIF) Reader")
@DocumentationResource("${docbase}/format-reference.html#format-${command}")
@MimeTypeCapability({ MimeTypes.APPLICATION_X_NIF_TURTLE })
@TypeCapability(outputs = { "de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Heading",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token",
"de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Lemma",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Stem",
"de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity" })
@MimeTypeCapability({MimeTypes.APPLICATION_X_NIF_TURTLE})
@TypeCapability(
outputs = {
"de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Heading",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token",
"de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Lemma",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Stem",
"de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity" })
public class NifReader
extends JCasResourceCollectionReader_ImplBase
{
Expand All @@ -80,32 +82,35 @@ public class NifReader
* Enable/disable type mapping.
*/
public static final String PARAM_MAPPING_ENABLED = ComponentParameters.PARAM_MAPPING_ENABLED;
@ConfigurationParameter(name = PARAM_MAPPING_ENABLED, mandatory = true, defaultValue = ComponentParameters.DEFAULT_MAPPING_ENABLED)
@ConfigurationParameter(name = PARAM_MAPPING_ENABLED, mandatory = true, defaultValue =
ComponentParameters.DEFAULT_MAPPING_ENABLED)
protected boolean mappingEnabled;

/**
* Load the part-of-speech tag to UIMA type mapping from this location instead of locating the
* mapping automatically.
* Load the part-of-speech tag to UIMA type mapping from this location instead of locating
* the mapping automatically.
*/
public static final String PARAM_POS_MAPPING_LOCATION = ComponentParameters.PARAM_POS_MAPPING_LOCATION;
public static final String PARAM_POS_MAPPING_LOCATION =
ComponentParameters.PARAM_POS_MAPPING_LOCATION;
@ConfigurationParameter(name = PARAM_POS_MAPPING_LOCATION, mandatory = false)
private String posMappingLocation;

private MappingProvider posMappingProvider;

private Resource res;
private Model model;
private StmtIterator contextIterator;
private int inFileCount;

@Override
public void initialize(UimaContext aContext) throws ResourceInitializationException
public void initialize(UimaContext aContext)
throws ResourceInitializationException
{
super.initialize(aContext);

posMappingProvider = createPosMappingProvider(this, posMappingLocation, posTagset,
getLanguage());

// Seek first article
try {
step();
Expand All @@ -114,7 +119,7 @@ public void initialize(UimaContext aContext) throws ResourceInitializationExcept
throw new ResourceInitializationException(e);
}
}

@Override
public void getNext(JCas aJCas) throws IOException, CollectionException
{
Expand All @@ -141,28 +146,29 @@ public void getNext(JCas aJCas) throws IOException, CollectionException
inFileCount++;
step();
}

private void closeAll()
{
res = null;
contextIterator = null;
}

@Override
public void destroy()
{
closeAll();
super.destroy();
}

@Override
public boolean hasNext() throws IOException, CollectionException
public boolean hasNext()
throws IOException, CollectionException
{
// If there is still an iterator, then there is still data. This requires that we call
// step() already during initialization.
return contextIterator != null;
}

/**
* Seek article in file. Stop once article element has been found without reading it.
*/
Expand All @@ -182,19 +188,19 @@ private void step() throws IOException
RDFDataMgr.read(model, is, RDFLanguages.filenameToLang(
CompressionUtils.stripCompressionExtension(res.getLocation())));
}
contextIterator = model.listStatements(null, RDF.type,
contextIterator = model.listStatements(null, RDF.type,
model.createResource(NIF.TYPE_CONTEXT));
}
else {
// No more files to read
return;
}
}

if (contextIterator.hasNext()) {
return;
}

// End of file reached
closeAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dkpro.core.io.nif;
*/package org.dkpro.core.io.nif;

import java.io.OutputStream;

Expand All @@ -41,43 +40,46 @@
/**
* Writer for the NLP Interchange Format (NIF).
*
* @see <a href="http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core/nif-core.html">NIF
* 2.0 Core Ontology</a>
* @see <a href="http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core/nif-core.html">NIF 2.0 Core Ontology</a>
*/
@ResourceMetaData(name = "NLP Interchange Format (NIF) Writer")
@DocumentationResource("${docbase}/format-reference.html#format-${command}")
@MimeTypeCapability({ MimeTypes.APPLICATION_X_NIF_TURTLE })
@TypeCapability(inputs = { "de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Heading",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token",
"de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Lemma",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Stem",
"de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity" })
@MimeTypeCapability({MimeTypes.APPLICATION_X_NIF_TURTLE})
@TypeCapability(
inputs = {
"de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Heading",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Paragraph",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token",
"de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Lemma",
"de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Stem",
"de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity" })
public class NifWriter
extends JCasFileWriter_ImplBase
{
/**
* Specify the suffix of output files. Default value <code>.ttl</code>. The file format will be
* chosen depending on the file suffice.
* chosen depending on the file suffice.
*
* @see RDFLanguages
*/
public static final String PARAM_FILENAME_EXTENSION = ComponentParameters.PARAM_FILENAME_EXTENSION;
public static final String PARAM_FILENAME_EXTENSION =
ComponentParameters.PARAM_FILENAME_EXTENSION;
@ConfigurationParameter(name = PARAM_FILENAME_EXTENSION, mandatory = true, defaultValue = ".ttl")
private String filenameSuffix;

@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException
public void process(JCas aJCas)
throws AnalysisEngineProcessException
{
OntModel model = ModelFactory.createOntologyModel();
model.setNsPrefix(NIF.PREFIX_NIF, NIF.NS_NIF);
model.setNsPrefix(ITS.PREFIX_ITS, ITS.NS_ITS);

DKPro2Nif.convert(aJCas, model);

try (OutputStream docOS = getOutputStream(aJCas, filenameSuffix)) {
RDFDataMgr.write(docOS, model.getBaseModel(),
RDFLanguages.fileExtToLang(filenameSuffix));
Expand Down
Loading

0 comments on commit 683723b

Please sign in to comment.