diff --git a/inception/inception-dependencies/pom.xml b/inception/inception-dependencies/pom.xml index 7a2bec87a49..4334b968e43 100644 --- a/inception/inception-dependencies/pom.xml +++ b/inception/inception-dependencies/pom.xml @@ -1153,18 +1153,6 @@ 6.7.0.202309050840-r - - org.webjars - c3 - 0.6.6 - - - - org.webjars - d3js - 5.5.0 - - org.webjars.bowergithub.xbsoftware enjoyhint diff --git a/inception/inception-recommendation/pom.xml b/inception/inception-recommendation/pom.xml index 49d8ddc47e3..ed6156a6ba0 100644 --- a/inception/inception-recommendation/pom.xml +++ b/inception/inception-recommendation/pom.xml @@ -247,18 +247,6 @@ org.wicketstuff wicketstuff-annotationeventdispatcher - - de.agilecoders.wicket.webjars - wicket-webjars - - - org.webjars - c3 - - - org.webjars - d3js - @@ -385,14 +373,6 @@ org.springframework:spring-websocket - - - org.webjars:d3js - org.webjars:c3 - diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/Chart.js b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/Chart.js deleted file mode 100644 index bdbfd0c3d05..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/Chart.js +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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. - */ -function updateLearningCurveDiagram(selector, data) { - var e = c3.generate({ - bindto: selector, - size : { height: 200 }, - legend: { show: false }, - data: { - empty: { label: { text: "No Data Available" } }, - json: data, - x : 'run', - axes: { - score: 'y', - trainSize: 'y2' - }, - keys: { - x: 'run', - value: ['score', 'trainSize'] - }, - names: { - score: 'Score', - trainSize: 'Training instances' - } - }, - axis: { - x: { - type: "category", - tick: { format: function(a) { return "#" + (a+1); } }, - label: 'Evaluation run', - }, - y: { - min: 0, - //to round off the decimal points of the y-axis values to 4 if it is a decimal number. - tick: { format: function(a) { return Math.round(1e4 * a) / 1e4; } }, - label: 'Score', - }, - y2: { - show: true, - label: 'Training instances', - min: 0 - } - } - }); -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartJsReference.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartJsReference.java deleted file mode 100644 index 06ad9d9064d..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartJsReference.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.chart; - -import org.apache.wicket.request.resource.JavaScriptResourceReference; - -public class ChartJsReference - extends JavaScriptResourceReference -{ - private static final long serialVersionUID = 1L; - - private static final ChartJsReference INSTANCE = new ChartJsReference(); - - /** - * Gets the instance of the resource reference - * - * @return the single instance of the resource reference - */ - public static ChartJsReference get() - { - return INSTANCE; - } - - /** - * Private constructor - */ - private ChartJsReference() - { - super(ChartJsReference.class, "Chart.js"); - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartPanel.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartPanel.html deleted file mode 100644 index b2c5a3d3dc4..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartPanel.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - -
-
- - diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartPanel.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartPanel.java deleted file mode 100644 index 87d529d8838..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/chart/ChartPanel.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * 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.chart; - -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; -import static de.tudarmstadt.ukp.clarin.webanno.support.JSONUtil.toInterpretableJsonString; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.wicket.behavior.AbstractAjaxBehavior; -import org.apache.wicket.markup.head.CssHeaderItem; -import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.head.JavaScriptContentHeaderItem; -import org.apache.wicket.markup.head.JavaScriptHeaderItem; -import org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.handler.TextRequestHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.annotation.JsonAutoDetect; - -import de.agilecoders.wicket.webjars.request.resource.WebjarsCssResourceReference; -import de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference; -import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult; -import de.tudarmstadt.ukp.inception.recommendation.model.RecommenderEvaluationScoreMetricEnum; - -public class ChartPanel - extends Panel -{ - private static final long serialVersionUID = -3849226240909011148L; - - private static final Logger LOG = LoggerFactory.getLogger(ChartPanel.class); - - private static final String MID_CHART_CONTAINER = "chart"; - - private final IModel metric; - private final WebMarkupContainer chart; - private final ChartAjaxBejavior chartAjaxBejavior; - - public ChartPanel(String aId, IModel> aModel, - IModel aMetric) - { - super(aId, aModel); - - metric = aMetric; - - chart = new WebMarkupContainer(MID_CHART_CONTAINER); - add(chart); - - chartAjaxBejavior = new ChartAjaxBejavior(); - add(chartAjaxBejavior); - } - - @SuppressWarnings("unchecked") - public List getModelObject() - { - return (List) getDefaultModelObject(); - } - - @Override - public void renderHead(IHeaderResponse aResponse) - { - super.renderHead(aResponse); - - // import Js - aResponse.render(JavaScriptHeaderItem - .forReference(new WebjarsJavaScriptResourceReference("c3/current/c3.js"))); - aResponse.render(JavaScriptHeaderItem - .forReference(new WebjarsJavaScriptResourceReference("d3js/current/d3.js"))); - - // import Css - aResponse.render( - CssHeaderItem.forReference(new WebjarsCssResourceReference("c3/current/c3.css"))); - - aResponse.render(JavaScriptReferenceHeaderItem.forReference( - getApplication().getJavaScriptLibrarySettings().getJQueryReference())); - - aResponse.render(JavaScriptHeaderItem.forReference(ChartJsReference.get())); - - String chartTriggerJavascript = String.join("\n", // - "$(document).ready(function(){", // - " $.ajax({", // - " url:'" + chartAjaxBejavior.getCallbackUrl().toString() + "',", // - " type:'post',", // - " contentType:'application/json',", // - " dataType:'json',", // - " success : function(result){", // - " updateLearningCurveDiagram('#" + chart.getMarkupId() + "', result)", // - " }", // - " })", // - "})"); - - aResponse.render(JavaScriptContentHeaderItem.forScript(chartTriggerJavascript, null)); - } - - private List convert(List aEvaluationResults) - { - List data = new ArrayList<>(); - int run = 0; - for (EvaluationResult evaluationResult : aEvaluationResults) { - run++; - - if (evaluationResult.isEvaluationSkipped()) { - continue; - } - - double score; - switch (metric.getObject()) { - case Accuracy: - score = evaluationResult.computeAccuracyScore(); - break; - case Precision: - score = evaluationResult.computePrecisionScore(); - break; - case Recall: - score = evaluationResult.computeRecallScore(); - break; - case F1: - score = evaluationResult.computeF1Score(); - break; - default: - score = evaluationResult.computeAccuracyScore(); - } - - data.add(new Datapoint(run, evaluationResult.getTrainingSetSize(), - evaluationResult.getTrainDataRatio(), score)); - } - - return data; - } - - @SuppressWarnings("unused") - @JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE) - private final static class Datapoint - { - final int run; - final int trainSize; - final double trainRatio; - final double score; - - public Datapoint(int aRun, int aTrainSize, double aTrainRatio, double aScore) - { - run = aRun; - trainSize = aTrainSize; - trainRatio = aTrainRatio; - score = aScore; - } - } - - private final class ChartAjaxBejavior - extends AbstractAjaxBehavior - { - private static final long serialVersionUID = 1L; - - @Override - public void onRequest() - { - try { - String json = toInterpretableJsonString(convert(getModelObject())); - RequestCycle.get().scheduleRequestHandlerAfterCurrent( - new TextRequestHandler("application/json", "UTF-8", json)); - } - catch (IOException e) { - LOG.error(e.toString(), e); - } - } - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/config/RecommenderServiceAutoConfiguration.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/config/RecommenderServiceAutoConfiguration.java index e5943e20646..97e370a68c3 100644 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/config/RecommenderServiceAutoConfiguration.java +++ b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/config/RecommenderServiceAutoConfiguration.java @@ -42,7 +42,6 @@ import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; import de.tudarmstadt.ukp.inception.recommendation.api.RecommenderFactoryRegistry; import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngineFactory; -import de.tudarmstadt.ukp.inception.recommendation.evaluation.EvaluationSimulationPageMenuItem; import de.tudarmstadt.ukp.inception.recommendation.exporter.LearningRecordExporter; import de.tudarmstadt.ukp.inception.recommendation.exporter.RecommenderExporter; import de.tudarmstadt.ukp.inception.recommendation.footer.RecommendationEventFooterItem; @@ -86,15 +85,6 @@ public RecommendationService recommendationService(PreferencesService aPreferenc aProjectService, entityManager, aApplicationEventPublisher); } - @ConditionalOnWebApplication - @ConditionalOnProperty(prefix = "recommender.evaluation-page", // - name = "enabled", havingValue = "true", matchIfMissing = true) - @Bean - public EvaluationSimulationPageMenuItem evaluationSimulationPageMenuItem() - { - return new EvaluationSimulationPageMenuItem(); - } - @Bean public RecommenderExporter recommenderExporter(AnnotationSchemaService aAnnotationService, RecommendationService aRecommendationService) diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.html deleted file mode 100644 index 82a2d67a7d8..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - -
-
-
-
-
-
-
-
-
-
- - - diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.java deleted file mode 100644 index c1cdf9ec31c..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2019 - * Ubiquitous Knowledge Processing (UKP) Lab - * Technische Universität Darmstadt - * - * 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.evaluation; - -import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.MANAGER; -import static de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaBehavior.visibleWhenModelIsNotNull; -import static de.tudarmstadt.ukp.clarin.webanno.ui.core.page.ProjectPageBase.NS_PROJECT; -import static de.tudarmstadt.ukp.clarin.webanno.ui.core.page.ProjectPageBase.PAGE_PARAM_PROJECT; - -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.spring.injection.annot.SpringBean; -import org.wicketstuff.annotation.mount.MountPath; - -import de.tudarmstadt.ukp.clarin.webanno.api.ProjectService; -import de.tudarmstadt.ukp.clarin.webanno.model.Project; -import de.tudarmstadt.ukp.clarin.webanno.security.UserDao; -import de.tudarmstadt.ukp.clarin.webanno.ui.core.page.ProjectPageBase; -import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; -import de.tudarmstadt.ukp.inception.recommendation.project.RecommenderListPanel; - -@MountPath(NS_PROJECT + "/${" + PAGE_PARAM_PROJECT + "}/simulation") -public class EvaluationSimulationPage - extends ProjectPageBase -{ - private static final long serialVersionUID = 3042218455285633439L; - - private IModel selectedRecommenderModel; - private @SpringBean ProjectService projectService; - private @SpringBean UserDao userRepository; - - private static final String MID_EVALUATION_SIMULATION_CONTAINER = "evaluation-simulation-container"; - private static final String MID_RECOMMENDER_LIST = "recommenderList"; - private static final String MID_RECOMMENDER_VIEW = "recommenderView"; - - public EvaluationSimulationPage(final PageParameters aPageParameters) - { - super(aPageParameters); - - Project project = getProject(); - - requireProjectRole(userRepository.getCurrentUser(), MANAGER); - - selectedRecommenderModel = Model.of(); - - SimulationLearningCurvePanel evaluationSimulationPanel = new SimulationLearningCurvePanel( - MID_EVALUATION_SIMULATION_CONTAINER, project, selectedRecommenderModel); - add(evaluationSimulationPanel); - - RecommenderViewPanel recommenderViewPanel = new RecommenderViewPanel(MID_RECOMMENDER_VIEW, - selectedRecommenderModel); - recommenderViewPanel.setOutputMarkupPlaceholderTag(true); - recommenderViewPanel.add(visibleWhenModelIsNotNull(recommenderViewPanel)); - add(recommenderViewPanel); - - RecommenderListPanel recommenderListPanel = new RecommenderListPanel(MID_RECOMMENDER_LIST, - Model.of(project), selectedRecommenderModel, false); - recommenderListPanel.setChangeAction(_target -> { - evaluationSimulationPanel.recommenderChanged(); - _target.add(recommenderViewPanel); - }); - add(recommenderListPanel); - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.properties b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.properties deleted file mode 100644 index ad24199dbd1..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPage.properties +++ /dev/null @@ -1,16 +0,0 @@ -# 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. -page.title=Evaluation diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPageMenuItem.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPageMenuItem.java deleted file mode 100644 index a8bfaae83dd..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/EvaluationSimulationPageMenuItem.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.evaluation; - -import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.MANAGER; - -import org.apache.wicket.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.annotation.Order; - -import de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType; -import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesome5IconType; -import de.tudarmstadt.ukp.clarin.webanno.api.ProjectService; -import de.tudarmstadt.ukp.clarin.webanno.model.Project; -import de.tudarmstadt.ukp.clarin.webanno.security.UserDao; -import de.tudarmstadt.ukp.clarin.webanno.security.model.User; -import de.tudarmstadt.ukp.clarin.webanno.ui.core.menu.ProjectMenuItem; -import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; -import de.tudarmstadt.ukp.inception.recommendation.config.RecommenderServiceAutoConfiguration; -import wicket.contrib.input.events.key.KeyType; - -/** - *

- * This class is exposed as a Spring Component via - * {@link RecommenderServiceAutoConfiguration#evaluationSimulationPageMenuItem()}. - *

- */ -@Order(300) -public class EvaluationSimulationPageMenuItem - implements ProjectMenuItem -{ - private @Autowired UserDao userRepo; - private @Autowired ProjectService projectService; - private @Autowired RecommendationService recommenderService; - - @Override - public String getPath() - { - return "/evaluation"; - } - - @Override - public IconType getIcon() - { - return FontAwesome5IconType.chart_line_s; - } - - @Override - public String getLabel() - { - return "Evaluation"; - } - - @Override - public boolean applies(Project aProject) - { - // Visible if the current user is a curator - User user = userRepo.getCurrentUser(); - if (!(projectService.hasRole(user, aProject, MANAGER))) { - return false; - } - - return !recommenderService.listRecommenders(aProject).isEmpty(); - } - - @Override - public Class getPageClass() - { - return EvaluationSimulationPage.class; - } - - @Override - public KeyType[] shortcut() - { - return new KeyType[] { KeyType.Alt, KeyType.s }; - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.html deleted file mode 100644 index 5ec6631884d..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - -
-
- -
-
-
- -
- -
-
- -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- - diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.java deleted file mode 100644 index adff0fdd90c..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.evaluation; - -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.ComponentPropertyModel; -import org.apache.wicket.model.CompoundPropertyModel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.spring.injection.annot.SpringBean; - -import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationFeature; -import de.tudarmstadt.ukp.clarin.webanno.model.AnnotationLayer; -import de.tudarmstadt.ukp.inception.recommendation.api.RecommenderFactoryRegistry; -import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; -import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationEngineFactory; - -public class RecommenderViewPanel - extends Panel -{ - private static final long serialVersionUID = -5278078988218713188L; - - private static final String MID_FORM = "form"; - private static final String MID_NAME = "name"; - private static final String MID_FEATURE = "feature"; - private static final String MID_LAYER = "layer"; - private static final String MID_TOOL = "tool"; - - private @SpringBean RecommenderFactoryRegistry recommenderRegistry; - - public RecommenderViewPanel(String aId, IModel aRecommender) - { - super(aId, aRecommender); - - Form form = new Form<>(MID_FORM, CompoundPropertyModel.of(aRecommender)); - add(form); - - form.add(new TextField<>(MID_NAME, String.class)); - form.add(new TextField<>(MID_TOOL, LoadableDetachableModel.of(this::getToolName), - String.class)); - form.add(new TextField(MID_FEATURE, - new ComponentPropertyModel<>("feature.uiName"))); - form.add(new TextField(MID_LAYER, - new ComponentPropertyModel<>("layer.uiName"))); - } - - public Recommender getModelObject() - { - return (Recommender) getDefaultModelObject(); - } - - private String getToolName() - { - if (getModelObject() == null) { - return null; - } - - RecommendationEngineFactory factory = recommenderRegistry - .getFactory(getModelObject().getTool()); - if (factory == null) { - return "[UNSUPPORTED]"; - } - - return factory.getName(); - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.properties b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.properties deleted file mode 100644 index 2d5ce95f857..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/RecommenderViewPanel.properties +++ /dev/null @@ -1,21 +0,0 @@ -# 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. - -details=Details -name=Name -layer=Layer -tool=Tool -feature=Feature diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.html deleted file mode 100644 index fb54df69264..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - -
-
- -
-
-
- -
- -
-
-
-
- -
-
- diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.java deleted file mode 100644 index da824d6be60..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * 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.evaluation; - -import static de.tudarmstadt.ukp.clarin.webanno.api.CasUpgradeMode.AUTO_CAS_UPGRADE; -import static de.tudarmstadt.ukp.clarin.webanno.api.casstorage.CasAccessMode.SHARED_READ_ONLY_ACCESS; -import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.ANNOTATOR; -import static de.tudarmstadt.ukp.clarin.webanno.support.WebAnnoConst.CURATION_USER; -import static de.tudarmstadt.ukp.clarin.webanno.support.WebAnnoConst.INITIAL_CAS_PSEUDO_USER; -import static de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaBehavior.visibleWhen; -import static de.tudarmstadt.ukp.inception.recommendation.model.RecommenderEvaluationScoreMetricEnum.Accuracy; -import static java.util.Collections.emptyList; -import static org.apache.commons.collections4.CollectionUtils.isNotEmpty; -import static org.apache.commons.lang3.exception.ExceptionUtils.getRootCauseMessage; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - -import org.apache.uima.cas.CAS; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.feedback.IFeedback; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.util.ListModel; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.spring.injection.annot.SpringBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import de.tudarmstadt.ukp.clarin.webanno.api.DocumentService; -import de.tudarmstadt.ukp.clarin.webanno.api.ProjectService; -import de.tudarmstadt.ukp.clarin.webanno.model.Project; -import de.tudarmstadt.ukp.clarin.webanno.model.SourceDocument; -import de.tudarmstadt.ukp.clarin.webanno.security.UserDao; -import de.tudarmstadt.ukp.clarin.webanno.security.model.User; -import de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaAjaxButton; -import de.tudarmstadt.ukp.clarin.webanno.support.lambda.LambdaChoiceRenderer; -import de.tudarmstadt.ukp.inception.recommendation.api.RecommenderFactoryRegistry; -import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.EvaluationResult; -import de.tudarmstadt.ukp.inception.recommendation.api.evaluation.IncrementalSplitter; -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.RecommendationEngineFactory; -import de.tudarmstadt.ukp.inception.recommendation.api.recommender.RecommendationException; -import de.tudarmstadt.ukp.inception.recommendation.chart.ChartPanel; -import de.tudarmstadt.ukp.inception.recommendation.model.RecommenderEvaluationScoreMetricEnum; - -public class SimulationLearningCurvePanel - extends Panel -{ - private static final long serialVersionUID = 4306746527837380863L; - - private static final String MID_CHART_CONTAINER = "chart-container"; - private static final String MID_SIMULATION_START_BUTTON = "simulation-start-button"; - private static final String MID_FORM = "form"; - - private static final double TRAIN_PERCENTAGE = 0.8; - private static final int STEPS = 10; - private static final int LOW_SAMPLE_THRESHOLD = 10; - - private static final Logger LOG = LoggerFactory.getLogger(SimulationLearningCurvePanel.class); - - private static final List DROPDOWN_VALUES = Arrays - .asList(RecommenderEvaluationScoreMetricEnum.values()); - - private @SpringBean DocumentService documentService; - private @SpringBean ProjectService projectService; - private @SpringBean UserDao userDao; - private @SpringBean RecommenderFactoryRegistry recommenderRegistry; - - private final Project project; - private final IModel recommender; - private final IModel user; - private final IModel metric; - - private final DropDownChoice metricChoice; - private final DropDownChoice annotatorChoice; - private final ChartPanel chartPanel; - - private final IModel> evaluationResults; - - public SimulationLearningCurvePanel(String aId, Project aProject, - IModel aRecommender) - { - super(aId, aRecommender); - - project = aProject; - recommender = aRecommender; - evaluationResults = new ListModel(emptyList()); - metric = new Model(Accuracy); - - Form form = new Form<>(MID_FORM); - add(form); - - chartPanel = new ChartPanel(MID_CHART_CONTAINER, evaluationResults, metric); - chartPanel.setOutputMarkupPlaceholderTag(true); - chartPanel.add(visibleWhen(() -> isNotEmpty(chartPanel.getModelObject()))); - form.add(chartPanel); - - metricChoice = new DropDownChoice("metric", metric, - new ListModel(DROPDOWN_VALUES)); - metricChoice.setOutputMarkupId(true); - form.add(metricChoice); - - IModel> annotatorChoiceModel = LoadableDetachableModel - .of(this::getSelectableAnnotators); - user = Model.of(annotatorChoiceModel.getObject().get(0)); - annotatorChoice = new DropDownChoice("annotator", user, annotatorChoiceModel); - annotatorChoice.setChoiceRenderer(new LambdaChoiceRenderer<>(User::getUiName)); - annotatorChoice.setOutputMarkupId(true); - form.add(annotatorChoice); - - // clicking the start button the annotated documents are evaluated and the learning curve - // for the selected recommender is plotted in the hCart Panel - form.add(new LambdaAjaxButton<>(MID_SIMULATION_START_BUTTON, (_target, _form) -> { - recommenderChanged(); - evaluate(); - _target.add(chartPanel); - })); - } - - private List getSelectableAnnotators() - { - List list = new ArrayList<>(); - list.add(new User(INITIAL_CAS_PSEUDO_USER, "")); - list.add(new User(CURATION_USER, "")); - list.addAll(projectService.listProjectUsersWithPermissions(project, ANNOTATOR)); - return list; - } - - /** - * evaluates the selected recommender with the help of the annotated documents in the project. - */ - private void evaluate() - { - if (evaluationResults.getObject() != null) { - return; - } - - Optional target = RequestCycle.get().find(AjaxRequestTarget.class); - - // there must be some recommender selected by the user on the UI - if (recommender.getObject() == null || recommender.getObject().getTool() == null) { - error("Please select a recommender from the list"); - target.ifPresent(_target -> _target.addChildren(getPage(), IFeedback.class)); - return; - } - - List casList = new ArrayList<>(); - try { - for (SourceDocument doc : documentService.listSourceDocuments(project)) { - if (INITIAL_CAS_PSEUDO_USER.equals(user.getObject().getUsername())) { - casList.add(documentService.createOrReadInitialCas(doc, AUTO_CAS_UPGRADE, - SHARED_READ_ONLY_ACCESS)); - } - else { - if (documentService.existsAnnotationDocument(doc, user.getObject())) { - casList.add(documentService.readAnnotationCas(doc, - user.getObject().getUsername(), AUTO_CAS_UPGRADE, - SHARED_READ_ONLY_ACCESS)); - } - } - } - } - catch (IOException e) { - error("Unable to load chart data: " + getRootCauseMessage(e)); - target.ifPresent(_target -> _target.addChildren(getPage(), IFeedback.class)); - LOG.error("Unable to render chart", e); - return; - } - - @SuppressWarnings("rawtypes") - RecommendationEngineFactory factory = recommenderRegistry - .getFactory(recommender.getObject().getTool()); - RecommendationEngine recommenderEngine = factory.build(recommender.getObject()); - - if (recommenderEngine == null) { - error("Unknown recommender type selected: [" + recommender.getObject().getTool() + "]"); - target.ifPresent(_target -> _target.addChildren(getPage(), IFeedback.class)); - return; - } - - int estimatedDatasetSize = recommenderEngine.estimateSampleCount(casList); - if (estimatedDatasetSize < 0) { - error("Evaluation is not supported for the selected recommender."); - target.ifPresent(_target -> _target.addChildren(getPage(), IFeedback.class)); - return; - } - - int incrementSize = (int) Math.ceil((estimatedDatasetSize * TRAIN_PERCENTAGE)) / STEPS; - if (incrementSize <= 0) { - error("Not enough training data: " + estimatedDatasetSize + " samples"); - target.ifPresent(_target -> _target.addChildren(getPage(), IFeedback.class)); - return; - } - - IncrementalSplitter splitStrategy = new IncrementalSplitter(TRAIN_PERCENTAGE, incrementSize, - LOW_SAMPLE_THRESHOLD); - - evaluationResults.setObject(new ArrayList<>()); - - // Create a list of comma separated string of scores from every iteration of evaluation. - while (splitStrategy.hasNext()) { - splitStrategy.next(); - - try { - EvaluationResult evaluationResult = recommenderEngine.evaluate(casList, - splitStrategy); - - if (!evaluationResult.isEvaluationSkipped()) { - evaluationResults.getObject().add(evaluationResult); - } - } - catch (RecommendationException e) { - error("Unable to run simulation: " + getRootCauseMessage(e)); - target.ifPresent(_target -> _target.addChildren(getPage(), IFeedback.class)); - LOG.error("Unable to run simulation", e); - continue; - } - } - } - - public void recommenderChanged() - { - evaluationResults.setObject(null); - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.properties b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.properties deleted file mode 100644 index 7a66901cda5..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/evaluation/SimulationLearningCurvePanel.properties +++ /dev/null @@ -1,19 +0,0 @@ -# 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. -simulation=Evaluation Simulation -start=Start -metric=Select Evaluation Metric -annotator=Annotator \ No newline at end of file diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/model/LearningCurve.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/model/LearningCurve.java deleted file mode 100644 index 6dc9e478179..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/model/LearningCurve.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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.model; - -import java.io.Serializable; -import java.util.Map; - -public class LearningCurve - implements Serializable -{ - private static final long serialVersionUID = 6542281189066805238L; - - private Map curveData; - private String xAxis; - - public Map getCurveData() - { - return curveData; - } - - public void setCurveData(Map aCurveData) - { - curveData = aCurveData; - } - - public String getXaxis() - { - return xAxis; - } - - public void setXaxis(String aXAxis) - { - this.xAxis = aXAxis; - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartJsReference.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartJsReference.java deleted file mode 100644 index 649db35a984..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartJsReference.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.sidebar.learningcurve; - -import org.apache.wicket.request.resource.JavaScriptResourceReference; - -/** - * @deprecated The current implementation of the learning curve panel has a memory leak in the - * browser code. It should be re-implemented. - */ -@Deprecated -public class ChartJsReference - extends JavaScriptResourceReference -{ - private static final long serialVersionUID = 1L; - - private static final ChartJsReference INSTANCE = new ChartJsReference(); - - /** - * Gets the instance of the resource reference - * - * @return the single instance of the resource reference - */ - public static ChartJsReference get() - { - return INSTANCE; - } - - /** - * Private constructor - */ - private ChartJsReference() - { - super(ChartJsReference.class, "chart.js"); - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartPanel.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartPanel.html deleted file mode 100644 index b2c5a3d3dc4..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartPanel.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - -
-
- - diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartPanel.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartPanel.java deleted file mode 100644 index fb1d5852e8a..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/ChartPanel.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * 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.sidebar.learningcurve; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.wicket.behavior.AbstractAjaxBehavior; -import org.apache.wicket.markup.head.CssHeaderItem; -import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.head.JavaScriptContentHeaderItem; -import org.apache.wicket.markup.head.JavaScriptHeaderItem; -import org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.handler.TextRequestHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import de.agilecoders.wicket.webjars.request.resource.WebjarsCssResourceReference; -import de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference; -import de.tudarmstadt.ukp.inception.recommendation.model.LearningCurve; - -/** - * @deprecated The current implementation of the learning curve panel has a memory leak in the - * browser code. It should be re-implemented. - */ -@Deprecated -public class ChartPanel - extends Panel -{ - private static final long serialVersionUID = -3849226240909011148L; - - private static final Logger LOG = LoggerFactory.getLogger(ChartPanel.class); - - private static final String MID_CHART_CONTAINER = "chart"; - private static final String OUTPUT_MARKUP_ID_CHART = "canvas"; - - private final WebMarkupContainer chart; - private final ChartAjaxBejavior chartAjaxBejavior; - - public ChartPanel(String aId, IModel aModel) - { - super(aId, aModel); - - chart = new WebMarkupContainer(MID_CHART_CONTAINER); - chart.setMarkupId(OUTPUT_MARKUP_ID_CHART); - add(chart); - - chartAjaxBejavior = new ChartAjaxBejavior(); - add(chartAjaxBejavior); - } - - public LearningCurve getModelObject() - { - return (LearningCurve) getDefaultModelObject(); - } - - @Override - public void renderHead(IHeaderResponse aResponse) - { - super.renderHead(aResponse); - - // import Js - aResponse.render(JavaScriptHeaderItem - .forReference(new WebjarsJavaScriptResourceReference("c3/current/c3.js"))); - aResponse.render(JavaScriptHeaderItem - .forReference(new WebjarsJavaScriptResourceReference("d3js/current/d3.js"))); - - // import Css - aResponse.render( - CssHeaderItem.forReference(new WebjarsCssResourceReference("c3/current/c3.css"))); - - aResponse.render(JavaScriptReferenceHeaderItem.forReference( - getApplication().getJavaScriptLibrarySettings().getJQueryReference())); - - aResponse.render(JavaScriptHeaderItem.forReference(ChartJsReference.get())); - - String chartTriggerJavascript = String.join("\n", // - "$(document).ready(function(){", // - " $.ajax({", // - " url:'" + chartAjaxBejavior.getCallbackUrl().toString() + "',", // - " type:'post',", // - " contentType:'application/json',", // - " dataType:'json',", // - " success : function(result){", // - " createLearningCurveDiagram(result)", // - " }", // - " })", // - "})"); - - aResponse.render(JavaScriptContentHeaderItem.forScript(chartTriggerJavascript, null)); - } - - private final class ChartAjaxBejavior - extends AbstractAjaxBehavior - { - private static final long serialVersionUID = 1L; - - @Override - public void onRequest() - { - RequestCycle requestCycle = RequestCycle.get(); - - LearningCurve learningCurve = getModelObject(); - - try { - String json = addLearningCurve(learningCurve); - - // return the chart data back to the UI with the JSON. JSON define te learning - // curves and the xaxis - requestCycle.scheduleRequestHandlerAfterCurrent( - new TextRequestHandler("application/json", "UTF-8", json)); - } - catch (JsonProcessingException e) { - LOG.error(e.toString(), e); - } - } - } - - public String addLearningCurve(LearningCurve aLearningCurve) throws JsonProcessingException - { - List> lines = new ArrayList<>(); - - // add xaxis to the list of lines - List asList = new ArrayList<>(); - asList.add("x"); - - // only add the x-axis if it is present (C3 Javascript Library will handle the "no-data" ) - if (aLearningCurve != null && aLearningCurve.getXaxis() != null - && !aLearningCurve.getXaxis().isEmpty()) { - asList.addAll(Arrays.asList(aLearningCurve.getXaxis().split(","))); - } - lines.add(asList); - - // only add the curve data if it is present. (C3 Javascript Library will handle the - // "no-data" ) - if (aLearningCurve != null && aLearningCurve.getCurveData() != null - && !aLearningCurve.getCurveData().isEmpty()) { - // there can be multiple learning curves. add them to te list of lines - for (String data : aLearningCurve.getCurveData().keySet()) { - List newLine = new ArrayList(); - newLine.add(data); - newLine.addAll(Arrays.asList(aLearningCurve.getCurveData().get(data).split(","))); - lines.add(newLine); - } - } - - ObjectMapper mapper = new ObjectMapper(); - String json = mapper.writeValueAsString(lines); - - return json; - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/DropDownEvent.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/DropDownEvent.java deleted file mode 100644 index f749e840689..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/DropDownEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.sidebar.learningcurve; - -import org.apache.wicket.ajax.AjaxRequestTarget; - -import de.tudarmstadt.ukp.inception.recommendation.model.RecommenderEvaluationScoreMetricEnum; - -/** - * @deprecated The current implementation of the learning curve panel has a memory leak in the - * browser code. It should be re-implemented. - */ -@Deprecated -public class DropDownEvent -{ - public RecommenderEvaluationScoreMetricEnum selectedValue; - public AjaxRequestTarget target; - - public RecommenderEvaluationScoreMetricEnum getSelectedValue() - { - return selectedValue; - } - - public void setSelectedValue(RecommenderEvaluationScoreMetricEnum selectedValue) - { - this.selectedValue = selectedValue; - } - - public AjaxRequestTarget getTarget() - { - return target; - } - - public void setTarget(AjaxRequestTarget target) - { - this.target = target; - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/LearningCurveChartPanel.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/LearningCurveChartPanel.html deleted file mode 100644 index 4cb0c6b6a0a..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/LearningCurveChartPanel.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - -
-
- -
-
-
-
-
-
-
- diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/LearningCurveChartPanel.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/LearningCurveChartPanel.java deleted file mode 100644 index 8db8fbcf50c..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/LearningCurveChartPanel.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * 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.sidebar.learningcurve; - -import static de.tudarmstadt.ukp.clarin.webanno.support.JSONUtil.fromJsonString; -import static org.apache.commons.lang3.StringUtils.substring; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MultiValuedMap; -import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.event.IEvent; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.LoadableDetachableModel; -import org.apache.wicket.spring.injection.annot.SpringBean; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.wicketstuff.event.annotation.OnEvent; - -import de.tudarmstadt.ukp.inception.log.EventRepository; -import de.tudarmstadt.ukp.inception.log.model.LoggedEvent; -import de.tudarmstadt.ukp.inception.recommendation.api.RecommendationService; -import de.tudarmstadt.ukp.inception.recommendation.api.model.Recommender; -import de.tudarmstadt.ukp.inception.recommendation.log.RecommenderEvaluationResultEventAdapter.Details; -import de.tudarmstadt.ukp.inception.recommendation.model.LearningCurve; -import de.tudarmstadt.ukp.inception.recommendation.model.RecommenderEvaluationScoreMetricEnum; -import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; -import de.tudarmstadt.ukp.inception.rendering.request.RenderRequestedEvent; - -/** - * @deprecated The current implementation of the learning curve panel has a memory leak in the - * browser code. It should be re-implemented. - */ -@Deprecated -public class LearningCurveChartPanel - extends Panel -{ - private static final long serialVersionUID = 4306746527837380863L; - - private static final String MID_CHART_CONTAINER = "chart-container"; - private static final String MID_DROPDOWN_PANEL = "dropdownPanel"; - - private static final int MAX_POINTS_TO_PLOT = 50; - private static final Logger LOG = LoggerFactory.getLogger(LearningCurveChartPanel.class); - - private @SpringBean EventRepository eventRepo; - private @SpringBean RecommendationService recommendationService; - - private final ChartPanel chartPanel; - private final IModel model; - public RecommenderEvaluationScoreMetricEnum selectedMetric; - - public LearningCurveChartPanel(String aId, IModel aModel) - { - super(aId, aModel); - model = aModel; - - setOutputMarkupId(true); - - // initially the chart is empty. passing empty model - chartPanel = new ChartPanel(MID_CHART_CONTAINER, - LoadableDetachableModel.of(this::renderChart)); - // chartPanel.add(visibleWhen(() -> chartPanel.getModelObject() != null)); - - chartPanel.setOutputMarkupId(true); - add(chartPanel); - - final Panel dropDownPanel = new MetricSelectDropDownPanel(MID_DROPDOWN_PANEL); - dropDownPanel.setOutputMarkupId(true); - add(dropDownPanel); - - selectedMetric = RecommenderEvaluationScoreMetricEnum.Accuracy; - } - - @Override - public void onEvent(IEvent event) - { - super.onEvent(event); - if (event.getPayload() instanceof DropDownEvent) { - DropDownEvent dEvent = (DropDownEvent) event.getPayload(); - - RecommenderEvaluationScoreMetricEnum aSelectedMetric = dEvent.getSelectedValue(); - AjaxRequestTarget target = dEvent.getTarget(); - - target.add(this); - - selectedMetric = aSelectedMetric; - LOG.debug("Option selected: " + aSelectedMetric); - - event.stop(); - } - } - - @OnEvent - public void onRenderRequested(RenderRequestedEvent aEvent) - { - LOG.trace("rendered annotation event"); - - aEvent.getRequestHandler().add(this); - } - - /** - * Returns chart data wrapped in LearningCurve - */ - private LearningCurve renderChart() - { - LOG.debug("SELECTED METRIC IS " + selectedMetric); - MultiValuedMap recommenderScoreMap = getLatestScores(); - - if (CollectionUtils.isEmpty(recommenderScoreMap.keys())) { - LOG.debug("Cannot plot the learning curve because there are no scores. Project: {}", - model.getObject().getProject()); - return null; - } - - Map curveData = new HashMap(); - LearningCurve learningCurve = new LearningCurve(); - - // iterate over recommenderScoreMap to create data - for (String recommenderName : recommenderScoreMap.keySet()) { - // extract the scores from the recommenderScoreMap. The format of data is a comma - // separated string of scores(each score is Double cast-able) to be. - // Example 2.3, 4.5 ,6, 5, 3, 9, - String data = recommenderScoreMap.get(recommenderName).stream().map(Object::toString) - .collect(Collectors.joining(", ")); - - curveData.put(recommenderName, data); - - learningCurve.setCurveData(curveData); - - // the Curve is not allowed to have more points as compared to MAX_POINTS_TO_PLOT. This - // is how many scores we have retrieved from the database - int[] intArray = IntStream.range(0, MAX_POINTS_TO_PLOT).map(i -> i).toArray(); - String xaxisValues = substring(Arrays.toString(intArray), 1, -1); - - learningCurve.setXaxis(xaxisValues); - } - - return learningCurve; - } - - /** - * @return a number of latest evaluation scores from the database and save it in the map - * corresponding to each recommender for which the scores have been logged in the - * database - */ - private MultiValuedMap getLatestScores() - { - // we want to plot RecommenderEvaluationResultEvent for the learning curve. The - // value of the event - String eventType = "RecommenderEvaluationResultEvent"; - - List loggedEvents = new ArrayList(); - - List listEnabledRecommenders = recommendationService - .listEnabledRecommenders(model.getObject().getProject()); - - if (listEnabledRecommenders.isEmpty()) { - LOG.warn("The project has no enabled recommender"); - } - - for (Recommender recommender : listEnabledRecommenders) { - List tempLoggedEvents = eventRepo.listLoggedEventsForRecommender( - model.getObject().getProject(), model.getObject().getUser().getUsername(), - eventType, MAX_POINTS_TO_PLOT, recommender.getId()); - - // we want to show the latest record on the right side of the graph - Collections.reverse(tempLoggedEvents); - - loggedEvents.addAll(tempLoggedEvents); - } - - if (CollectionUtils.isEmpty(loggedEvents)) { - return new ArrayListValuedHashMap(); - } - - MultiValuedMap recommenderScoreMap = new ArrayListValuedHashMap<>(); - - // iterate over the logged events to extract the scores and map it against its corresponding - // recommender. - for (LoggedEvent loggedEvent : loggedEvents) { - String detailJson = loggedEvent.getDetails(); - try { - Details detail = fromJsonString(Details.class, detailJson); - - // If the log is inconsistent and we do not have an ID for some reason, then we - // have to skip it - if (detail.recommenderId == null) { - continue; - } - - // do not include the scores from disabled recommenders - Optional recommenderIfActive = recommendationService - .getEnabledRecommender(detail.recommenderId); - if (!recommenderIfActive.isPresent()) { - continue; - } - - // sometimes score values NaN. Can result into error while rendering the graph on UI - double score; - - switch (selectedMetric) { - case Accuracy: - score = detail.accuracy; - break; - case Precision: - score = detail.precision; - break; - case Recall: - score = detail.recall; - break; - case F1: - score = detail.f1; - break; - default: - score = detail.accuracy; - } - - if (!Double.isFinite(score)) { - continue; - } - - // recommenderIfActive only has one member - recommenderScoreMap.put(recommenderIfActive.get().getName(), score); - } - catch (IOException e) { - LOG.error("Invalid logged Event detail. Skipping record with logged event id: " - + loggedEvent.getId(), e); - } - } - return recommenderScoreMap; - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/MetricSelectDropDownPanel.html b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/MetricSelectDropDownPanel.html deleted file mode 100644 index 24d9357fb6a..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/MetricSelectDropDownPanel.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - -
- - - -
-
- - \ No newline at end of file diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/MetricSelectDropDownPanel.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/MetricSelectDropDownPanel.java deleted file mode 100644 index dfd850926d6..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/MetricSelectDropDownPanel.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.sidebar.learningcurve; - -import java.util.Arrays; -import java.util.List; - -import org.apache.wicket.AttributeModifier; -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.ajax.markup.html.AjaxLink; -import org.apache.wicket.event.Broadcast; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.panel.Panel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.util.ListModel; - -import de.tudarmstadt.ukp.inception.recommendation.model.RecommenderEvaluationScoreMetricEnum; - -/** - * @deprecated The current implementation of the learning curve panel has a memory leak in the - * browser code. It should be re-implemented. - */ -@Deprecated -public class MetricSelectDropDownPanel - extends Panel -{ - - private static final long serialVersionUID = 4988942370126340112L; - - private static final List METRICS = Arrays - .asList(RecommenderEvaluationScoreMetricEnum.values()); - - private static final String MID_METRIC_SELECT = "select"; - private static final String MID_METRIC_LINK = "link"; - - private final AjaxLink link; - private boolean isDropdownVisible = false; - - public MetricSelectDropDownPanel(String aId) - { - super(aId); - - final DropDownChoice dropdown = // - new DropDownChoice(MID_METRIC_SELECT, - new Model(METRICS.get(0)), - new ListModel(METRICS)); - dropdown.setRequired(true); - dropdown.setOutputMarkupId(true); - - dropdown.add(new AjaxFormComponentUpdatingBehavior("change") - { - private static final long serialVersionUID = -6744838136235652577L; - - @Override - protected void onUpdate(AjaxRequestTarget target) - { - DropDownEvent dropDownEvent = new DropDownEvent(); - dropDownEvent.setSelectedValue(dropdown.getModelObject()); - dropDownEvent.setTarget(target); - - send(getPage(), Broadcast.BREADTH, dropDownEvent); - - Effects.hide(target, dropdown); - Effects.show(target, dropdown); - target.appendJavaScript("document.getElementById('" + link.getMarkupId() - + "').classList.remove('fa-chevron-circle-right');"); - target.appendJavaScript("document.getElementById('" + link.getMarkupId() - + "').classList.add('fa-chevron-circle-left');"); - } - }); - - add(dropdown); - - link = new AjaxLink(MID_METRIC_LINK) - { - private static final long serialVersionUID = 1L; - - @Override - public void onClick(AjaxRequestTarget target) - { - if (isDropdownVisible) { - Effects.hide(target, dropdown); - target.appendJavaScript("document.getElementById('" + link.getMarkupId() - + "').classList.remove('fa-chevron-circle-left');"); - target.appendJavaScript("document.getElementById('" + link.getMarkupId() - + "').classList.add('fa-chevron-circle-right');"); - isDropdownVisible = false; - - } - else { - - Effects.show(target, dropdown); - target.appendJavaScript("document.getElementById('" + link.getMarkupId() - + "').classList.remove('fa-chevron-circle-right');"); - target.appendJavaScript("document.getElementById('" + link.getMarkupId() - + "').classList.add('fa-chevron-circle-left');"); - isDropdownVisible = true; - } - } - }; - - link.setOutputMarkupId(true); - add(link); - } - - private static class Effects - { - private static void hide(AjaxRequestTarget target, Component component) - { - if (component instanceof DropDownChoice) { - component.add(new DisplayNoneBehavior()); - String js = "$('#" + component.getMarkupId() - + "').animate({'width': '-=100'}, 100); $('#" - + ((DropDownChoice) component).getMarkupId() + "').hide();"; - target.appendJavaScript(js); - } - } - - private static void show(AjaxRequestTarget target, Component component) - { - if (component instanceof DropDownChoice) { - component.add(new DisplayNoneBehavior()); - String js = "$('#" + component.getMarkupId() - + "').animate({'width': '+=100'}, 100); $('#" - + ((DropDownChoice) component).getMarkupId() + "').show();"; - target.appendJavaScript(js); - } - } - } - - private static class DisplayNoneBehavior - extends AttributeModifier - { - - private static final long serialVersionUID = 1539674355578272254L; - - private DisplayNoneBehavior() - { - super("style", Model.of("display: none")); - } - - @Override - public boolean isTemporary(Component component) - { - return true; - } - } -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/chart.js b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/chart.js deleted file mode 100644 index f7c938faad1..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/sidebar/learningcurve/chart.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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. - */ - -/* - * The method renders a c3 chart with the help of the data it receives from the server side. - * - * the arrayOfLeaningCurves also includes x-axis. - */ -function updateLearningCurveDiagram(arrayOfLearningCurves) { - var xAxixType = 'indexed'; - - var xTick = { - format : function(a) { - return Math.round(1e2 * a) / 1e2; - } - }; - - var isCategoryChart = (arrayOfLearningCurves[0][2] - arrayOfLearningCurves[0][1]) < 1; - var size = { height: 200 }; - // make the type of x-axis "category" (shows x in category intervals of size 1). - // It is for better visualization when the x-axis represents test data size (annotation page) - if (isCategoryChart) { - xAxixType = "category"; - } - - // if we just have one value per data-row, we cannot visualize a step - var plotTypes = {}; - for (i = 0; i < arrayOfLearningCurves.length; i++) { - if (arrayOfLearningCurves[i].length < 3) { - plotTypes[arrayOfLearningCurves[i][0]] = 'scatter'; - } else { - plotTypes[arrayOfLearningCurves[i][0]] = 'step'; - } - } - - if (arrayOfLearningCurves[0].length < 3) { - xTick["values"] = [ 0.0, 1.0 ]; - } - - // draw the chart with the help of the arrayOfLearningCurves - var e = c3.generate({ - bindto: "#canvas", - size : size, - legend: { - show: false - }, - data: { - empty:{label:{text:"No Data Available"}}, - x: "x", - columns: arrayOfLearningCurves, - types: plotTypes - }, - axis: { - x: { - type: xAxixType, - tick : xTick - }, - y: { - min: 0, - //to round off the decimal points of the y-axis values to 4 if it is a decimal number. - tick: { - format: function(a) { - return Math.round(1e4 * a) / 1e4; - } - } - } - } - }); - - window.addEventListener('resize', (event) => { - if(isCategoryChart) - { - e.resize({height: 200, width: $("#html-chart-container").width()-10}) - } - }); -} diff --git a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/util/RepositoryUtil.java b/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/util/RepositoryUtil.java deleted file mode 100644 index aca1adf2805..00000000000 --- a/inception/inception-recommendation/src/main/java/de/tudarmstadt/ukp/inception/recommendation/util/RepositoryUtil.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2017 - * Ubiquitous Knowledge Processing (UKP) Lab - * Technische Universität Darmstadt - * - * 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.util; - -import java.io.File; -import java.util.LinkedList; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import de.tudarmstadt.ukp.clarin.webanno.api.DocumentService; -import de.tudarmstadt.ukp.clarin.webanno.api.ProjectService; -import de.tudarmstadt.ukp.clarin.webanno.model.Project; - -/** - * Little helper class to manage the folders used to store the results, models and recommendation - * settings. - * - * @deprecated Class appears not to be used anymore and is to be removed without replacement. - */ -@Deprecated -public class RepositoryUtil -{ - private static final Logger logger = LoggerFactory.getLogger(RepositoryUtil.class); - - private static final String RECOMMENDATION_DIR_NAME = "/recommendation/"; - - private static final String MODEL_DIR_NAME = "/model/"; - private static final String RESULT_DIR_NAME = "/results/"; - - public static File getRecommendationDir(DocumentService dc, Project p) - { - if (dc == null || p == null) { - logger.error("Cannot create file path. DocumentService or Project object is null"); - return null; - } - - File result = new File(dc.getDir(), "/" + ProjectService.PROJECT_FOLDER + "/"); - result = new File(result, Long.toString(p.getId())); - result = new File(result, RECOMMENDATION_DIR_NAME); - return result; - } - - public static List getRecommendationDirs(DocumentService dc) - { - if (dc == null) { - logger.error("Cannot create file paths. DocumentService object is null"); - return null; - } - - File dir = new File(dc.getDir(), "/" + ProjectService.PROJECT_FOLDER + "/"); - - if (!dir.exists()) { - return null; - } - - List result = new LinkedList<>(); - - for (File subDir : dir.listFiles()) { - if (subDir.isDirectory()) { - result.add(new File(subDir, RECOMMENDATION_DIR_NAME)); - } - } - - return result; - } - - public static File getModelDir(DocumentService dc, Project p) - { - File result = getRecommendationDir(dc, p); - return new File(result, MODEL_DIR_NAME); - } - - public static File getResultDir(DocumentService dc, Project p) - { - File result = getRecommendationDir(dc, p); - return new File(result, RESULT_DIR_NAME); - } -}