Skip to content

Commit

Permalink
#2696 - Document-level recommendations
Browse files Browse the repository at this point in the history
- Enable rejecting document-level annotations
- Switch OpenNLP module to auto-configuration
- Use records instead of model classes for some wicket models
  • Loading branch information
reckart committed Dec 23, 2023
1 parent f5ce849 commit 537d1b5
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ public Optional<Delta<SpanSuggestion>> generateNextSuggestion(String aSessionOwn
var pref = recommendationService.getPreferences(aDataOwner,
alState.getLayer().getProject());
var nextSuggestion = alState.getStrategy().generateNextSuggestion(pref, suggestionGroups);
assert nextSuggestion.get().getFirst().isVisible() : "Generated suggestion must be visible";
assert !nextSuggestion.isPresent() || nextSuggestion.get().getFirst()
.isVisible() : "Generated suggestion must be visible";
return nextSuggestion;
}

Expand Down Expand Up @@ -214,8 +215,8 @@ public void acceptSpanSuggestion(SourceDocument aDocument, User aDataOwner,
aSuggestion, suggestionWithUserSelectedLabel, AL_SIDEBAR);
}
else {
recommendationService.acceptSuggestion(sessionOwner, aDocument, dataOwner, cas, suggestionWithUserSelectedLabel,
AL_SIDEBAR);
recommendationService.acceptSuggestion(sessionOwner, aDocument, dataOwner, cas,
suggestionWithUserSelectedLabel, AL_SIDEBAR);
}

// Save CAS after annotation has been created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.apache.uima.cas.CAS;
import org.apache.wicket.model.IModel;
import org.springframework.stereotype.Component;

import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature;
import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer;
Expand All @@ -32,7 +31,6 @@
import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngineFactoryImplBase;
import de.tudarmstadt.ukp.inception.ui.core.docanno.layer.DocumentMetadataLayerSupport;

@Component
public class OpenNlpDoccatMetadataRecommenderFactory
extends RecommendationEngineFactoryImplBase<OpenNlpDoccatRecommenderTraits>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import org.apache.uima.cas.CAS;
import org.apache.wicket.model.IModel;
import org.springframework.stereotype.Component;

import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature;
import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer;
Expand All @@ -34,7 +33,6 @@
import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngine;
import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngineFactoryImplBase;

@Component
public class OpenNlpDoccatRecommenderFactory
extends RecommendationEngineFactoryImplBase<OpenNlpDoccatRecommenderTraits>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Licensed to the Technische Universität Darmstadt under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The Technische Universität Darmstadt
* licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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 de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat.OpenNlpDoccatMetadataRecommenderFactory;
import de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat.OpenNlpDoccatRecommenderFactory;
import de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.ner.OpenNlpNerRecommenderFactory;
import de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.pos.OpenNlpPosRecommenderFactory;
import de.tudarmstadt.ukp.inception.schema.api.AnnotationSchemaService;

@Configuration
public class OpenNlpRecommenderAutoConfiguration
{
@Bean
public OpenNlpDoccatRecommenderFactory openNlpDoccatRecommenderFactory()
{
return new OpenNlpDoccatRecommenderFactory();
}

@Bean
@ConditionalOnProperty(prefix = "documentmetadata", name = "enabled", havingValue = "true", matchIfMissing = true)
public OpenNlpDoccatMetadataRecommenderFactory openNlpDoccatMetadataRecommenderFactory(
AnnotationSchemaService aSchemaService)
{
return new OpenNlpDoccatMetadataRecommenderFactory();
}

@Bean
public OpenNlpNerRecommenderFactory openNlpNerRecommenderFactory()
{
return new OpenNlpNerRecommenderFactory();
}

@Bean
public OpenNlpPosRecommenderFactory openNlpPosRecommenderFactory()
{
return new OpenNlpPosRecommenderFactory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
import static java.util.Arrays.asList;

import org.apache.uima.cas.CAS;
import org.springframework.stereotype.Component;

import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature;
import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer;
import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender;
import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngine;
import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngineFactoryImplBase;

@Component
public class OpenNlpNerRecommenderFactory
extends RecommendationEngineFactoryImplBase<OpenNlpNerRecommenderTraits>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import org.apache.uima.cas.CAS;
import org.apache.wicket.model.IModel;
import org.springframework.stereotype.Component;

import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature;
import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer;
Expand All @@ -35,7 +34,6 @@
import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngine;
import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngineFactoryImplBase;

@Component
public class OpenNlpPosRecommenderFactory
extends RecommendationEngineFactoryImplBase<OpenNlpPosRecommenderTraits>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.tudarmstadt.ukp.inception.recommendation.imls.opennlp.doccat.config.OpenNlpRecommenderAutoConfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>

<div class="d-flex flex-grow-1 flex-column">
<div class="d-flex">
<div class="d-flex" wicket:enclosure="annotation">
<div class="flex-grow-1 my-1 mx-2 position-relative overflow-hidden">
<div class="float-end">
<div class="btn-group mb-0 ms-1 bg-body" role="group">
Expand Down
Loading

0 comments on commit 537d1b5

Please sign in to comment.