Java Code Examples for org.apache.uima.resource.metadata.Capability#setLanguagesSupported()
The following examples show how to use
org.apache.uima.resource.metadata.Capability#setLanguagesSupported() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CapabilitySection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Handle add lang. * * @param selItem the sel item * @param itemKind the item kind */ private void handleAddLang(TreeItem selItem, int itemKind) { if (itemKind == CS) selItem = selItem.getItems()[0]; // lang is 1st item in capability set else if (itemKind == LANG_ITEM) selItem = selItem.getParentItem(); else if (itemKind == TYPE || itemKind == SOFA) selItem = selItem.getParentItem().getItems()[0]; else if (itemKind == FEAT || itemKind == SOFA_ITEM) selItem = selItem.getParentItem().getParentItem().getItems()[0]; Capability c = getCapabilityFromTreeItem(selItem.getParentItem()); CommonInputDialog dialog = new CommonInputDialog( this, "Add Language", "Enter a two letter ISO-639 language code, followed optionally by a two-letter ISO-3166 country code (Examples: fr or fr-CA)", CommonInputDialog.LANGUAGE); if (dialogForLanguage(c, dialog) == Window.CANCEL) return; c.setLanguagesSupported(stringArrayAdd(c.getLanguagesSupported(), dialog.getValue())); // update GUI TreeItem lItem = new TreeItem(selItem, SWT.NONE); lItem.setData(LANG_TITLE); lItem.setText(NAME_COL, dialog.getValue()); selItem.setExpanded(true); pack04(); finishAction(); }
Example 2
Source File: CapabilitySection.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Handle remove. * * @param removeItem the remove item * @param itemKind the item kind */ private void handleRemove(TreeItem removeItem, int itemKind) { int selectionIndex = tt.indexOf(tt.getSelection()[0]); Capability c = getCapability(removeItem); switch (itemKind) { case CS: { if (Window.CANCEL == Utility.popOkCancel("Confirm Remove", "This action will remove an entire capability set. Please confirm.", MessageDialog.WARNING)) { maybeSetSelection(tt, selectionIndex + 1); return; } removeCapabilitySet(c); removeItem.dispose(); break; } case LANG_ITEM: { c.setLanguagesSupported(stringArrayRemove(c.getLanguagesSupported(), removeItem .getText(NAME_COL))); removeItem.dispose(); break; } case SOFA_ITEM: { if (Window.CANCEL == Utility .popOkCancel( "Confirm Removal of Sofa", "This action will remove this Sofa as a capability, and delete its mappings if no other capability set declares this Sofa." + " Please confirm.", MessageDialog.WARNING)) { maybeSetSelection(tt, selectionIndex + 1); return; } String sofaName = removeItem.getText(NAME_COL); boolean isInput = INPUT.equals(removeItem.getText(INPUT_COL)); if (isInput) c.setInputSofas((String[]) Utility.removeElementFromArray(c.getInputSofas(), sofaName, String.class)); else c.setOutputSofas((String[]) Utility.removeElementFromArray(c.getOutputSofas(), sofaName, String.class)); removeItem.dispose(); if (!anyCapabilitySetDeclaresSofa(sofaName, isInput)) { Comparator comparator = new Comparator() { @Override public int compare(Object o1, Object o2) { String name = (String) o1; SofaMapping sofaMapping = (SofaMapping) o2; if (name.equals(sofaMapping.getAggregateSofaName())) return 0; return 1; } }; editor.getAeDescription().setSofaMappings( (SofaMapping[]) Utility.removeElementsFromArray(getSofaMappings(), sofaName, SofaMapping.class, comparator)); sofaMapSection.markStale(); } break; } case TYPE: { if (Window.CANCEL == Utility.popOkCancel("Confirm Removal of Type", "This action will remove this type as a capability. Please confirm.", MessageDialog.WARNING)) { maybeSetSelection(tt, selectionIndex + 1); return; } TreeItem[] features = removeItem.getItems(); if (null != features) for (int i = 0; i < features.length; i++) { removeFeature(c, features[i]); } String typeNameToRemove = getFullyQualifiedName(removeItem); if (isInput(removeItem)) c.setInputs(typeOrFeatureArrayRemove(c.getInputs(), typeNameToRemove)); if (isOutput(removeItem) /* || isUpdate(removeItem) */) c.setOutputs(typeOrFeatureArrayRemove(c.getOutputs(), typeNameToRemove)); removeItem.dispose(); break; } case FEAT: { removeFeature(c, removeItem); break; } default: throw new InternalErrorCDE("invalid state"); } maybeSetSelection(tt, selectionIndex - 1); finishAction(); }
Example 3
Source File: ResultSpecification_implTest.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { try { // create array of types and features for use in testing t1 = new TypeOrFeature_impl(); t1.setType(true); t1.setName("FakeType"); t1.setAllAnnotatorFeatures(false); f1 = new TypeOrFeature_impl(); f1.setType(false); f1.setName("FakeType:FakeFeature"); t2 = new TypeOrFeature_impl(); t2.setType(true); t2.setName("AnotherType"); t2.setAllAnnotatorFeatures(true); mTypesAndFeatures = new TypeOrFeature[] { t1, f1, t2 }; // create capability[] for language tests // capability 1 - using t1 Capability cap1 = new Capability_impl(); String[] languages1 = { "en", "de", "en-US", "en-GB" }; TypeOrFeature[] tofs1 = { t1 }; cap1.setLanguagesSupported(languages1); cap1.setOutputs(tofs1); // capability 2 - using f1 Capability cap2 = new Capability_impl(); String[] languages2 = { "ja", "en" }; TypeOrFeature[] tofs2 = { f1 }; cap2.setLanguagesSupported(languages2); cap2.setOutputs(tofs2); // capability 3 - using t2 Capability cap3 = new Capability_impl(); String[] languages3 = { "x-unspecified" }; TypeOrFeature[] tofs3 = { t2 }; cap3.setLanguagesSupported(languages3); cap3.setOutputs(tofs3); // capability 4 - using f1 cap4 = new Capability_impl(); String[] languages4 = {}; // length 0 string TypeOrFeature[] tofs4 = { f1 }; cap4.setLanguagesSupported(languages4); cap4.setOutputs(tofs4); // make capability array with the above specified values capabilities = new Capability[] { cap1, cap2, cap3 }; // make languages array languages = new Vector<>(3); languages.add(0, languages1); languages.add(1, languages2); languages.add(2, languages3); } catch (Exception e) { JUnitExtension.handleException(e); } }