@Override public ConceptFeatureTraits getFeatureTraits(Project aProject) { AnnotationLayer linkedLayer = annotationService .getLayer(NamedEntity.class.getName(), aProject); AnnotationFeature linkedFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); FeatureSupport<ConceptFeatureTraits> fs = featureSupportRegistry .getFeatureSupport(linkedFeature); ConceptFeatureTraits traits = fs.readTraits(linkedFeature); return traits; }
@Override public ConceptFeatureTraits getFeatureTraits(Project aProject) { AnnotationLayer linkedLayer = annotationService .getLayer(NamedEntity.class.getName(), aProject); AnnotationFeature linkedFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); FeatureSupport<ConceptFeatureTraits> fs = featureSupportRegistry .getFeatureSupport(linkedFeature); ConceptFeatureTraits traits = fs.readTraits(linkedFeature); return traits; }
@Override public void onConfigure() { super.onConfigure(); List<LinkWithRoleModel> links = (List<LinkWithRoleModel>) this.getModelObject().value; if (links.size() == 0) { String role = roleModel.role; roleModel = new LinkWithRoleModel(); roleModel.role = role; links.add(roleModel); } else { roleModel = links.get(0); } String linkedType = this.getModelObject().feature.getType(); AnnotationLayer linkedLayer = annotationService .getLayer(linkedType, this.stateModel.getObject().getProject()); linkedAnnotationFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); }
private void fix(Project aProject, Class<? extends TOP> aLayer, String aLayerType, AnnotationLayer aTokenLayer, String aFeature) { if (annotationSchemaService.existsLayer(aLayer.getName(), aLayerType, aProject)) { AnnotationLayer layer = annotationSchemaService.getLayer(aLayer.getName(), aProject); if (layer.getAttachFeature() == null) { layer.setAttachFeature(annotationSchemaService.getFeature(aFeature, aTokenLayer)); log.info("DATABASE UPGRADE PERFORMED: Fixed attach-feature of layer " + "[{}] ({}) in project [{}] ({})", layer.getUiName(), layer.getId(), aProject.getName(), aProject.getId()); } } } }
@Override public void onConfigure() { super.onConfigure(); List<LinkWithRoleModel> links = (List<LinkWithRoleModel>) this.getModelObject().value; if (links.size() == 0) { String role = roleModel.role; roleModel = new LinkWithRoleModel(); roleModel.role = role; links.add(roleModel); } else { roleModel = links.get(0); } String linkedType = this.getModelObject().feature.getType(); AnnotationLayer linkedLayer = annotationService .getLayer(linkedType, this.stateModel.getObject().getProject()); linkedAnnotationFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer); }
public KBHandle getLinkedSubjectObjectKBHandle(String featureName, AnnotationActionHandler actionHandler, AnnotatorState aState) { AnnotationLayer factLayer = annotationService.getLayer(FACT_LAYER, aState.getProject()); KBHandle kbHandle = null; AnnotationFeature annotationFeature = annotationService.getFeature(featureName, factLayer); List<LinkWithRoleModel> featureValue = (List<LinkWithRoleModel>) aState .getFeatureState(annotationFeature).value; if (!featureValue.isEmpty()) { int targetAddress = featureValue.get(0).targetAddr; if (targetAddress != -1) { JCas jCas; try { jCas = actionHandler.getEditorCas(); kbHandle = factService .getKBHandleFromCasByAddr(jCas, targetAddress, aState.getProject(), traits); } catch (Exception e) { LOG.error("Error: " + e.getMessage(), e); error("Error: " + e.getMessage()); } } } return kbHandle; } }
public KBHandle getLinkedSubjectObjectKBHandle(String featureName, AnnotationActionHandler actionHandler, AnnotatorState aState) { AnnotationLayer factLayer = annotationService.getLayer(FACT_LAYER, aState.getProject()); KBHandle kbHandle = null; AnnotationFeature annotationFeature = annotationService.getFeature(featureName, factLayer); List<LinkWithRoleModel> featureValue = (List<LinkWithRoleModel>) aState .getFeatureState(annotationFeature).value; if (!featureValue.isEmpty()) { int targetAddress = featureValue.get(0).targetAddr; if (targetAddress != -1) { JCas jCas; try { jCas = actionHandler.getEditorCas(); kbHandle = factService .getKBHandleFromCasByAddr(jCas, targetAddress, aState.getProject(), traits); } catch (Exception e) { LOG.error("Error: " + e.getMessage(), e); error("Error: " + e.getMessage()); } } } return kbHandle; } }
private void fix(Project aProject, Class<? extends TOP> aLayer, String aLayerType, AnnotationLayer aTokenLayer, String aFeature) { if (annotationSchemaService.existsLayer(aLayer.getName(), aLayerType, aProject)) { AnnotationLayer layer = annotationSchemaService.getLayer(aLayer.getName(), aProject); if (layer.getAttachFeature() == null) { layer.setAttachFeature(annotationSchemaService.getFeature(aFeature, aTokenLayer)); log.info("DATABASE UPGRADE PERFORMED: Fixed attach-feature of layer " + "[{}] ({}) in project [{}] ({})", layer.getUiName(), layer.getId(), aProject.getName(), aProject.getId()); } } } }
private String formatLabel(AnnotationSuggestion aCurrentRecommendation) { AnnotationFeature feat = annotationService.getFeature(aCurrentRecommendation.getFeature(), alStateModel.getObject().getLayer()); FeatureSupport<?> featureSupport = featureSupportRegistry.getFeatureSupport(feat); String labelValue = featureSupport.renderFeatureValue(feat, aCurrentRecommendation.getLabel()); return labelValue; }
private String formatLabel(AnnotationSuggestion aCurrentRecommendation) { AnnotationFeature feat = annotationService.getFeature(aCurrentRecommendation.getFeature(), alStateModel.getObject().getLayer()); FeatureSupport<?> featureSupport = featureSupportRegistry.getFeatureSupport(feat); String labelValue = featureSupport.renderFeatureValue(feat, aCurrentRecommendation.getLabel()); return labelValue; }
.getLayer(linkedType, this.stateModel.getObject().getProject()); linkedAnnotationFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer);
.getLayer(linkedType, this.stateModel.getObject().getProject()); linkedAnnotationFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer);
exLayer.getAttachType().getName(), project); AnnotationFeature attachFeature = annotationService .getFeature(exLayer.getAttachFeature().getName(), attachLayer); layer.setAttachFeature(attachFeature);
exLayer.getAttachType().getName(), project); AnnotationFeature attachFeature = annotationService .getFeature(exLayer.getAttachFeature().getName(), attachLayer); layer.setAttachFeature(attachFeature);
.getLayer(exTemplate.getTrainFeature().getLayer(), aProject); AnnotationFeature trainingFeature = annotationService .getFeature(exTemplate.getTrainFeature().getName(), trainingLayer); template.setTrainFeature(trainingFeature); Set<AnnotationFeature> otherFeatures = new HashSet<>(); for (ExportedAnnotationFeatureReference other : exTemplate.getOtherFeatures()) { AnnotationLayer layer = annotationService.getLayer(other.getLayer(), aProject); AnnotationFeature feature = annotationService.getFeature(other.getName(), layer); otherFeatures.add(feature);
.getLayer(linkedType, this.stateModel.getObject().getProject()); AnnotationFeature linkedAnnotationFeature = annotationService .getFeature(FactLinkingConstants.LINKED_LAYER_FEATURE, linkedLayer);
private void writeLearningRecordInDatabaseAndEventLog(AnnotationSuggestion aSuggestion, LearningRecordType aUserAction, String aAnnotationValue) { AnnotatorState state = ActiveLearningSidebar.this.getModelObject(); ActiveLearningUserState alState = alStateModel.getObject(); AnnotationFeature feat = annotationService.getFeature(aSuggestion.getFeature(), alState.getLayer()); SourceDocument sourceDoc = documentService.getSourceDocument(state.getProject(), aSuggestion.getDocumentName()); // Log the action to the learning record learningRecordService.logRecord(sourceDoc, state.getUser().getUsername(), aSuggestion, aAnnotationValue, alState.getLayer(), feat, aUserAction, LearningRecordChangeLocation.AL_SIDEBAR); // Send an application event that the suggestion has been rejected List<AnnotationSuggestion> alternativeSuggestions = recommendationService .getPredictions(state.getUser(), state.getProject()) .getPredictionsByTokenAndFeature(aSuggestion.getDocumentName(), alState.getLayer(), aSuggestion.getBegin(), aSuggestion.getEnd(), aSuggestion.getFeature()); applicationEventPublisherHolder.get() .publishEvent(new ActiveLearningRecommendationEvent(this, sourceDoc, aSuggestion, state.getUser().getUsername(), alState.getLayer(), aSuggestion.getFeature(), aUserAction, alternativeSuggestions)); }
private void writeLearningRecordInDatabaseAndEventLog(AnnotationSuggestion aSuggestion, LearningRecordType aUserAction, String aAnnotationValue) { AnnotatorState state = ActiveLearningSidebar.this.getModelObject(); ActiveLearningUserState alState = alStateModel.getObject(); AnnotationFeature feat = annotationService.getFeature(aSuggestion.getFeature(), alState.getLayer()); SourceDocument sourceDoc = documentService.getSourceDocument(state.getProject(), aSuggestion.getDocumentName()); // Log the action to the learning record learningRecordService.logRecord(sourceDoc, state.getUser().getUsername(), aSuggestion, aAnnotationValue, alState.getLayer(), feat, aUserAction, LearningRecordChangeLocation.AL_SIDEBAR); // Send an application event that the suggestion has been rejected List<AnnotationSuggestion> alternativeSuggestions = recommendationService .getPredictions(state.getUser(), state.getProject()) .getPredictionsByTokenAndFeature(aSuggestion.getDocumentName(), alState.getLayer(), aSuggestion.getBegin(), aSuggestion.getEnd(), aSuggestion.getFeature()); applicationEventPublisherHolder.get() .publishEvent(new ActiveLearningRecommendationEvent(this, sourceDoc, aSuggestion, state.getUser().getUsername(), alState.getLayer(), aSuggestion.getFeature(), aUserAction, alternativeSuggestions)); }
private void importTrainingDocuments(ExportedProject aExProject, Project aProject) throws IOException { ExportedTrainingDocument[] trainingDocuments = aExProject .getArrayProperty(TRAINING_DOCUMENTS, ExportedTrainingDocument.class); for (ExportedTrainingDocument importedTrainingDocument : trainingDocuments) { TrainingDocument trainingDocument = new TrainingDocument(); trainingDocument.setFormat(importedTrainingDocument.getFormat()); trainingDocument.setName(importedTrainingDocument.getName()); trainingDocument.setState(importedTrainingDocument.getState()); trainingDocument.setProject(aProject); trainingDocument.setTimestamp(importedTrainingDocument.getTimestamp()); trainingDocument.setSentenceAccessed(importedTrainingDocument.getSentenceAccessed()); if (importedTrainingDocument.getFeature() != null) { AnnotationLayer trainingLayer = annotationService .getLayer(importedTrainingDocument.getFeature().getLayer(), aProject); AnnotationFeature trainingFeature = annotationService .getFeature(importedTrainingDocument.getFeature().getName(), trainingLayer); trainingDocument.setFeature(trainingFeature); } automationService.createTrainingDocument(trainingDocument); } }
AnnotationFeature feature = annotationService.getFeature(exfeature.getName(), layer); feature.setTagset(tagSet);