/** * method computeFlowTable create the flow table for faster processing. The flow table includes * the corresponding flow sequence for all languages in the capabilities * * @param aCapabilities * aggregate engine capabilities * @return Map - flow table includes all sequences for all languages */ protected Map<String, List<AnalysisSequenceCapabilityNode>> computeFlowTable(Capability[] aCapabilities) { // create flowTable Map<String, List<AnalysisSequenceCapabilityNode>> flowTable = new HashMap<String, List<AnalysisSequenceCapabilityNode>>(); // get all languages from the capabilities Set<String> languages = new HashSet<String>(); for (Capability capability : aCapabilities) { for (String capabilityLanguage : capability.getLanguagesSupported()) { languages.add(capabilityLanguage); } } // create flow table with sequences for all languages for (String capabilityLanguage : languages) { flowTable.put(capabilityLanguage, computeSequence(capabilityLanguage, aCapabilities)); } return flowTable; }
protected void normalizeIsoLangCodes(ProcessingResourceMetaData md) { if (md == null) { return; } Capability[] capabilities = md.getCapabilities(); if (capabilities == null) { return; } for (int i = 0; i < capabilities.length; i++) { Capability c = capabilities[i]; String[] languages = c.getLanguagesSupported(); for (int j = 0; j < languages.length; j++) { languages[j] = Language.normalize(languages[j]); } } }
/** * @see org.apache.uima.analysis_engine.ResultSpecification#addCapabilities(org.apache.uima.resource.metadata.Capability[], * boolean) */ public void addCapabilities(Capability[] capabilities, boolean outputs) { if (null == capabilities) { return; } for (Capability capability : capabilities) { TypeOrFeature[] tofs = outputs ? capability.getOutputs() : capability.getInputs(); for (TypeOrFeature tof : tofs) { String typeName = tof.getName(); if (!tof.isType()) { int i = typeName.indexOf(TypeSystem.FEATURE_SEPARATOR); String shortFeatName = typeName.substring(i+1); typeName = typeName.substring(0, i); rsTypesMap.add(typeName, shortFeatName, capability.getLanguagesSupported(), false); } else { rsTypesMap.add(typeName, tof.isAllAnnotatorFeatures(), capability.getLanguagesSupported(), false); } } } setCompileNeeded(); }
/** * Dialog for language. * * @param c the c * @param dialog the dialog * @return the int */ private int dialogForLanguage(Capability c, CommonInputDialog dialog) { for (;;) { if (dialog.open() == Window.CANCEL) return Window.CANCEL; String[] languages = c.getLanguagesSupported(); boolean alreadySpecified = false; for (int i = 0; i < languages.length; i++) { if (languages[i].equals(dialog.getValue())) { Utility .popMessage( "Language spec already defined", "The language specification you entered is already specified.\nPlease enter a different specification, or Cancel this operation." + "\n\nLanguage: " + dialog.getValue(), MessageDialog.ERROR); alreadySpecified = true; break; } } if (!alreadySpecified) break; } return Window.OK; }
String[] languages = c.getLanguagesSupported(); if (null != languages) { for (int i = 0; i < languages.length; i++) {
return; c.setLanguagesSupported(stringArrayAdd(c.getLanguagesSupported(), dialog.getValue()));
if (dialogForLanguage(c, dialog) == Window.CANCEL) return; c.getLanguagesSupported()[getIndex(editItem)] = dialog.getValue();
c.setLanguagesSupported(stringArrayRemove(c.getLanguagesSupported(), removeItem .getText(NAME_COL))); removeItem.dispose();