@Override public File getMiraDir(AnnotationFeature aFeature) { return new File(dir, "/" + PROJECT_FOLDER + "/" + aFeature.getProject().getId() + MIRA); }
private List<KnowledgeBase> listKnowledgeBases() { return kbService.getKnowledgeBases(feature.getObject().getProject()); }
private List<KnowledgeBase> listKnowledgeBases() { return kbService.getKnowledgeBases(feature.getObject().getProject()); }
private List<KBHandle> listConcepts() { // If a specific KB is selected, we show the concepts inside that one if (traits.getObject().knowledgeBase != null) { return kbService.listConcepts(traits.getObject().knowledgeBase, false); } // Otherwise, we offer concepts from all KBs else { List<KBHandle> allConcepts = new ArrayList<>(); for (KnowledgeBase kb : kbService.getKnowledgeBases(feature.getObject().getProject())) { allConcepts.addAll(kbService.listConcepts(kb, false)); } return allConcepts; } }
private List<KBHandle> listConcepts() { // If a specific KB is selected, we show the concepts inside that one if (traits.getObject().knowledgeBase != null) { return kbService.listConcepts(traits.getObject().knowledgeBase, false); } // Otherwise, we offer concepts from all KBs else { List<KBHandle> allConcepts = new ArrayList<>(); for (KnowledgeBase kb : kbService.getKnowledgeBases(feature.getObject().getProject())) { allConcepts.addAll(kbService.listConcepts(kb, false)); } return allConcepts; } }
@Override @Transactional public List<MiraTemplate> listMiraTemplates(Project aProject) { List<MiraTemplate> allTenplates = entityManager.createQuery( "FROM MiraTemplate ORDER BY trainFeature ASC ", MiraTemplate.class).getResultList(); List<MiraTemplate> templatesInThisProject = new ArrayList<>(); for (MiraTemplate miraTemplate : allTenplates) { if (nonNull(miraTemplate.getTrainFeature()) && Objects.equals( miraTemplate.getTrainFeature().getProject().getId(), aProject.getId())) { templatesInThisProject.add(miraTemplate); } } return templatesInThisProject; }
private String loadLabelValue(Key aKey) { try { return kbService.getKnowledgeBases(aKey.getAnnotationFeature().getProject()).stream() .map(k -> kbService.readProperty(k, aKey.getLabel())) .flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty)) .map(KBProperty::getUiLabel).findAny().orElseThrow(NoSuchElementException::new); } catch (Exception e) { LOG.error("Unable to render feature value [{}]", aKey.getLabel(), e); return "ERROR (" + aKey.getLabel() + ")"; } }
private String loadLabelValue(Key aKey) { try { return kbService.getKnowledgeBases(aKey.getAnnotationFeature().getProject()).stream() .map(k -> kbService.readProperty(k, aKey.getLabel())) .flatMap(o -> o.map(Stream::of).orElseGet(Stream::empty)) .map(KBProperty::getUiLabel).findAny().orElseThrow(NoSuchElementException::new); } catch (Exception e) { LOG.error("Unable to render feature value [{}]", aKey.getLabel(), e); return "ERROR (" + aKey.getLabel() + ")"; } }
AnnotationFeature feature = aTemplate.getTrainFeature(); TypeAdapter adapter = aAnnotationService.getAdapter(feature.getLayer()); for (SourceDocument document : aRepository.listSourceDocuments(feature.getProject())) { File predFile = new File(miraDir, document.getId() + ".pred.ft"); BufferedWriter predOut = new BufferedWriter(new FileWriter(predFile));
AnnotationFeature feature = aTemplate.getTrainFeature(); TypeAdapter adapter = aAnnotationService.getAdapter(feature.getLayer()); for (SourceDocument document : aRepository.listSourceDocuments(feature.getProject())) { File predFile = new File(miraDir, document.getId() + ".pred.ft"); BufferedWriter predOut = new BufferedWriter(new FileWriter(predFile));
private String loadLabelValue(Key aKey) { try { ConceptFeatureTraits t = readTraits(aKey.getAnnotationFeature()); // Use the concept from a particular knowledge base Optional<KBObject> kbObject; if (t.getRepositoryId() != null) { kbObject = kbService .getKnowledgeBaseById(aKey.getAnnotationFeature().getProject(), t.getRepositoryId()) .flatMap(kb -> kbService.readKBIdentifier(kb, aKey.getLabel())); } // Use the concept from any knowledge base (leave KB unselected) else { kbObject = kbService.readKBIdentifier(aKey.getAnnotationFeature().getProject(), aKey.getLabel()); } return kbObject.map(KBObject::getUiLabel).orElseThrow(NoSuchElementException::new); } catch (NoSuchElementException e) { LOG.error("No label for feature value [{}]", aKey.getLabel()); return "NO LABEL (" + aKey.getLabel() + ")"; } catch (Exception e) { LOG.error("Unable to obtain label value for feature value [{}]", aKey.getLabel(), e); return "ERROR (" + aKey.getLabel() + ")"; } }
private String loadLabelValue(Key aKey) { try { ConceptFeatureTraits t = readTraits(aKey.getAnnotationFeature()); // Use the concept from a particular knowledge base Optional<KBObject> kbObject; if (t.getRepositoryId() != null) { kbObject = kbService .getKnowledgeBaseById(aKey.getAnnotationFeature().getProject(), t.getRepositoryId()) .flatMap(kb -> kbService.readKBIdentifier(kb, aKey.getLabel())); } // Use the concept from any knowledge base (leave KB unselected) else { kbObject = kbService.readKBIdentifier(aKey.getAnnotationFeature().getProject(), aKey.getLabel()); } return kbObject.map(KBObject::getUiLabel).orElseThrow(NoSuchElementException::new); } catch (NoSuchElementException e) { LOG.error("No label for feature value [{}]", aKey.getLabel()); return "NO LABEL (" + aKey.getLabel() + ")"; } catch (Exception e) { LOG.error("Unable to obtain label value for feature value [{}]", aKey.getLabel(), e); return "ERROR (" + aKey.getLabel() + ")"; } }
AnnotationFeature feat = getModelObject().feature; Project project = feat.getProject(); FeatureSupport<ConceptFeatureTraits> fs = featureSupportRegistry .getFeatureSupport(feat);
Project project = feature.getObject().getProject();
public UimaStringTraitsEditor(String aId, IModel<AnnotationFeature> aFeature) { super(aId); DropDownChoice<TagSet> tagset = new BootstrapSelect<>("tagset"); tagset.setOutputMarkupPlaceholderTag(true); tagset.setOutputMarkupId(true); tagset.setChoiceRenderer(new ChoiceRenderer<>("name")); tagset.setNullValid(true); tagset.setModel(PropertyModel.of(aFeature, "tagset")); tagset.setChoices(LoadableDetachableModel.of(() -> annotationService .listTagSets(aFeature.getObject().getProject()))); add(tagset); } }
public UimaStringTraitsEditor(String aId, IModel<AnnotationFeature> aFeature) { super(aId); DropDownChoice<TagSet> tagset = new BootstrapSelect<>("tagset"); tagset.setOutputMarkupPlaceholderTag(true); tagset.setOutputMarkupId(true); tagset.setChoiceRenderer(new ChoiceRenderer<>("name")); tagset.setNullValid(true); tagset.setModel(PropertyModel.of(aFeature, "tagset")); tagset.setChoices(LoadableDetachableModel.of(() -> annotationService .listTagSets(aFeature.getObject().getProject()))); add(tagset); } }
public PropertyFeatureEditor(String aId, MarkupContainer aOwner, AnnotationActionHandler aHandler, final IModel<AnnotatorState> aStateModel, IModel<FeatureState> aFeatureStateModel) { super(aId, aOwner, new CompoundPropertyModel<>(aFeatureStateModel)); stateModel = aStateModel; actionHandler = aHandler; project = this.getModelObject().feature.getProject(); traits = factService.getFeatureTraits(project); add(new Label("feature", getModelObject().feature.getUiName())); add(focusComponent = createAutoCompleteTextField()); add(createStatementIndicatorLabel()); add(createNoStatementLabel()); }
public PropertyFeatureEditor(String aId, MarkupContainer aOwner, AnnotationActionHandler aHandler, final IModel<AnnotatorState> aStateModel, IModel<FeatureState> aFeatureStateModel) { super(aId, aOwner, new CompoundPropertyModel<>(aFeatureStateModel)); stateModel = aStateModel; actionHandler = aHandler; project = this.getModelObject().feature.getProject(); traits = factService.getFeatureTraits(project); add(new Label("feature", getModelObject().feature.getUiName())); add(focusComponent = createAutoCompleteTextField()); add(createStatementIndicatorLabel()); add(createNoStatementLabel()); }
public SubjectObjectFeatureEditor(String aId, MarkupContainer aOwner, AnnotationActionHandler aHandler, final IModel<AnnotatorState> aStateModel, final IModel<FeatureState> aFeatureStateModel, String role) { super(aId, aOwner, CompoundPropertyModel.of(aFeatureStateModel)); stateModel = aStateModel; actionHandler = aHandler; project = this.getModelObject().feature.getProject(); add(new Label("feature", getModelObject().feature.getUiName())); content = new WebMarkupContainer("content"); content.setOutputMarkupId(true); add(content); List<LinkWithRoleModel> links = (List<LinkWithRoleModel>) SubjectObjectFeatureEditor.this .getModelObject().value; roleModel = new LinkWithRoleModel(); roleModel.role = role; if (links.size() == 1) { roleModel = links.get(0); } content.add(createSubjectObjectLabel()); content.add(createRemoveLabelIcon()); content.add(focusComponent = createAutoCompleteTextField()); }
public SubjectObjectFeatureEditor(String aId, MarkupContainer aOwner, AnnotationActionHandler aHandler, final IModel<AnnotatorState> aStateModel, final IModel<FeatureState> aFeatureStateModel, String role) { super(aId, aOwner, CompoundPropertyModel.of(aFeatureStateModel)); stateModel = aStateModel; actionHandler = aHandler; project = this.getModelObject().feature.getProject(); add(new Label("feature", getModelObject().feature.getUiName())); content = new WebMarkupContainer("content"); content.setOutputMarkupId(true); add(content); List<LinkWithRoleModel> links = (List<LinkWithRoleModel>) SubjectObjectFeatureEditor.this .getModelObject().value; roleModel = new LinkWithRoleModel(); roleModel.role = role; if (links.size() == 1) { roleModel = links.get(0); } content.add(createSubjectObjectLabel()); content.add(createRemoveLabelIcon()); content.add(focusComponent = createAutoCompleteTextField()); }