/**
   * Convert from an entity to a map.
   *
   * @param entity the entity to convert
   * @return a map containing the entity's fields (and history is required)
   */
  public Map<String, Object> convertEntity(Entity entity) {
    Map<String, Object> map = Maps.newHashMap();

    convertFeatures(map, entity);

    if (outputHistory && documentHistory != null) {
      Collection<HistoryEvent> events = documentHistory.getHistory(entity.getInternalId());
      convertHistory(map, events, entity.getInternalId());
    }
    putIfExists(map, fields.getExternalId(), entity.getExternalId());

    return map;
  }
  @Override
  public void doProcess(JCas aJCas) throws AnalysisEngineProcessException {
    List<Entity> toRemove = new ArrayList<Entity>();

    FSIterator<Annotation> iter = aJCas.getAnnotationIndex(Entity.type).iterator();
    while (iter.hasNext()) {
      Entity e = (Entity) iter.next();

      if (e.getConfidence() < confidenceThreshold
          && (!ignoreZeroConfidence || e.getConfidence() > 0.0)) {
        toRemove.add(e);
        getMonitor()
            .debug(
                "Low confidence entity found (ID: {}) - this entity will be removed",
                e.getInternalId());
      }
    }

    removeFromJCasIndex(toRemove);
  }