You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/08/12 13:14:21 UTC

svn commit: r1157050 [6/11] - in /uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons: ./ .settings/ META-INF/ icons/ schema/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/uima/ src/main/java/o...

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/EntryComparator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/EntryComparator.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/EntryComparator.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/EntryComparator.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.statistics;
+
+import java.util.Comparator;
+
+public class EntryComparator implements Comparator<StatisticsEntry> {
+
+  private int index;
+
+  private boolean inverted;
+
+  public EntryComparator(int index, boolean inverted) {
+    super();
+    this.index = index;
+    this.inverted = inverted;
+  }
+
+  public int compare(StatisticsEntry e1, StatisticsEntry e2) {
+    int result = 0;
+    switch (index) {
+      case 0:
+        result = e1.getName().compareTo(e2.getName());
+        break;
+      case 1:
+        result = ((Double) e1.getTotal()).compareTo(e2.getTotal());
+        break;
+      case 2:
+        result = ((Integer) e1.getAmount()).compareTo(e2.getAmount());
+        break;
+      case 3:
+        result = ((Double) e1.getPart()).compareTo(e2.getPart());
+        break;
+      default:
+        result = 0;
+    }
+    if (inverted) {
+      result = (int) -Math.signum(result);
+    }
+    return result;
+
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/EntryComparator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/EntryComparator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/IStatisticsViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/IStatisticsViewPage.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/IStatisticsViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/IStatisticsViewPage.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.statistics;
+
+import org.apache.uima.cev.views.ICEVViewPage;
+
+public interface IStatisticsViewPage extends ICEVViewPage {
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/IStatisticsViewPage.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/IStatisticsViewPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsContentProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsContentProvider.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsContentProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsContentProvider.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.statistics;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class StatisticsContentProvider implements IStructuredContentProvider {
+
+  public void dispose() {
+  }
+
+  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+  }
+
+  public Object[] getElements(Object inputElement) {
+    @SuppressWarnings("unchecked")
+    List<StatisticsEntry> entries = (List<StatisticsEntry>) inputElement;
+    return entries.toArray();
+
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsContentProvider.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsContentProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsEntry.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsEntry.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsEntry.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsEntry.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.statistics;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.impl.DoubleArrayFSImpl;
+import org.apache.uima.cas.impl.IntArrayFSImpl;
+import org.apache.uima.cas.impl.StringArrayFSImpl;
+
+public class StatisticsEntry {
+  private static final String PARTS = "part";
+
+  private static final String AMOUNTS = "amount";
+
+  private static final String TOTALS = "total";
+
+  private static final String NAMES = "name";
+
+  private static final String TYPE = "org.apache.uima.textmarker.type.Statistics";
+
+  private final String name;
+
+  private final double total;
+
+  private final int amount;
+
+  private final double part;
+
+  public StatisticsEntry(String name, double total, int amount, double part) {
+    super();
+    this.name = name;
+    this.total = total;
+    this.amount = amount;
+    this.part = part;
+
+  }
+
+  public static List<StatisticsEntry> createEntries(FeatureStructure fs) {
+    List<StatisticsEntry> result = new ArrayList<StatisticsEntry>();
+    Type type = fs.getCAS().getTypeSystem().getType(TYPE);
+    Feature fname = type.getFeatureByBaseName(NAMES);
+    Feature ftotal = type.getFeatureByBaseName(TOTALS);
+    Feature famount = type.getFeatureByBaseName(AMOUNTS);
+    Feature fparts = type.getFeatureByBaseName(PARTS);
+    StringArrayFSImpl vname = (StringArrayFSImpl) fs.getFeatureValue(fname);
+    DoubleArrayFSImpl vtotal = (DoubleArrayFSImpl) fs.getFeatureValue(ftotal);
+    IntArrayFSImpl vamount = (IntArrayFSImpl) fs.getFeatureValue(famount);
+    DoubleArrayFSImpl vpart = (DoubleArrayFSImpl) fs.getFeatureValue(fparts);
+
+    String[] narray = vname.toArray();
+    double[] tarray = vtotal.toArray();
+    int[] aarray = vamount.toArray();
+    double[] parray = vpart.toArray();
+
+    int i = 0;
+    for (String each : narray) {
+      result.add(new StatisticsEntry(each, tarray[i], aarray[i], parray[i]));
+      i++;
+    }
+
+    return result;
+  }
+
+  public double getPart() {
+    return part;
+  }
+
+  public int getAmount() {
+    return amount;
+  }
+
+  public double getTotal() {
+    return total;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  @Override
+  public String toString() {
+    return getName() + " : " + getTotal() + " : " + getAmount() + " : " + getPart();
+  }
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsEntry.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsEntry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsLabelProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsLabelProvider.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsLabelProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsLabelProvider.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.statistics;
+
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class StatisticsLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+  private StatisticsViewPage owner;
+
+  public StatisticsLabelProvider(StatisticsViewPage owner) {
+    super();
+    this.owner = owner;
+  }
+
+  public Image getColumnImage(Object element, int columnIndex) {
+    return null;
+  }
+
+  public String getColumnText(Object element, int columnIndex) {
+    StatisticsEntry entry = (StatisticsEntry) element;
+    switch (columnIndex) {
+      case 0:
+        return entry.getName();
+      case 1:
+        return entry.getTotal() + "ms";
+      case 2:
+        return entry.getAmount() + "";
+      case 3:
+        return entry.getPart() + "ms";
+      default:
+        throw new RuntimeException("Should not happen");
+    }
+
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsLabelProvider.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsLabelProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.statistics;
+
+import org.apache.uima.cev.views.CEVPageBookView;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class StatisticsView extends CEVPageBookView {
+
+  public StatisticsView() {
+    super();
+  }
+
+  @Override
+  protected PageRec doCreatePage(IWorkbenchPart part) {
+    return doCreatePage(part, IStatisticsViewPage.class);
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsView.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewFactory.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewFactory.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.statistics;
+
+import org.apache.uima.cev.data.CEVDocument;
+import org.apache.uima.cev.editor.CEVViewer;
+import org.apache.uima.cev.extension.ICEVView;
+import org.apache.uima.cev.extension.ICEVViewFactory;
+
+public class StatisticsViewFactory implements ICEVViewFactory {
+
+  public StatisticsViewFactory() {
+  }
+
+  public ICEVView createView(CEVViewer viewer, CEVDocument cevDocument, int index) {
+    return new StatisticsViewPage(viewer, cevDocument, index);
+  }
+
+  public Class<?> getAdapterInterface() {
+    return IStatisticsViewPage.class;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,280 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.statistics;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cev.data.CEVData;
+import org.apache.uima.cev.data.CEVDocument;
+import org.apache.uima.cev.editor.CEVViewer;
+import org.apache.uima.cev.extension.ICEVView;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.part.Page;
+
+public class StatisticsViewPage extends Page implements IStatisticsViewPage, ICEVView,
+        IDoubleClickListener, ISelectionChangedListener {
+
+  private static final String TYPE = "org.apache.uima.textmarker.type.Statistics";
+
+  private CEVDocument casDoc;
+
+  private int current;
+
+  private CEVViewer casViewer;
+
+  private Map<String, Image> images;
+
+  private TableViewer viewer;
+
+  public StatisticsViewPage(CEVViewer casViewer, CEVDocument casDoc, int index) {
+    super();
+    this.casViewer = casViewer;
+    this.casDoc = casDoc;
+    this.current = index;
+  }
+
+  @Override
+  public void dispose() {
+    super.dispose();
+    if (images != null) {
+      for (Image each : images.values()) {
+        each.dispose();
+      }
+    }
+  }
+
+  private void initImages() {
+    images = new HashMap<String, Image>();
+    ImageDescriptor desc;
+    Image image;
+    String name;
+
+    // desc = TextMarkerCEVPlugin.getImageDescriptor("/icons/accept.png");
+    // image = desc.createImage();
+    // name = "matched";
+    // images.put(name, image);
+  }
+
+  public Image getImage(String name) {
+    if (images == null) {
+      initImages();
+    }
+    return images.get(name);
+  }
+
+  @Override
+  public void createControl(Composite parent) {
+    createViewer(parent);
+    viewChanged(current);
+    //
+    //
+    //
+    // public void handleEvent(Event e) {
+    // TableItem item = (TableItem) e.item;
+    // int index = table.indexOf(item);
+    // // int[] datum = data[index];
+    // // item.setText(new String[] { Integer.toString(datum[0]), Integer.toString(datum[1]) });
+    // }
+    // });
+    // // Add sort indicator and sort data when column selected
+    // Listener sortListener = new Listener() {
+    // public void handleEvent(Event e) {
+    // // determine new sort column and direction
+    // TableColumn sortColumn = table.getSortColumn();
+    // TableColumn currentColumn = (TableColumn) e.widget;
+    // int dir = table.getSortDirection();
+    // if (sortColumn == currentColumn) {
+    // dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+    // } else {
+    // table.setSortColumn(currentColumn);
+    // dir = SWT.UP;
+    // }
+    // // sort the data based on column and direction
+    // final int index = currentColumn == cname ? 0 : 1;
+    // final int direction = dir;
+    // // Object[] data = new ;
+    // // Arrays.sort(data, new Comparator() {
+    // // public int compare(Object arg0, Object arg1) {
+    // // int[] a = (int[]) arg0;
+    // // int[] b = (int[]) arg1;
+    // // if (a[index] == b[index])
+    // // return 0;
+    // // if (direction == SWT.UP) {
+    // // return a[index] < b[index] ? -1 : 1;
+    // // }
+    // // return a[index] < b[index] ? 1 : -1;
+    // // }
+    // // });
+    // // update data displayed in table
+    // table.setSortDirection(dir);
+    // table.clearAll();
+    // }
+    // };
+    // cname.addListener(SWT.Selection, sortListener);
+    // ctotal.addListener(SWT.Selection, sortListener);
+    // camount.addListener(SWT.Selection, sortListener);
+    // cpart.addListener(SWT.Selection, sortListener);
+    // table.setSortColumn(cname);
+    // table.setSortDirection(SWT.UP);
+
+  }
+
+  private void createViewer(Composite parent) {
+    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+    createColumns(viewer);
+    viewer.setContentProvider(new StatisticsContentProvider());
+    viewer.setLabelProvider(new StatisticsLabelProvider(this));
+  }
+
+  // This will create the columns for the table
+  private void createColumns(final TableViewer viewer) {
+    Listener sortListener = new Listener() {
+
+      public void handleEvent(Event e) {
+        // determine new sort column and direction
+        TableColumn sortColumn = viewer.getTable().getSortColumn();
+        TableColumn currentColumn = (TableColumn) e.widget;
+        int dir = viewer.getTable().getSortDirection();
+        if (sortColumn == currentColumn) {
+          dir = dir == SWT.UP ? SWT.DOWN : SWT.UP;
+        } else {
+          viewer.getTable().setSortColumn(currentColumn);
+          dir = SWT.UP;
+        }
+        // sort the data based on column and direction
+        final int index = Arrays.asList(viewer.getTable().getColumns()).indexOf(currentColumn);
+        @SuppressWarnings("unchecked")
+        List<StatisticsEntry> input = (List<StatisticsEntry>) viewer.getInput();
+        Collections.sort(input, new EntryComparator(index, dir == SWT.UP));
+        viewer.getTable().setSortDirection(dir);
+        viewer.getTable().clearAll();
+        viewer.setInput(input);
+      }
+    };
+
+    String[] titles = { "Name", "Total", "Amount", "Each" };
+    int[] bounds = { 100, 100, 75, 100 };
+    TableViewerColumn column = null;
+    for (int i = 0; i < titles.length; i++) {
+      column = new TableViewerColumn(viewer, SWT.NONE);
+      TableColumn tc = column.getColumn();
+      tc.setText(titles[i]);
+      tc.setWidth(bounds[i]);
+      tc.setResizable(true);
+      tc.setMoveable(true);
+      tc.addListener(SWT.Selection, sortListener);
+    }
+    Table table = viewer.getTable();
+    table.setHeaderVisible(true);
+    table.setLinesVisible(true);
+    table.setSortColumn(column.getColumn());
+    table.setSortDirection(SWT.UP);
+  }
+
+  /**
+   * Passing the focus request to the viewer's control.
+   */
+  @Override
+  public void setFocus() {
+    viewer.getControl().setFocus();
+  }
+
+  @Override
+  public Control getControl() {
+    return viewer.getControl();
+  }
+
+  public CEVData getCurrentCEVData() {
+    return casDoc.getCASData(current);
+  }
+
+  public void doubleClick(DoubleClickEvent event) {
+  }
+
+  public void inputChange(Object newInput) {
+    if (newInput instanceof FeatureStructure) {
+      viewer.setInput(StatisticsEntry.createEntries((FeatureStructure) newInput));
+    }
+  }
+
+  public void viewChanged(int newIndex) {
+    getCurrentCEVData().removeAnnotationListener(this);
+    current = newIndex;
+    getCurrentCEVData().addAnnotationListener(this);
+    CAS cas = getCurrentCEVData().getCAS();
+    Type type = cas.getTypeSystem().getType(TYPE);
+    if (type != null) {
+      FSIterator allIndexedFS = cas.getIndexRepository().getAllIndexedFS(type);
+      if (allIndexedFS.isValid()) {
+        inputChange(allIndexedFS.get());
+      }
+    }
+    viewer.refresh();
+  }
+
+  public void annotationsAdded(List<AnnotationFS> annots) {
+  }
+
+  public void annotationsRemoved(List<AnnotationFS> annots) {
+  }
+
+  public void annotationStateChanged(Type type) {
+  }
+
+  public void annotationStateChanged(AnnotationFS annot) {
+  }
+
+  public void colorChanged(Type type) {
+  }
+
+  public void newSelection(int offset) {
+  }
+
+  public void selectionChanged(SelectionChangedEvent event) {
+  }
+
+  public void casChanged(CEVDocument casDocument) {
+    this.casDoc = casDocument;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/statistics/StatisticsViewPage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluator.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluator.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluator.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.CASRuntimeException;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+
+public class CoreMatchCasEvaluator implements ICasEvaluator {
+
+  @Override
+  public CAS evaluate(CAS test, CAS run, Collection<String> excludedTypes)
+          throws CASRuntimeException, CASException {
+    Type annotationType = test.getAnnotationType();
+    Type falsePositiveType = run.getTypeSystem().getType(ICasEvaluator.FALSE_POSITIVE);
+    Type falseNegativeType = run.getTypeSystem().getType(ICasEvaluator.FALSE_NEGATIVE);
+    Type truePositveType = run.getTypeSystem().getType(ICasEvaluator.TRUE_POSITIVE);
+
+    Feature feature = falsePositiveType.getFeatureByBaseName(ICasEvaluator.ORIGINAL);
+    List<Type> allTypes = test.getTypeSystem().getProperlySubsumedTypes(annotationType);
+    List<Type> types = new ArrayList<Type>();
+    for (Type eachType : allTypes) {
+      int size = test.getAnnotationIndex(eachType).size();
+      if (!excludedTypes.contains(eachType.getName()) && size > 0
+              && !eachType.equals(test.getDocumentAnnotation().getType())) {
+        types.add(eachType);
+      }
+    }
+
+    List<AnnotationFS> testAnnotations = getAnnotations(types, test);
+    List<AnnotationFS> runAnnotations = getAnnotations(types, run);
+
+    Collection<AnnotationFS> matched = new HashSet<AnnotationFS>();
+    List<AnnotationFS> fp = new ArrayList<AnnotationFS>();
+    List<AnnotationFS> fn = new ArrayList<AnnotationFS>();
+    List<AnnotationFS> tp = new ArrayList<AnnotationFS>();
+
+    for (AnnotationFS eachTest : testAnnotations) {
+      boolean found = false;
+      for (AnnotationFS eachRun : runAnnotations) {
+        if (matchCore(eachTest, eachRun)) {
+          matched.add(eachRun);
+          found = true;
+          break;
+        }
+      }
+      if (!found) {
+        AnnotationFS createAnnotation = run.createAnnotation(falseNegativeType,
+                eachTest.getBegin(), eachTest.getEnd());
+        Type type = run.getTypeSystem().getType(eachTest.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, eachTest.getBegin(), eachTest.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        fn.add(createAnnotation);
+      } else {
+        AnnotationFS createAnnotation = run.createAnnotation(truePositveType, eachTest.getBegin(),
+                eachTest.getEnd());
+        Type type = run.getTypeSystem().getType(eachTest.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, eachTest.getBegin(), eachTest.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        tp.add(createAnnotation);
+      }
+
+    }
+
+    for (AnnotationFS each : runAnnotations) {
+      if (!matched.contains(each)) {
+        AnnotationFS createAnnotation = run.createAnnotation(falsePositiveType, each.getBegin(),
+                each.getEnd());
+        Type type = run.getTypeSystem().getType(each.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, each.getBegin(), each.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        fp.add(createAnnotation);
+      }
+    }
+
+    for (AnnotationFS annotationFS : fn) {
+      run.addFsToIndexes(annotationFS);
+    }
+    for (AnnotationFS annotationFS : fp) {
+      run.addFsToIndexes(annotationFS);
+    }
+    for (AnnotationFS annotationFS : tp) {
+      run.addFsToIndexes(annotationFS);
+    }
+    return run;
+  }
+
+  private List<AnnotationFS> getAnnotations(List<Type> types, CAS cas) {
+    List<AnnotationFS> result = new ArrayList<AnnotationFS>();
+    for (Type type : types) {
+      FSIterator iterator = cas.getAnnotationIndex(type).iterator();
+      while (iterator.isValid()) {
+        FeatureStructure fs = iterator.get();
+        if (fs instanceof AnnotationFS) {
+          result.add((AnnotationFS) fs);
+        }
+        iterator.moveToNext();
+      }
+    }
+    return result;
+  }
+
+  private boolean matchCore(AnnotationFS a1, AnnotationFS a2) {
+
+    String coreTerm = null;
+    StringTokenizer tokenizer = new StringTokenizer(a1.getCoveredText());
+    while (tokenizer.hasMoreTokens()) {
+      String token = tokenizer.nextToken();
+      if (Character.isUpperCase(token.charAt(0)) && token.length() > 3) {
+        coreTerm = token;
+      }
+    }
+
+    // check, if coreTerm is contained in a2
+    if (coreTerm != null && a2.getCoveredText().indexOf(coreTerm) != -1)
+      return true;
+
+    return false;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluatorFactory.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluatorFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluatorFactory.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+public class CoreMatchCasEvaluatorFactory implements ICasEvaluatorFactory {
+
+  @Override
+  public ICasEvaluator createEvaluator() {
+    
+    return new CoreMatchCasEvaluator();
+  }
+
+  @Override
+  public String getDescription() {
+    return "Compares the offsets of two annotations, allowes partial matching, defines core terms and checks if at least these match (partially) with the other annotation";
+    
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/CoreMatchCasEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluator.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluator.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluator.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.CASRuntimeException;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+
+public class ExactCasEvaluator implements ICasEvaluator {
+
+  @Override
+  public CAS evaluate(CAS test, CAS run, Collection<String> excludedTypes)
+          throws CASRuntimeException, CASException {
+    Type annotationType = test.getAnnotationType();
+    Type falsePositiveType = run.getTypeSystem().getType(ICasEvaluator.FALSE_POSITIVE);
+    Type falseNegativeType = run.getTypeSystem().getType(ICasEvaluator.FALSE_NEGATIVE);
+    Type truePositveType = run.getTypeSystem().getType(ICasEvaluator.TRUE_POSITIVE);
+
+    Feature feature = falsePositiveType.getFeatureByBaseName(ICasEvaluator.ORIGINAL);
+    List<Type> allTypes = test.getTypeSystem().getProperlySubsumedTypes(annotationType);
+    List<Type> types = new ArrayList<Type>();
+    for (Type eachType : allTypes) {
+      int size = test.getAnnotationIndex(eachType).size();
+      if (!excludedTypes.contains(eachType.getName()) && size > 0
+              && !eachType.equals(test.getDocumentAnnotation().getType())) {
+        types.add(eachType);
+      }
+    }
+
+    List<AnnotationFS> testAnnotations = getAnnotations(types, test);
+    List<AnnotationFS> runAnnotations = getAnnotations(types, run);
+
+    Collection<AnnotationFS> matched = new HashSet<AnnotationFS>();
+    List<AnnotationFS> fp = new ArrayList<AnnotationFS>();
+    List<AnnotationFS> fn = new ArrayList<AnnotationFS>();
+    List<AnnotationFS> tp = new ArrayList<AnnotationFS>();
+
+    for (AnnotationFS eachTest : testAnnotations) {
+      boolean found = false;
+      for (AnnotationFS eachRun : runAnnotations) {
+        if (match(eachTest, eachRun)) {
+          matched.add(eachRun);
+          found = true;
+          break;
+        }
+      }
+      if (!found) {
+        AnnotationFS createAnnotation = run.createAnnotation(falseNegativeType,
+                eachTest.getBegin(), eachTest.getEnd());
+        Type type = run.getTypeSystem().getType(eachTest.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, eachTest.getBegin(), eachTest.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        fn.add(createAnnotation);
+      } else {
+        AnnotationFS createAnnotation = run.createAnnotation(truePositveType, eachTest.getBegin(),
+                eachTest.getEnd());
+        Type type = run.getTypeSystem().getType(eachTest.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, eachTest.getBegin(), eachTest.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        tp.add(createAnnotation);
+      }
+
+    }
+
+    for (AnnotationFS each : runAnnotations) {
+      if (!matched.contains(each)) {
+        AnnotationFS createAnnotation = run.createAnnotation(falsePositiveType, each.getBegin(),
+                each.getEnd());
+        Type type = run.getTypeSystem().getType(each.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, each.getBegin(), each.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        fp.add(createAnnotation);
+      }
+    }
+
+    for (AnnotationFS annotationFS : fn) {
+      run.addFsToIndexes(annotationFS);
+    }
+    for (AnnotationFS annotationFS : fp) {
+      run.addFsToIndexes(annotationFS);
+    }
+    for (AnnotationFS annotationFS : tp) {
+      run.addFsToIndexes(annotationFS);
+    }
+    return run;
+  }
+
+  private List<AnnotationFS> getAnnotations(List<Type> types, CAS cas) {
+    List<AnnotationFS> result = new ArrayList<AnnotationFS>();
+    for (Type type : types) {
+      FSIterator iterator = cas.getAnnotationIndex(type).iterator();
+      while (iterator.isValid()) {
+        FeatureStructure fs = iterator.get();
+        if (fs instanceof AnnotationFS) {
+          result.add((AnnotationFS) fs);
+        }
+        iterator.moveToNext();
+      }
+    }
+    return result;
+  }
+
+  private boolean match(AnnotationFS a1, AnnotationFS a2) {
+    if (a1 != null && a2 != null) {
+      if (a1.getBegin() == a2.getBegin() && a1.getEnd() == a2.getEnd()
+              && a1.getType().getName().equals(a2.getType().getName()))
+        return true;
+    }
+    return false;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluatorFactory.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluatorFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluatorFactory.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+public class ExactCasEvaluatorFactory implements ICasEvaluatorFactory {
+
+  public ICasEvaluator createEvaluator() {
+    return new ExactCasEvaluator();
+  }
+
+  public String getDescription() {
+    return "Compare the offsets of the given annotations.";
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ExactCasEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluator.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluator.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluator.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,419 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.CASRuntimeException;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.textmarker.engine.TextMarkerEngine;
+
+public class FeatureCasEvaluator implements ICasEvaluator {
+
+  @Override
+  public CAS evaluate(CAS test, CAS run, Collection<String> excludedTypes)
+          throws CASRuntimeException, CASException {
+
+    Type falsePositiveType = run.getTypeSystem().getType(ICasEvaluator.FALSE_POSITIVE);
+    Type falseNegativeType = run.getTypeSystem().getType(ICasEvaluator.FALSE_NEGATIVE);
+    Type truePositiveType = run.getTypeSystem().getType(ICasEvaluator.TRUE_POSITIVE);
+    Feature feature = falsePositiveType.getFeatureByBaseName(ICasEvaluator.ORIGINAL);
+    Type annotationType = test.getAnnotationType();
+    Type stringType = run.getTypeSystem().getType("uima.cas.String");
+    Type basicType = run.getTypeSystem().getType(TextMarkerEngine.BASIC_TYPE);
+    List<Type> allTypes = test.getTypeSystem().getProperlySubsumedTypes(annotationType);
+    List<Type> types = new ArrayList<Type>();
+    TypeSystem typeSystem = test.getTypeSystem();
+    for (Type eachType : allTypes) {
+      if (!excludedTypes.contains(eachType.getName())) {
+        List<Feature> features = eachType.getFeatures();
+        for (Feature f : features) {
+          Type range = f.getRange();
+          if (typeSystem.subsumes(annotationType, range) || typeSystem.subsumes(stringType, range)) {
+            if (!eachType.getName().startsWith("org.apache.uima.textmarker.type")
+                    && !typeSystem.subsumes(basicType, eachType)) {
+              types.add(eachType);
+              break;
+            }
+          }
+        }
+      }
+    }
+
+    // Here it is possible to select the relevant types from a file instead of using the HMI again
+    // to filter out irrelevant types …
+
+    Collection<FeatureStructure> runFSs = getFeatureStructures(types, run);
+    Collection<FeatureStructure> testFSs = getFeatureStructures(types, test);
+    Collection<FeatureStructure> matched = new HashSet<FeatureStructure>();
+    List<FeatureStructure> fp = new ArrayList<FeatureStructure>();
+    List<FeatureStructure> fn = new ArrayList<FeatureStructure>();
+    List<FeatureStructure> tp = new ArrayList<FeatureStructure>();
+    for (FeatureStructure eachTest : testFSs) {
+      boolean found = false;
+      for (FeatureStructure eachRun : runFSs) {
+        if (match(eachTest, eachRun)) {
+          matched.add(eachRun);
+
+          found = true;
+
+          break;
+
+        }
+
+      }
+
+      if (!found) {
+
+        FeatureStructure createFS = run.createFS(falseNegativeType);
+
+        fillFS(eachTest, createFS, false);
+
+        Type type = run.getTypeSystem().getType(eachTest.getType().getName());
+
+        FeatureStructure original = run.createFS(type);
+
+        fillFS(eachTest, original, true);
+
+        createFS.setFeatureValue(feature, original);
+
+        fn.add(createFS);
+
+      } else {
+
+        FeatureStructure createFS = run.createFS(truePositiveType);
+
+        fillFS(eachTest, createFS, false);
+
+        Type type = run.getTypeSystem().getType(eachTest.getType().getName());
+
+        FeatureStructure original = run.createFS(type);
+
+        fillFS(eachTest, original, true);
+
+        createFS.setFeatureValue(feature, original);
+
+        tp.add(createFS);
+
+      }
+
+    }
+
+    for (FeatureStructure each : runFSs) {
+
+      if (!matched.contains(each)) {
+
+        FeatureStructure createFS = run.createFS(falsePositiveType);
+
+        fillFS(each, createFS, false);
+
+        Type type = run.getTypeSystem().getType(each.getType().getName());
+
+        FeatureStructure original = run.createFS(type);
+
+        fillFS(each, original, true);
+
+        createFS.setFeatureValue(feature, original);
+
+        fp.add(createFS);
+
+      }
+
+    }
+
+    for (FeatureStructure fs : fn) {
+
+      run.addFsToIndexes(fs);
+
+    }
+
+    for (FeatureStructure fs : fp) {
+
+      run.addFsToIndexes(fs);
+
+    }
+
+    for (FeatureStructure fs : tp) {
+
+      run.addFsToIndexes(fs);
+
+    }
+
+    return run;
+
+  }
+
+  private void fillFS(FeatureStructure fs, FeatureStructure newFS, boolean withFeatures) {
+
+    if (fs instanceof AnnotationFS) {
+
+      Annotation a = (Annotation) newFS;
+
+      a.setBegin(((AnnotationFS) fs).getBegin());
+
+      a.setEnd(((AnnotationFS) fs).getEnd());
+
+    }
+
+    if (withFeatures) {
+
+      CAS testCas = fs.getCAS();
+
+      CAS runCas = newFS.getCAS();
+      TypeSystem testTS = testCas.getTypeSystem();
+      TypeSystem runTS = runCas.getTypeSystem();
+      Type annotationType = testCas.getAnnotationType();
+      List<Feature> features = fs.getType().getFeatures();
+      for (Feature feature : features) {
+        Type range = feature.getRange();
+        if (testTS.subsumes(annotationType, range)) {
+          FeatureStructure valueTest = fs.getFeatureValue(feature);
+          if (valueTest instanceof AnnotationFS) {
+            AnnotationFS a1 = (AnnotationFS) valueTest;
+            Feature feature2 = newFS.getType().getFeatureByBaseName(feature.getShortName());
+            if (feature != null) {
+              Type range2 = runTS.getType(range.getName());
+              AnnotationFS createAnnotation = runCas.createAnnotation(range2, a1.getBegin(),
+                      a1.getEnd());
+              newFS.setFeatureValue(feature2, createAnnotation);
+            }
+          }
+        }
+
+        if ("uima.cas.String".equals(range.getName())) {
+          String valueTest = fs.getFeatureValueAsString(feature);
+          if (valueTest != null) {
+            Feature feature2 = newFS.getType().getFeatureByBaseName(feature.getShortName());
+            newFS.setFeatureValueFromString(feature2, valueTest);
+          }
+        }
+      }
+
+    }
+
+  }
+
+  private Collection<FeatureStructure> getFeatureStructures(List<Type> types, CAS cas) {
+    TypeSystem typeSystem = cas.getTypeSystem();
+    Type annotationType = cas.getAnnotationType();
+    Type annotationBaseType = typeSystem.getType("uima.cas.AnnotationBase");
+    Collection<FeatureStructure> result = new HashSet<FeatureStructure>();
+    for (Type type : types) {
+      // if ((type != null) && !typeSystem.subsumes(cas.getAnnotationType(), type) &&
+      // !typeSystem.subsumes(annotationBaseType, type)
+      if (type != null) {
+        FSIterator<FeatureStructure> iterator = cas.getIndexRepository().getAllIndexedFS(type);
+        try {
+          iterator = cas.getView("_InitialView").getJCas().getIndexRepository()
+                  .getAllIndexedFS(type);
+        } catch (CASException e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+        }
+        // FSIterator<FeatureStructure> iterator=cas.getIndexRepository().getAllIndexedFS(type);;
+        while (iterator.isValid()) { // hasNext()
+          FeatureStructure fs = iterator.get();
+          List<Feature> features = fs.getType().getFeatures();
+          for (Feature feature : features) {
+            Type range = feature.getRange();
+            if (typeSystem.subsumes(annotationType, range)
+                    || "uima.cas.String".equals(range.getName())) {
+              result.add(fs);
+              break;
+            }
+          }
+          iterator.moveToNext();
+        }
+      }
+    }
+
+    return result;
+
+  }
+
+  private boolean match(FeatureStructure a1, FeatureStructure a2) {
+    Type type1 = a1.getType();
+    Type type2 = a2.getType();
+    if (!type1.getName().equals(type2.getName())) {
+      return false;
+    }
+    if (a1 instanceof AnnotationFS && a2 instanceof AnnotationFS) {
+      AnnotationFS a11 = (AnnotationFS) a1;
+      AnnotationFS a22 = (AnnotationFS) a2;
+      if (!contains(a11, a22) || !overlap(a11, a22)) {
+        // if (!(a11.getBegin() == a22.getBegin() && a11.getEnd() == a22.getEnd())) {
+        return false;
+      }
+    }
+
+    CAS cas = a1.getCAS();
+
+    TypeSystem typeSystem = cas.getTypeSystem();
+
+    Type annotationType = cas.getAnnotationType();
+
+    List<Feature> features1 = type1.getFeatures();
+
+    boolean result = true;
+
+    boolean allEmpty1 = true;
+
+    boolean allEmpty2 = true;
+
+    for (Feature eachFeature1 : features1) {
+
+      Type range = eachFeature1.getRange();
+
+      if (typeSystem.subsumes(annotationType, range)) {
+
+        String name = eachFeature1.getShortName();
+
+        Feature eachFeature2 = type2.getFeatureByBaseName(name);
+
+        FeatureStructure featureValue1 = a1.getFeatureValue(eachFeature1);
+
+        FeatureStructure featureValue2 = a2.getFeatureValue(eachFeature2);
+
+        allEmpty1 &= featureValue1 == null;
+
+        allEmpty2 &= featureValue2 == null;
+
+        if (featureValue1 instanceof AnnotationFS && featureValue2 instanceof AnnotationFS) {
+
+          result &= matchAnnotations((AnnotationFS) featureValue1, (AnnotationFS) featureValue2);
+
+        } else if (featureValue1 == null) {
+
+          // nothing to do
+
+        } else if (featureValue1 != null || featureValue2 != null) {
+
+          return false;
+
+        }
+
+      }
+
+      if ("uima.cas.String".equals(range.getName())) {
+
+        String name = eachFeature1.getShortName();
+
+        Feature eachFeature2 = type2.getFeatureByBaseName(name);
+
+        String featureValue1 = a1.getFeatureValueAsString(eachFeature1);
+
+        String featureValue2 = a2.getFeatureValueAsString(eachFeature2);
+
+        if ((featureValue2 == null || featureValue2.trim().isEmpty()) && (featureValue1 == null)) {
+
+          // nothing to do
+
+        }
+
+        else if (featureValue2.trim().toLowerCase().contains(featureValue1.trim().toLowerCase())) {
+
+          result &= true;
+
+        }
+
+        else if (featureValue1 != null || featureValue2 != null) {
+
+          // the unrelated values are put in uppercase
+
+          a1.setFeatureValueFromString(eachFeature1, featureValue1.toUpperCase());
+
+          a2.setFeatureValueFromString(eachFeature2, featureValue2.toUpperCase());
+
+          return false;
+
+        }
+
+      }
+
+    }
+
+    return result && (allEmpty1 == allEmpty2);
+
+  }
+
+  private boolean matchAnnotations(AnnotationFS a1, AnnotationFS a2) {
+
+    if (a1 != null && a2 != null) {
+
+      // if (a1.getBegin() == a2.getBegin() && a1.getEnd() == a2.getEnd()
+
+      if ((contains(a1, a2) || overlap(a1, a2))
+
+      && a1.getType().getName().equals(a2.getType().getName())) {
+
+        return true;
+
+      }
+
+    }
+
+    return false;
+
+  }
+
+  private boolean overlap(AnnotationFS a1, AnnotationFS a2) {
+
+    if (a1 != null && a2 != null) {
+
+      if ((a1.getBegin() <= a2.getBegin() && a1.getEnd() >= a2.getBegin())
+
+      || (a1.getBegin() >= a2.getBegin() && a1.getBegin() <= a2.getEnd()))
+
+        return true;
+
+    }
+
+    return false;
+
+  }
+
+  private boolean contains(AnnotationFS a1, AnnotationFS a2) {
+
+    if (a1 != null && a2 != null) {
+
+      if ((a1.getBegin() <= a2.getBegin() && a1.getEnd() >= a2.getEnd())
+
+      || (a1.getBegin() >= a2.getBegin() && a1.getEnd() <= a2.getEnd()))
+
+        return true;
+
+    }
+
+    return false;
+
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluatorFactory.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluatorFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluatorFactory.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+public class FeatureCasEvaluatorFactory implements ICasEvaluatorFactory {
+
+  public ICasEvaluator createEvaluator() {
+    return new FeatureCasEvaluator();
+  }
+
+  public String getDescription() {
+    return "Complex feature structures are compared. A feature structure is a true positive if all annotation and string feature values are correct.";
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/FeatureCasEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluator.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluator.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluator.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+import java.util.Collection;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.CASRuntimeException;
+
+public interface ICasEvaluator {
+
+  public static final String FALSE_NEGATIVE = "org.apache.uima.textmarker.type.FalseNegative";
+
+  public static final String FALSE_POSITIVE = "org.apache.uima.textmarker.type.FalsePositive";
+
+  public static final String TRUE_POSITIVE = "org.apache.uima.textmarker.type.TruePositive";
+
+  public static final String ORIGINAL = "original";
+
+  CAS evaluate(CAS test, CAS run, Collection<String> excludedTypes) throws CASRuntimeException,
+          CASException;
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluatorFactory.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluatorFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluatorFactory.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+public interface ICasEvaluatorFactory {
+
+  ICasEvaluator createEvaluator();
+
+  String getDescription();
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/ICasEvaluatorFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluator.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluator.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluator.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.CASRuntimeException;
+import org.apache.uima.cas.FSIterator;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+
+public class PartialMatchCasEvaluator implements ICasEvaluator {
+
+  public CAS evaluate(CAS test, CAS run, Collection<String> excludedTypes)
+          throws CASRuntimeException, CASException {
+    Type annotationType = test.getAnnotationType();
+    Type falsePositiveType = run.getTypeSystem().getType(ICasEvaluator.FALSE_POSITIVE);
+    Type falseNegativeType = run.getTypeSystem().getType(ICasEvaluator.FALSE_NEGATIVE);
+    Type truePositveType = run.getTypeSystem().getType(ICasEvaluator.TRUE_POSITIVE);
+
+    Feature feature = falsePositiveType.getFeatureByBaseName(ICasEvaluator.ORIGINAL);
+    List<Type> allTypes = test.getTypeSystem().getProperlySubsumedTypes(annotationType);
+    List<Type> types = new ArrayList<Type>();
+    for (Type eachType : allTypes) {
+      int size = test.getAnnotationIndex(eachType).size();
+      if (!excludedTypes.contains(eachType.getName()) && size > 0
+              && !eachType.equals(test.getDocumentAnnotation().getType())) {
+        types.add(eachType);
+      }
+    }
+
+    List<AnnotationFS> testAnnotations = getAnnotations(types, test);
+    List<AnnotationFS> runAnnotations = getAnnotations(types, run);
+
+    Collection<AnnotationFS> matched = new HashSet<AnnotationFS>();
+    List<AnnotationFS> fp = new ArrayList<AnnotationFS>();
+    List<AnnotationFS> fn = new ArrayList<AnnotationFS>();
+    List<AnnotationFS> tp = new ArrayList<AnnotationFS>();
+
+    for (AnnotationFS eachTest : testAnnotations) {
+      boolean found = false;
+      for (AnnotationFS eachRun : runAnnotations) {
+        if (contains(eachTest, eachRun) || overlap(eachTest, eachRun)) {
+          matched.add(eachRun);
+          found = true;
+          break;
+        }
+      }
+      if (!found) {
+        AnnotationFS createAnnotation = run.createAnnotation(falseNegativeType,
+                eachTest.getBegin(), eachTest.getEnd());
+        Type type = run.getTypeSystem().getType(eachTest.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, eachTest.getBegin(), eachTest.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        fn.add(createAnnotation);
+      } else {
+        AnnotationFS createAnnotation = run.createAnnotation(truePositveType, eachTest.getBegin(),
+                eachTest.getEnd());
+        Type type = run.getTypeSystem().getType(eachTest.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, eachTest.getBegin(), eachTest.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        tp.add(createAnnotation);
+      }
+
+    }
+
+    for (AnnotationFS each : runAnnotations) {
+      if (!matched.contains(each)) {
+        AnnotationFS createAnnotation = run.createAnnotation(falsePositiveType, each.getBegin(),
+                each.getEnd());
+        Type type = run.getTypeSystem().getType(each.getType().getName());
+        AnnotationFS original = run.createAnnotation(type, each.getBegin(), each.getEnd());
+        createAnnotation.setFeatureValue(feature, original);
+        fp.add(createAnnotation);
+      }
+    }
+
+    for (AnnotationFS annotationFS : fn) {
+      run.addFsToIndexes(annotationFS);
+    }
+    for (AnnotationFS annotationFS : fp) {
+      run.addFsToIndexes(annotationFS);
+    }
+    for (AnnotationFS annotationFS : tp) {
+      run.addFsToIndexes(annotationFS);
+    }
+    return run;
+  }
+
+  private List<AnnotationFS> getAnnotations(List<Type> types, CAS cas) {
+    List<AnnotationFS> result = new ArrayList<AnnotationFS>();
+    for (Type type : types) {
+      FSIterator iterator = cas.getAnnotationIndex(type).iterator();
+      while (iterator.isValid()) {
+        FeatureStructure fs = iterator.get();
+        if (fs instanceof AnnotationFS) {
+          result.add((AnnotationFS) fs);
+        }
+        iterator.moveToNext();
+      }
+    }
+    return result;
+  }
+
+  private boolean overlap(AnnotationFS a1, AnnotationFS a2) {
+    if (a1 != null && a2 != null) {
+      if ((a1.getBegin() <= a2.getBegin() && a1.getEnd() >= a2.getBegin())
+              || (a1.getBegin() >= a2.getBegin() && a1.getBegin() <= a2.getEnd()))
+        return true;
+    }
+    return false;
+  }
+
+  private boolean contains(AnnotationFS a1, AnnotationFS a2) {
+    if (a1 != null && a2 != null) {
+      if (a1.getBegin() <= a2.getBegin() && a1.getEnd() >= a2.getEnd())
+        return true;
+    }
+    return false;
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluator.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluatorFacotry.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluatorFacotry.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluatorFacotry.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluatorFacotry.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.textmarker.testing.evaluator;
+
+public class PartialMatchCasEvaluatorFacotry implements ICasEvaluatorFactory {
+
+  @Override
+  public ICasEvaluator createEvaluator() {
+    
+    return new PartialMatchCasEvaluator();
+  }
+
+  @Override
+  public String getDescription() {
+    return "Compares the offsets of the given annotations.\n" +
+    "Allows partial matching if the begin or end\n" + 
+    "character sequenze of the annotations match.";
+    
+  }
+
+}

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluatorFacotry.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/evaluator/PartialMatchCasEvaluatorFacotry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain