protected boolean capabilitiesContainSofa(String aSofaName, boolean aOutput) { Capability[] caps = this.getAnalysisEngineMetaData().getCapabilities(); for (int i = 0; i < caps.length; i++) { String[] sofas = aOutput ? caps[i].getOutputSofas() : caps[i].getInputSofas(); for (int j = 0; j < sofas.length; j++) { if (aSofaName.equals(sofas[j])) { return true; } } } return false; }
/** * Gets whether this AE is sofa-aware. This is a derived property that cannot be set directly. An * AE is sofa-aware if and only if it declares at least one input sofa or output sofa. * * @return true if this component is sofa-aware, false if it is sofa-unaware. */ public boolean isSofaAware() { Capability[] capabilities = getCapabilities(); if (capabilities != null) { for (int i = 0; i < capabilities.length; i++) { if (capabilities[i].getInputSofas().length > 0 || capabilities[i].getOutputSofas().length > 0) { return true; } } } return false; }
private boolean declaresSofa(AnalysisEngineDescription aDesc, String aSofaName) { Capability[] caps = aDesc.getAnalysisEngineMetaData().getCapabilities(); for (int i = 0; i < caps.length; i++) { String[] sofas = caps[i].getOutputSofas(); for (int j = 0; j < sofas.length; j++) { if (aSofaName.equals(sofas[j])) { return true; } } sofas = caps[i].getInputSofas(); for (int j = 0; j < sofas.length; j++) { if (aSofaName.equals(sofas[j])) { return true; } } } return false; }
/** * Any capability set declares sofa. * * @param name the name * @param isInput the is input * @return true, if successful */ private boolean anyCapabilitySetDeclaresSofa(String name, boolean isInput) { final Capability[] cSets = getAnalysisEngineMetaData().getCapabilities(); for (int i = 0; i < cSets.length; i++) { final String[] sofaNames = isInput ? cSets[i].getInputSofas() : cSets[i].getOutputSofas(); for (int j = 0; j < sofaNames.length; j++) { if (name.equals(sofaNames[j])) return true; } } return false; }
/** * Gets the capability sofa names. * * @param rs the rs * @param componentKey the component key * @return the capability sofa names */ protected static Set[] getCapabilitySofaNames(ResourceCreationSpecifier rs, String componentKey) { Capability[] cs = getCapabilities(rs); Set inputSofasSet = new TreeSet(); Set outputSofasSet = new TreeSet(); for (int i = 0; i < cs.length; i++) { Capability c = cs[i]; mergeSofaNames(inputSofasSet, c.getInputSofas(), componentKey); mergeSofaNames(outputSofasSet, c.getOutputSofas(), componentKey); } return new Set[] { inputSofasSet, outputSofasSet }; }
/** * Check dupl sofa name. * * @return the string */ private String checkDuplSofaName() { Capability[] cSets = capabilitySection.getCapabilities(); // check for dis-allowed duplicates in other capability sets for (int i = 0; i < cSets.length; i++) { Capability ci = cSets[i]; if (ci == capability) continue; // "reverse" i and o - if input validate name not exist as output in other sets, etc. String[] sofaNames = isInput ? ci.getOutputSofas() : ci.getInputSofas(); if (null != sofaNames) for (int j = 0; j < sofaNames.length; j++) { if (sofaName.equals(sofaNames[j])) return "This name exists as an " + (isInput ? "output" : "input") + " in some capability set. Please choose another name, or " + "switch the input/output specification to the opposite setting."; } } // check for duplicates in this capability if (!sofaName.equals(originalSofa)) { // means adding new sofa or changing name of existing one if (checkDuplSofaName1(sofaName, capability.getInputSofas()) || checkDuplSofaName1(sofaName, capability.getOutputSofas())) return "This name already in use; please choose a different name."; } return null; }
for (int i = 0; i < caps.length; i++) { String[] outputSofas = caps[i].getOutputSofas(); for (int j = 0; j < outputSofas.length; j++) { String aggSofa = sofamap.get(componentKey + "@/@" + outputSofas[j]); String[] sofas = caps[i].getOutputSofas(); for (int j = 0; j < sofas.length; j++) { if (!correctlyMappedAggregateOutputs.contains(sofas[j])) {
/** * Needs view. * * @return true if needsTCas */ private boolean needsView() { if (definedCapabilities == null) { // If Collection Reader and CAS Initilaizer do not declare any output SofAs, // must be sent the default view (meaning whatever's mapped to _InitialView) // for backward compatiblity CasInitializer casIni = ((CollectionReader) collectionReader).getCasInitializer(); if (casIni != null) { definedCapabilities = casIni.getProcessingResourceMetaData().getCapabilities(); } else { definedCapabilities = ((CollectionReader) collectionReader).getProcessingResourceMetaData() .getCapabilities(); } for (int j = 0; j < definedCapabilities.length; j++) { if (definedCapabilities[j].getOutputSofas().length > 0) { needsTCas = false; break; } } } return needsTCas; }
if (capabilities[j].getOutputSofas().length > 0) { sofaUnaware = false; break;
String[] outputSofaNames = c.getOutputSofas(); Arrays.sort(inputSofaNames); Arrays.sort(outputSofaNames);
} else { cSets[i].setOutputSofas((String[]) Utility.removeElementsFromArray(prevSofas = cSets[i] .getOutputSofas(), existingSofaName, String.class)); wasRemoved = prevSofas != cSets[i].getOutputSofas(); cSets[i].setInputSofas(stringArrayAdd(cSets[i].getInputSofas(), dialog.sofaName)); } else { cSets[i].setOutputSofas(stringArrayAdd(cSets[i].getOutputSofas(), dialog.sofaName));
/** * Handle add sofa. * * @param selItem the sel item * @param itemKind the item kind */ private void handleAddSofa(TableTreeItem selItem, int itemKind) { if (itemKind == CS) selItem = selItem.getItems()[1]; else if (itemKind == LANG || itemKind == TYPE) selItem = selItem.getParentItem().getItems()[1]; else if (itemKind == LANG_ITEM || itemKind == FEAT || itemKind == SOFA_ITEM) selItem = selItem.getParentItem().getParentItem().getItems()[1]; Capability c = getCapabilityFromTableTreeItem(selItem.getParentItem()); AddSofaDialog dialog = new AddSofaDialog(this, c); if (dialog.open() == Window.CANCEL) return; // dialog.isInput, dialog.sofaName if (dialog.isInput) c.setInputSofas(stringArrayAdd(c.getInputSofas(), dialog.sofaName)); else c.setOutputSofas(stringArrayAdd(c.getOutputSofas(), dialog.sofaName)); TableTreeItem item = new TableTreeItem(selItem, SWT.NONE); setGuiSofaName(item, dialog.sofaName, dialog.isInput); selItem.setExpanded(true); pack04(); sofaMapSection.markStale(); finishAction(); }
String.class)); else c.setOutputSofas((String[]) Utility.removeElementFromArray(c.getOutputSofas(), sofaName, String.class)); removeItem.dispose();