Examples of TypePriorityList


Examples of org.apache.uima.resource.metadata.TypePriorityList

              "uima.cas.String");
      enumType.setAllowedValues(new AllowedValue[] { new AllowedValue_impl("One", "First Value"),
          new AllowedValue_impl("Two", "Second Value") });

      TypePriorities typePriorities = new TypePriorities_impl();
      TypePriorityList priorityList = typePriorities.addPriorityList();
      priorityList.addType("Fake");
      priorityList.addType("EnumType");

      FsIndexDescription index = new FsIndexDescription_impl();
      index.setLabel("testIndex");
      index.setTypeName("Fake");
      FsIndexKeyDescription key1 = new FsIndexKeyDescription_impl();
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

              "uima.cas.String");
      enumType.setAllowedValues(new AllowedValue[] { new AllowedValue_impl("One", "First Value"),
          new AllowedValue_impl("Two", "Second Value") });

      TypePriorities typePriorities = new TypePriorities_impl();
      TypePriorityList priorityList = typePriorities.addPriorityList();
      priorityList.addType("Fake");
      priorityList.addType("EnumType");

      FsIndexDescription index = new FsIndexDescription_impl();
      index.setLabel("testIndex");
      index.setTypeName("Fake");
      FsIndexKeyDescription key1 = new FsIndexKeyDescription_impl();
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

    return typePriorityLists[tree.indexOf(item)];
  }

  public void handleEvent(Event event) {
    if (event.widget == addSetButton) {
      TypePriorityList typePriorityList = UIMAFramework.getResourceSpecifierFactory()
              .createTypePriorityList();

      TypePriorities typePriorities = getTypePriorities();
      if (typePriorities == null) {
        typePriorities = UIMAFramework.getResourceSpecifierFactory().createTypePriorities();
        getAnalysisEngineMetaData().setTypePriorities(typePriorities);
      }

      getTypePriorities().addPriorityList(typePriorityList);

      TreeItem item = new TreeItem(tree, SWT.NONE);
      item.setText(PRIORITY_LIST);

      tree.setSelection(new TreeItem[] { item });
      setFileDirty();
    } else if (event.widget == addButton) { // add type to set
      if (editor.isTypePriorityDescriptor() && !editor.getIsContextLoaded()) {
        Utility
                .popMessage(
                        "Can''t add types here",
                        "Types cannot be added here, because there is no loaded context type system to pick the types from",
                        MessageDialog.WARNING);
        return;
      }
      TreeItem parent = tree.getSelection()[0];
      if (null != parent.getParentItem())
        parent = parent.getParentItem();
      AddTypeToPriorityListDialog dialog = new AddTypeToPriorityListDialog(this,
              editor.definedTypesWithSupers.get(), // types
              getTypePriorityListFromTreeItem(parent).getTypes()); // types already in list

      if (dialog.open() == Window.CANCEL)
        return;

      TypePriorityList typePriorityList = getTypePriorityListFromTreeItem(parent);

      String[] newTypeNames = dialog.getSelectedTypeNames();
      for (int i = 0; i < newTypeNames.length; i++) {
        typePriorityList.addType(newTypeNames[i]);
        TreeItem item = new TreeItem(parent, SWT.NONE);
        item.setText(formatName(newTypeNames[i]));
      }

      setFileDirty();
    } else if (event.widget == removeButton) {
      TreeItem item = tree.getSelection()[0];
      TreeItem parent = item.getParentItem();

      if (null == parent) { // removing a priority set
        if (Window.CANCEL == Utility.popOkCancel("ConfirmRemove", "ConfirmRemoveSet",
                MessageDialog.WARNING))
          return;
        TypePriorityList removedTypePriorityList = getTypePriorityListFromTreeItem(item);
        TypePriorityList[] oldPriorityLists = getAnalysisEngineMetaData().getTypePriorities()
                .getPriorityLists();
        TypePriorityList[] newPriorityLists = new TypePriorityList[oldPriorityLists.length - 1];

        for (int i = 0, j = 0; i < oldPriorityLists.length; i++) {
          if (oldPriorityLists[i] != removedTypePriorityList) {
            newPriorityLists[j++] = oldPriorityLists[i];
          }
        }

        getAnalysisEngineMetaData().getTypePriorities().setPriorityLists(newPriorityLists);

      } else { // removing a type
        if (Window.CANCEL == Utility.popOkCancel("ConfirmRemove", "ConfirmRemoveType",
                MessageDialog.WARNING))
          return;
        TypePriorityList typePriorityList = getTypePriorityListFromTreeItem(parent);
        typePriorityList.removeType(item.getText());
      }

      TreeItem previousSelection = getPreviousSelection(parent == null ? tree.getItems() : parent
              .getItems(), item);
      if (null != previousSelection)
        tree.setSelection(new TreeItem[] { previousSelection });
      item.dispose();
      setFileDirty();
    }
    // only enabled for types
    else if (event.widget == downButton || event.widget == upButton) {
      TreeItem item = tree.getSelection()[0];
      TreeItem parent = item.getParentItem();
      TreeItem[] items = parent.getItems();
      int i = getItemIndex(items, item);

      TypePriorityList typePriorityList = getTypePriorityListFromTreeItem(parent);
      String[] types = typePriorityList.getTypes();
      String temp = types[i];
      if (event.widget == downButton) {
        types[i] = types[i + 1];
        types[i + 1] = temp;
        typePriorityList.setTypes(types);

        new TreeItem(parent, SWT.NONE, i).setText(formatName(types[i]));
        TreeItem t = new TreeItem(parent, SWT.NONE, i + 1);
        t.setText(formatName(types[i + 1]));
        tree.setSelection(new TreeItem[] { t });

        items[i].dispose();
        items[i + 1].dispose();
      } else {
        types[i] = types[i - 1];
        types[i - 1] = temp;
        typePriorityList.setTypes(types);

        TreeItem t = new TreeItem(parent, SWT.NONE, i - 1);
        t.setText(formatName(types[i - 1]));
        tree.setSelection(new TreeItem[] { t });
        new TreeItem(parent, SWT.NONE, i).setText(formatName(types[i]));
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

            org.apache.uima.fit.component.NoOpAnnotator.class, typeSystemDescription,
            prioritizedTypeNames, (Object[]) null);

    typePriorities = engine.getAnalysisEngineMetaData().getTypePriorities();
    assertEquals(1, typePriorities.getPriorityLists().length);
    TypePriorityList typePriorityList = typePriorities.getPriorityLists()[0];
    assertEquals(2, typePriorityList.getTypes().length);
    assertEquals("org.apache.uima.fit.type.Token", typePriorityList.getTypes()[0]);
    assertEquals("org.apache.uima.fit.type.Sentence", typePriorityList.getTypes()[1]);

    jCas = engine.newJCas();
    tokenBuilder.buildTokens(jCas, "word");
    FSIterator<Annotation> tokensInSentence = jCas.getAnnotationIndex().subiterator(
            JCasUtil.selectByIndex(jCas, Sentence.class, 0));
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

   * @param prioritizedTypeNames
   *          a sequence of ordered type names
   */
  public static TypePriorities createTypePriorities(String... prioritizedTypeNames) {
    TypePriorities typePriorities = new TypePriorities_impl();
    TypePriorityList typePriorityList = typePriorities.addPriorityList();
    for (String typeName : prioritizedTypeNames) {
      typePriorityList.addType(typeName);
    }
    return typePriorities;
  }
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

      enumType.setAllowedValues(new AllowedValue[] { new AllowedValue_impl("One", "First Value"),
          new AllowedValue_impl("Two", "Second Value") });
      desc.getAnalysisEngineMetaData().setTypeSystem(typeSystem);

      TypePriorities typePriorities = new TypePriorities_impl();
      TypePriorityList priorityList = typePriorities.addPriorityList();
      priorityList.addType("Type1");
      priorityList.addType("Type2");
      desc.getAnalysisEngineMetaData().setTypePriorities(typePriorities);

      FsIndexDescription index1 = new FsIndexDescription_impl();
      index1.setLabel("Index1");
      index1.setTypeName("Type1");
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

  /**
   * @see TypePriorities#addPriorityList()
   */
  public TypePriorityList addPriorityList() {
    TypePriorityList newPriorityList = new TypePriorityList_impl();
    mPriorityLists.add(newPriorityList);
    return newPriorityList;
  }
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

  public Object clone() {
    TypePriorities_impl clone = (TypePriorities_impl) super.clone();
    clone.mPriorityLists = new ArrayList<TypePriorityList>();
    Iterator<TypePriorityList> priListIter = mPriorityLists.iterator();
    while (priListIter.hasNext()) {
      TypePriorityList priList = priListIter.next();
      clone.addPriorityList((TypePriorityList) priList.clone());
    }

    return clone;
  }
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

  /**
   * @see org.apache.uima.analysis_engine.metadata.TypePriorities#addPriorityList()
   */
  public TypePriorityList addPriorityList() {
    TypePriorityList newPriorityList = new TypePriorityList_impl();
    mPriorityLists.add(newPriorityList);
    return newPriorityList;
  }
View Full Code Here

Examples of org.apache.uima.resource.metadata.TypePriorityList

  public Object clone() {
    TypePriorities_impl clone = (TypePriorities_impl) super.clone();
    clone.mPriorityLists = new ArrayList<TypePriorityList>();
    Iterator<TypePriorityList> priListIter = mPriorityLists.iterator();
    while (priListIter.hasNext()) {
      TypePriorityList priList = priListIter.next();
      clone.addPriorityList((TypePriorityList) priList.clone());
    }

    return clone;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.