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 [10/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/...
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveView.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveView.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewFactory.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewFactory.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.ui.views.fp;
+
+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 FalsePositiveViewFactory implements ICEVViewFactory {
+
+ public FalsePositiveViewFactory() {
+ }
+
+ @Override
+ public ICEVView createView(CEVViewer viewer, CEVDocument cevDocument, int index) {
+ return new FalsePositiveViewPage(viewer, cevDocument, index);
+ }
+
+ @Override
+ public Class<?> getAdapterInterface() {
+ return IFalsePositiveViewPage.class;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewPage.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewPage.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,189 @@
+/*
+ * 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.ui.views.fp;
+
+import java.util.List;
+import java.util.Map;
+
+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.apache.uima.cev.views.CEVAnnotationTreeViewDragListener;
+import org.apache.uima.textmarker.testing.ui.views.tree.TestEvaluationTree;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+
+
+public class FalsePositiveViewPage extends Page implements IFalsePositiveViewPage,
+ IDoubleClickListener, ICEVView, ISelectionChangedListener {
+
+ private CEVViewer casViewer;
+
+ private CEVDocument casDoc;
+
+ private CheckboxTreeViewer viewer;
+
+ int current = 0;
+
+ private Map<String, Image> images;
+
+ public FalsePositiveViewPage(CEVViewer casViewer, CEVDocument casDoc, int index) {
+ super();
+ this.casViewer = casViewer;
+ this.casDoc = casDoc;
+ this.current = index;
+ }
+
+ @Override
+ public Control getControl() {
+ return viewer.getControl();
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+ @Override
+ public void init(IPageSite pageSite) {
+ super.init(pageSite);
+ }
+
+ public TreeViewer getTreeViewer() {
+ return viewer;
+ }
+
+ public CEVData getCurrentCEVData() {
+ return casDoc.getCASData(current);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ viewer = new CheckboxTreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new FalsePositiveContentProvider());
+ viewer.setLabelProvider(new FalsePositiveLabelProvider(this));
+ viewer.addCheckStateListener(casDoc.getCASData(current));
+ viewer.addDoubleClickListener(this);
+ viewer.addSelectionChangedListener(this);
+ TestEvaluationTree tree = new TestEvaluationTree();
+ tree.createTree(getCurrentCEVData().getCAS());
+
+ int ops = DND.DROP_COPY | DND.DROP_MOVE;
+ Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
+ viewer.addDragSupport(ops, transfers, new CEVAnnotationTreeViewDragListener(viewer));
+
+ viewer.setInput(tree);
+ viewer.refresh();
+ }
+
+ public void doubleClick(DoubleClickEvent event) {
+
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (images != null) {
+ for (Image each : images.values()) {
+ each.dispose();
+ }
+ }
+ }
+
+ public void mouseDown(final MouseEvent event) {
+
+ }
+
+ public void mouseUp(final MouseEvent event) {
+
+ }
+
+ public void mouseDoubleClick(final MouseEvent event) {
+
+ }
+
+ public void viewChanged(int newIndex) {
+ getCurrentCEVData().removeAnnotationListener(this);
+ current = newIndex;
+ getCurrentCEVData().addAnnotationListener(this);
+
+ TestEvaluationTree tree = new TestEvaluationTree();
+ tree.createTree(getCurrentCEVData().getCAS());
+ viewer.setInput(tree.getRoot());
+ 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) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof ITreeSelection) {
+ ITreeSelection struct = (ITreeSelection) selection;
+ Object firstElement = struct.getFirstElement();
+
+ }
+ }
+
+ public void casChanged(CEVDocument casDocument) {
+ this.casDoc = casDocument;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewPage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/FalsePositiveViewPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/IFalsePositiveViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/IFalsePositiveViewPage.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/IFalsePositiveViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/IFalsePositiveViewPage.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,27 @@
+/*
+ * 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.ui.views.fp;
+
+import org.apache.uima.cev.views.ICEVViewPage;
+
+
+public interface IFalsePositiveViewPage extends ICEVViewPage {
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/IFalsePositiveViewPage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/fp/IFalsePositiveViewPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/ITruePositiveViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/ITruePositiveViewPage.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/ITruePositiveViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/ITruePositiveViewPage.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,27 @@
+/*
+ * 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.ui.views.tp;
+
+import org.apache.uima.cev.views.ICEVViewPage;
+
+
+public interface ITruePositiveViewPage extends ICEVViewPage {
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/ITruePositiveViewPage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/ITruePositiveViewPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveContentProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveContentProvider.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveContentProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveContentProvider.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,97 @@
+/*
+ * 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.ui.views.tp;
+
+import org.apache.uima.cev.data.tree.CEVAnnotationTreeNode;
+import org.apache.uima.cev.data.tree.CEVTypeTreeNode;
+import org.apache.uima.cev.data.tree.ICEVTreeNode;
+import org.apache.uima.textmarker.testing.ui.views.tree.TestEvaluationTree;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class TruePositiveContentProvider implements ITreeContentProvider {
+
+ private Object[] empty = new Object[] {};
+
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof TestEvaluationTree) {
+ CEVTypeTreeNode root = (CEVTypeTreeNode) ((TestEvaluationTree) parentElement).getRoot();
+ if (root == null) {
+ return empty;
+ }
+ for (ICEVTreeNode node : root.getChildren()) {
+ if (node instanceof CEVTypeTreeNode) {
+ if (((CEVTypeTreeNode) node).getType().getName()
+ .equals("org.apache.uima.textmarker.type.TruePositive")) {
+ return node.getChildren();
+ }
+ }
+ }
+ }
+ if (parentElement instanceof CEVTypeTreeNode) {
+
+ CEVTypeTreeNode node = (CEVTypeTreeNode) parentElement;
+ return node.getChildren();
+ }
+ if (parentElement instanceof CEVAnnotationTreeNode) {
+ CEVAnnotationTreeNode node = (CEVAnnotationTreeNode) parentElement;
+ return node.getChildren();
+ }
+ return empty;
+ }
+
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof ICEVTreeNode) {
+ return ((ICEVTreeNode) element).getParent();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof TestEvaluationTree) {
+ CEVTypeTreeNode root = (CEVTypeTreeNode) ((TestEvaluationTree) element).getRoot();
+ return root.hasChildren();
+
+ }
+ if (element instanceof ICEVTreeNode) {
+ return ((ICEVTreeNode) element).hasChildren();
+ }
+ return false;
+ }
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ @Override
+ public void dispose() {
+
+ }
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveContentProvider.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveContentProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveLabelProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveLabelProvider.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveLabelProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveLabelProvider.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,83 @@
+/*
+ * 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.ui.views.tp;
+
+import org.apache.uima.cev.data.tree.CEVAnnotationTreeNode;
+import org.apache.uima.cev.data.tree.CEVFeatureTreeNode;
+import org.apache.uima.cev.data.tree.CEVTypeTreeNode;
+import org.apache.uima.cev.views.TextUtils;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class TruePositiveLabelProvider extends LabelProvider implements ILabelProvider {
+
+ private TruePositiveViewPage owner;
+
+ public TruePositiveLabelProvider() {
+ super();
+ }
+
+ public TruePositiveLabelProvider(TruePositiveViewPage owner) {
+ super();
+ this.owner = owner;
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof CEVAnnotationTreeNode) {
+ CEVAnnotationTreeNode fnNode = (CEVAnnotationTreeNode) element;
+ if (fnNode.getAnnotation() != null) {
+ String typeName = fnNode.getAnnotation().getType().getName();
+ String coveredText = fnNode.getAnnotation().getCoveredText();
+ coveredText = coveredText.replaceAll("[\\n]", "").replaceAll("[\\r]", "");
+ if (typeName.equals("org.apache.uima.textmarker.type.FalsePositive")
+ || typeName.equals("org.apache.uima.textmarker.type.FalseNegative")
+ || typeName.equals("org.apache.uima.textmarker.type.TruePositive")) {
+ return coveredText;
+ }
+ String name = TextUtils.shrinkNamespace(fnNode.getAnnotation().getType().getName());
+ return (name + ": " + coveredText);
+ }
+ }
+ if (element instanceof CEVTypeTreeNode) {
+ CEVTypeTreeNode testNode = (CEVTypeTreeNode) element;
+ return TextUtils.shrinkNamespace(testNode.getType().getName());
+ }
+ if (element instanceof CEVFeatureTreeNode) {
+ CEVFeatureTreeNode fNode = (CEVFeatureTreeNode) element;
+ return fNode.getName();
+ }
+
+ return "error";
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof CEVTypeTreeNode) {
+ return owner.getCurrentCEVData().getIcon(((CEVTypeTreeNode) element).getType());
+ }
+ if (element instanceof CEVAnnotationTreeNode) {
+ return owner.getCurrentCEVData().getIcon(
+ ((CEVAnnotationTreeNode) element).getAnnotation().getType());
+ }
+ return null;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveLabelProvider.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveLabelProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.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.ui.views.tp;
+
+import org.apache.uima.cev.views.CEVPageBookView;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class TruePositiveView extends CEVPageBookView {
+
+ public TruePositiveView() {
+ super();
+ }
+
+ @Override
+ protected PageRec doCreatePage(IWorkbenchPart part) {
+ return doCreatePage(part, ITruePositiveViewPage.class);
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveView.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewFactory.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewFactory.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,43 @@
+/*
+ * 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.ui.views.tp;
+
+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 TruePositiveViewFactory implements ICEVViewFactory {
+
+ public TruePositiveViewFactory() {
+ }
+
+ @Override
+ public ICEVView createView(CEVViewer viewer, CEVDocument cevDocument, int index) {
+ return new TruePositiveViewPage(viewer, cevDocument, index);
+ }
+
+ @Override
+ public Class<?> getAdapterInterface() {
+ return ITruePositiveViewPage.class;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewPage.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewPage.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,189 @@
+/*
+ * 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.ui.views.tp;
+
+import java.util.List;
+import java.util.Map;
+
+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.apache.uima.cev.views.CEVAnnotationTreeViewDragListener;
+import org.apache.uima.textmarker.testing.ui.views.tree.TestEvaluationTree;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+
+
+public class TruePositiveViewPage extends Page implements ITruePositiveViewPage,
+ IDoubleClickListener, ICEVView, ISelectionChangedListener {
+
+ private CEVViewer casViewer;
+
+ private CEVDocument casDoc;
+
+ private CheckboxTreeViewer viewer;
+
+ int current = 0;
+
+ private Map<String, Image> images;
+
+ public TruePositiveViewPage(CEVViewer casViewer, CEVDocument casDoc, int index) {
+ super();
+ this.casViewer = casViewer;
+ this.casDoc = casDoc;
+ this.current = index;
+ }
+
+ @Override
+ public Control getControl() {
+ return viewer.getControl();
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getControl().setFocus();
+ }
+
+ @Override
+ public void init(IPageSite pageSite) {
+ super.init(pageSite);
+ }
+
+ public TreeViewer getTreeViewer() {
+ return viewer;
+ }
+
+ public CEVData getCurrentCEVData() {
+ return casDoc.getCASData(current);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ viewer = new CheckboxTreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new TruePositiveContentProvider());
+ viewer.setLabelProvider(new TruePositiveLabelProvider(this));
+ viewer.addCheckStateListener(casDoc.getCASData(current));
+ viewer.addDoubleClickListener(this);
+ viewer.addSelectionChangedListener(this);
+ TestEvaluationTree tree = new TestEvaluationTree();
+ tree.createTree(getCurrentCEVData().getCAS());
+
+ int ops = DND.DROP_COPY | DND.DROP_MOVE;
+ Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
+ viewer.addDragSupport(ops, transfers, new CEVAnnotationTreeViewDragListener(viewer));
+
+ viewer.setInput(tree);
+ viewer.refresh();
+ }
+
+ public void doubleClick(DoubleClickEvent event) {
+
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (images != null) {
+ for (Image each : images.values()) {
+ each.dispose();
+ }
+ }
+ }
+
+ public void mouseDown(final MouseEvent event) {
+
+ }
+
+ public void mouseUp(final MouseEvent event) {
+
+ }
+
+ public void mouseDoubleClick(final MouseEvent event) {
+
+ }
+
+ public void viewChanged(int newIndex) {
+ getCurrentCEVData().removeAnnotationListener(this);
+ current = newIndex;
+ getCurrentCEVData().addAnnotationListener(this);
+
+ TestEvaluationTree tree = new TestEvaluationTree();
+ tree.createTree(getCurrentCEVData().getCAS());
+ viewer.setInput(tree.getRoot());
+ 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) {
+ ISelection selection = event.getSelection();
+ if (selection instanceof ITreeSelection) {
+ ITreeSelection struct = (ITreeSelection) selection;
+ Object firstElement = struct.getFirstElement();
+
+ }
+ }
+
+ public void casChanged(CEVDocument casDocument) {
+ this.casDoc = casDocument;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewPage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tp/TruePositiveViewPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,109 @@
+/*
+ * 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.ui.views.tree;
+
+import org.apache.uima.cas.CAS;
+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;
+import org.apache.uima.cev.data.tree.CEVAnnotationTreeNode;
+import org.apache.uima.cev.data.tree.CEVTypeTreeNode;
+import org.apache.uima.cev.data.tree.ICEVTreeNode;
+import org.apache.uima.textmarker.testing.evaluator.ICasEvaluator;
+
+
+public class TestEvaluationTree {
+
+ private CEVTypeTreeNode root;
+
+ public TestEvaluationTree() {
+
+ }
+
+ public void createTree(CAS cas) {
+ Type falsePositiveType = cas.getTypeSystem().getType(ICasEvaluator.FALSE_POSITIVE);
+ Type falseNegativeType = cas.getTypeSystem().getType(ICasEvaluator.FALSE_NEGATIVE);
+ Type truePositiveType = cas.getTypeSystem().getType(ICasEvaluator.TRUE_POSITIVE);
+
+ if (falsePositiveType == null || falseNegativeType == null) {
+ return;
+ }
+ // Creating RootNode and children that function as root nodes
+ // for the FalsePositive /FalseNegative subtrees
+ root = new CEVTypeTreeNode(null, cas.getAnnotationType());
+ boolean containsEvalInfos = false;
+
+ CEVTypeTreeNode fproot = new CEVTypeTreeNode(root, falsePositiveType);
+ CEVTypeTreeNode fnroot = new CEVTypeTreeNode(root, falseNegativeType);
+ CEVTypeTreeNode tproot = new CEVTypeTreeNode(root, truePositiveType);
+
+ // Iterating through CAS and adding nodes to according subtrees
+
+ addEvalNodes(cas, falsePositiveType, fproot);
+ addEvalNodes(cas, falseNegativeType, fnroot);
+ addEvalNodes(cas, truePositiveType, tproot);
+
+ // if (containsEvalInfos) {
+ root.addChild(fproot);
+ root.addChild(fnroot);
+ root.addChild(tproot);
+ // }
+ }
+
+ private void addEvalNodes(CAS cas, Type falsePositiveType, CEVTypeTreeNode fproot) {
+ FSIterator<AnnotationFS> iter = cas.getAnnotationIndex(falsePositiveType).iterator();
+ while (iter.isValid()) {
+ FeatureStructure fs = iter.get();
+ if (fs instanceof AnnotationFS) {
+ AnnotationFS a = (AnnotationFS) fs;
+ Feature original = fs.getType().getFeatureByBaseName(ICasEvaluator.ORIGINAL);
+ FeatureStructure originalfs = fs.getFeatureValue(original);
+ CEVTypeTreeNode parentTypeNode = containsTypeNode(fproot, originalfs);
+ if (parentTypeNode == null && originalfs != null) {
+ parentTypeNode = new CEVTypeTreeNode(fproot, originalfs.getType());
+ fproot.addChild(parentTypeNode);
+ }
+ CEVAnnotationTreeNode newNode = new CEVAnnotationTreeNode(parentTypeNode, a);
+ parentTypeNode.addChild(newNode);
+ }
+ iter.moveToNext();
+ }
+ }
+
+ private CEVTypeTreeNode containsTypeNode(CEVTypeTreeNode fproot, FeatureStructure originalfs) {
+ ICEVTreeNode[] children = fproot.getChildren();
+ for (ICEVTreeNode each : children) {
+ if (each instanceof CEVTypeTreeNode) {
+ CEVTypeTreeNode node = (CEVTypeTreeNode) each;
+ if (node.getType().equals(originalfs.getType())) {
+ return node;
+ }
+ }
+ }
+ return null;
+ }
+
+ public ICEVTreeNode getRoot() {
+ return this.root;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/tree/TestEvaluationTree.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/CASLoader.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/CASLoader.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/CASLoader.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/CASLoader.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,90 @@
+/*
+ * 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.ui.views.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.resource.metadata.FsIndexDescription;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
+import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.util.CasCreationUtils;
+import org.apache.uima.util.XMLInputSource;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+
+public class CASLoader {
+
+ public static CAS loadCas(IResource r, IPath file) {
+ String elementName = r.getLocation().lastSegment();
+ // Remove Fileend if elementName exists
+ int lastIndexOf = elementName.lastIndexOf(".tm");
+ if (lastIndexOf != -1) {
+ elementName = elementName.substring(0, lastIndexOf);
+ }
+
+ IPath engineDescriptorPath = TextMarkerProjectUtils.getEngineDescriptorPath(r.getLocation(),
+ r.getProject());
+ try {
+ XMLInputSource in = new XMLInputSource(engineDescriptorPath.toPortableString());
+ ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
+ AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(specifier);
+
+ String desc = null;
+ desc = engineDescriptorPath.toPortableString();
+ XMLInputSource in2 = new XMLInputSource(desc);
+ Object descriptor = UIMAFramework.getXMLParser().parse(in2);
+ CAS testCas = null;
+ if (descriptor instanceof AnalysisEngineDescription) {
+ testCas = CasCreationUtils.createCas((AnalysisEngineDescription) descriptor);
+ } else if (descriptor instanceof TypeSystemDescription) {
+ TypeSystemDescription tsDesc = (TypeSystemDescription) descriptor;
+ tsDesc.resolveImports();
+ testCas = CasCreationUtils.createCas(tsDesc, null, new FsIndexDescription[0]);
+ // TODO: where are the type priorities?
+ }
+
+ FileInputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(
+ // resource.getLocation().toFile()
+ new File(file.toPortableString()));
+
+ XmiCasDeserializer.deserialize(inputStream, testCas, true);
+
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ return testCas;
+ } catch (Exception e) {
+ TextMarkerIdePlugin.error(e);
+ }
+ return null;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/CASLoader.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/CASLoader.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Caretaker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Caretaker.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Caretaker.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Caretaker.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,125 @@
+/*
+ * 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.ui.views.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.uima.textmarker.testing.ui.views.TestCasData;
+import org.eclipse.jface.viewers.TableViewer;
+
+
+public class Caretaker {
+
+ private class SaveStateAdapter implements Runnable {
+
+ private TableViewer viewer;
+
+ private ArrayList list;
+
+ public SaveStateAdapter(TableViewer viewer, ArrayList list) {
+ this.viewer = viewer;
+ this.list = list;
+ }
+
+ @Override
+ public void run() {
+ viewer.setInput(list);
+
+ }
+
+ }
+
+ LinkedList<ArrayList<TestCasData>> memento;
+
+ int index;
+
+ public Caretaker() {
+ memento = new LinkedList();
+ memento.add(new ArrayList<TestCasData>());
+ index = 0;
+
+ }
+
+ public Caretaker(ArrayList<TestCasData> firstElement) {
+ memento = new LinkedList();
+ memento.add(firstElement);
+ index = 0;
+ }
+
+ public void saveState(TableViewer viewer) {
+ ArrayList state = (ArrayList) viewer.getInput();
+
+ index++;
+
+ ArrayList<TestCasData> newState = new ArrayList<TestCasData>();
+
+ Iterator<TestCasData> iter = state.iterator();
+
+ if (index < memento.size()) {
+ for (int i = index; i < memento.size(); i++) {
+ memento.remove(i);
+ }
+ }
+
+ while (iter.hasNext()) {
+ newState.add(iter.next());
+ }
+ memento.add(index, state);
+
+ viewer.getControl().getDisplay().asyncExec(new SaveStateAdapter(viewer, newState));
+ }
+
+ public Object getMemento(int newIndex) {
+ if (index <= 0) {
+ index = 0;
+ return memento.get(0);
+ }
+
+ if (memento.size() > index) {
+ return memento.get(index);
+ }
+
+ if (memento.size() <= index) {
+ index = memento.size() - 1;
+ return memento.get(memento.size() - 1);
+ }
+
+ index = memento.size();
+ return memento.get(index);
+ }
+
+ public Object getPreviousState() {
+ index--;
+ if (index < 0) {
+ index = 0;
+ }
+ return getMemento(index);
+ }
+
+ public Object getNextState() {
+ index++;
+ if (index > memento.size() - 1) {
+ index = memento.size() - 1;
+ }
+ return getMemento(index);
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Caretaker.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Caretaker.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/EvalDataProcessor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/EvalDataProcessor.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/EvalDataProcessor.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/EvalDataProcessor.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,132 @@
+/*
+ * 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.ui.views.util;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.apache.uima.cas.CAS;
+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.cas.text.AnnotationIndex;
+import org.apache.uima.textmarker.testing.evaluator.ICasEvaluator;
+import org.apache.uima.textmarker.testing.ui.views.TestCasData;
+import org.apache.uima.textmarker.testing.ui.views.evalDataTable.TypeEvalData;
+
+
+public class EvalDataProcessor {
+
+ public static void calculateEvaluatData(TestCasData data, CAS resultCas) {
+ data.setEvaluationStatus(true);
+ TypeSystem ts = resultCas.getTypeSystem();
+ Type falsePositiveType = ts.getType(ICasEvaluator.FALSE_POSITIVE);
+ Type falseNegativeType = ts.getType(ICasEvaluator.FALSE_NEGATIVE);
+ Type truePositiveType = ts.getType(ICasEvaluator.TRUE_POSITIVE);
+
+ Feature originalFeature = truePositiveType.getFeatureByBaseName("original");
+
+ int falsePositiveCount = resultCas.getAnnotationIndex(falsePositiveType).size();
+ int falseNegativeCount = resultCas.getAnnotationIndex(falseNegativeType).size();
+ int truePositiveCount = resultCas.getAnnotationIndex(truePositiveType).size();
+
+ data.setTruePositiveCount(truePositiveCount);
+ data.setFalsePositiveCount(falsePositiveCount);
+ data.setFalseNegativeCount(falseNegativeCount);
+
+ HashMap<String, TypeEvalData> map = new HashMap<String, TypeEvalData>();
+
+ map.put(" Total", new TypeEvalData("Total", truePositiveCount, falsePositiveCount,
+ falseNegativeCount));
+
+ AnnotationIndex<AnnotationFS> index = resultCas.getAnnotationIndex(truePositiveType);
+
+ FSIterator iter = index.iterator();
+
+ if (originalFeature != null) {
+
+ while (iter.isValid()) {
+ AnnotationFS a = (AnnotationFS) iter.next();
+
+ FeatureStructure fs = a.getFeatureValue(originalFeature);
+ String typeName = fs.getType().getName();
+
+ if (map.containsKey(typeName)) {
+ TypeEvalData element = (TypeEvalData) map.get(typeName);
+ int oldCount = element.getTruePositives();
+ element.setTruePositives(oldCount + 1);
+ } else {
+ TypeEvalData newData = new TypeEvalData(typeName, 1, 0, 0);
+ map.put(typeName, newData);
+ }
+ }
+
+ index = resultCas.getAnnotationIndex(falsePositiveType);
+ iter = index.iterator();
+
+ while (iter.isValid()) {
+ AnnotationFS a = (AnnotationFS) iter.next();
+
+ FeatureStructure fs = a.getFeatureValue(originalFeature);
+ String typeName = fs.getType().getName();
+
+ if (map.containsKey(typeName)) {
+ TypeEvalData element = (TypeEvalData) map.get(typeName);
+ int oldCount = element.getFalsePositives();
+ element.setFalsePositives(oldCount + 1);
+ } else {
+ TypeEvalData newData = new TypeEvalData(typeName, 0, 1, 0);
+ map.put(typeName, newData);
+ }
+ }
+
+ index = resultCas.getAnnotationIndex(falseNegativeType);
+ iter = index.iterator();
+
+ while (iter.isValid()) {
+ AnnotationFS a = (AnnotationFS) iter.next();
+
+ FeatureStructure fs = a.getFeatureValue(originalFeature);
+ String typeName = fs.getType().getName();
+
+ if (map.containsKey(typeName)) {
+ TypeEvalData element = (TypeEvalData) map.get(typeName);
+ int oldCount = element.getFalseNegatives();
+ element.setFalseNegatives(oldCount + 1);
+ } else {
+ TypeEvalData newData = new TypeEvalData(typeName, 0, 0, 1);
+ map.put(typeName, newData);
+ }
+ }
+
+ data.setTypeEvalData(map);
+
+ Collection<TypeEvalData> col = map.values();
+ for (TypeEvalData typeEvalData : col) {
+ typeEvalData.calcFOne();
+ }
+
+ return;
+ }
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/EvalDataProcessor.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/EvalDataProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Memento.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Memento.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Memento.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Memento.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.testing.ui.views.util;
+
+import java.util.ArrayList;
+
+import org.apache.uima.textmarker.testing.ui.views.TestCasData;
+
+
+public class Memento {
+
+ private ArrayList<TestCasData> testFileList;
+
+ public Memento (ArrayList<TestCasData> testData) {
+ this.testFileList = testData;
+ }
+
+ public ArrayList<TestCasData> getTestFileList () {
+ return this.testFileList;
+ }
+
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Memento.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/testing/ui/views/util/Memento.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstarctApplyScriptHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstarctApplyScriptHandler.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstarctApplyScriptHandler.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstarctApplyScriptHandler.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,69 @@
+/*
+ * 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.utils.apply;
+
+import org.apache.uima.textmarker.addons.TextMarkerAddonsPlugin;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.part.FileEditorInput;
+
+public abstract class AbstarctApplyScriptHandler implements IHandler {
+
+ public void addHandlerListener(IHandlerListener handlerListener) {
+ }
+
+ public void dispose() {
+ }
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbench workbench = TextMarkerAddonsPlugin.getDefault().getWorkbench();
+ IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
+ IEditorPart part = page.getActiveEditor();
+ IEditorInput editorInput = part.getEditorInput();
+ if (editorInput instanceof FileEditorInput) {
+ FileEditorInput input = (FileEditorInput) editorInput;
+ IFile path = input.getFile();
+ getJob(event, path).schedule();
+ }
+ return null;
+ }
+
+ abstract AbstractApplyScriptHandlerJob getJob(ExecutionEvent event, IFile path);
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public boolean isHandled() {
+ return true;
+ }
+
+ public void removeHandlerListener(IHandlerListener handlerListener) {
+
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstarctApplyScriptHandler.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstarctApplyScriptHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstractApplyScriptHandlerJob.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstractApplyScriptHandlerJob.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstractApplyScriptHandlerJob.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstractApplyScriptHandlerJob.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,235 @@
+/*
+ * 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.utils.apply;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.cas.impl.XmiCasSerializer;
+import org.apache.uima.resource.ResourceManager;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.textmarker.engine.TextMarkerEngine;
+import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
+import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLSerializer;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.xml.sax.SAXException;
+
+public abstract class AbstractApplyScriptHandlerJob extends Job {
+ private ExecutionEvent event;
+
+ private IFile scriptFile;
+
+ private boolean createXMI;
+
+ AbstractApplyScriptHandlerJob(ExecutionEvent event, IFile scriptFile, boolean createXMI) {
+ super("Applying " + scriptFile.getName() + "...");
+ this.event = event;
+ this.scriptFile = scriptFile;
+ this.createXMI = createXMI;
+ setUser(true);
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("Collecting files...", 1);
+
+ if (HandlerUtil.getCurrentSelection(event) instanceof IStructuredSelection) {
+ StructuredSelection selection = (StructuredSelection) HandlerUtil.getCurrentSelection(event);
+ Iterator<?> iter = selection.iterator();
+ IResource first = null;
+
+ List<IPath> paths = new ArrayList<IPath>();
+ while (iter.hasNext()) {
+ Object object = iter.next();
+ if (object instanceof IResource) {
+ IResource resource = (IResource) object;
+ if (first == null) {
+ first = resource;
+ }
+ paths.addAll(getPaths(resource));
+ }
+ }
+ IPath descriptorPath = TextMarkerProjectUtils.getEngineDescriptorPath(
+ scriptFile.getLocation(), scriptFile.getProject());
+ IPath rootPath = TextMarkerProjectUtils.getDescriptorRootPath(scriptFile.getProject());
+
+ CAS cas = null;
+ AnalysisEngine ae = null;
+ try {
+ XMLInputSource in = new XMLInputSource(descriptorPath.toPortableString());
+ ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);
+ ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
+ resMgr.setDataPath(rootPath.toPortableString());
+ ae = UIMAFramework.produceAnalysisEngine(specifier, resMgr, null);
+ initAE(ae);
+ ae.reconfigure();
+ } catch (Exception e) {
+ DLTKCore.error(e.getMessage(), e);
+ return Status.CANCEL_STATUS;
+ }
+ monitor.beginTask("Processing... ", paths.size());
+ for (IPath path : paths) {
+ if (monitor.isCanceled()) {
+ break;
+ }
+
+ monitor.setTaskName("Processing " + path.lastSegment() + "... ");
+ try {
+
+ if (cas == null) {
+ cas = ae.newCAS();
+ } else {
+ cas.reset();
+ }
+ if (path.getFileExtension().equals("xmi")) {
+ XmiCasDeserializer.deserialize(new FileInputStream(path.toPortableString()), cas, true);
+ } else {
+ cas.setDocumentText(getText(path.toPortableString()));
+ }
+ TextMarkerEngine.removeSourceDocumentInformation(cas);
+ TextMarkerEngine.addSourceDocumentInformation(cas, new File(path.toPortableString()));
+ ae.process(cas);
+ } catch (Exception e) {
+ DLTKCore.error(e.getMessage(), e);
+ monitor.worked(1);
+ continue;
+ }
+
+ if (createXMI) {
+ monitor.setTaskName("Writing " + path.lastSegment() + "... ");
+
+ File newFile = null;
+ if (path.getFileExtension().equals("xmi")) {
+ newFile = new File(path.toPortableString());
+ } else {
+ newFile = new File(path.toPortableString() + ".xmi");
+ }
+ try {
+ writeXmi(cas, newFile);
+ } catch (Exception e) {
+ DLTKCore.error(e.getMessage(), e);
+ monitor.worked(1);
+ continue;
+ }
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ IPath makeRelativeTo = path.makeRelativeTo(root.getLocation());
+ IResource resource = root.findMember(makeRelativeTo);
+
+ try {
+ if (resource != null) {
+ resource.getParent()
+ .refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+ } catch (CoreException e) {
+ }
+ }
+ monitor.worked(1);
+ }
+ if (cas != null) {
+ cas.release();
+ }
+ }
+
+ monitor.done();
+ return Status.OK_STATUS;
+
+ }
+
+ private static void writeXmi(CAS aCas, File name) throws IOException, SAXException {
+ FileOutputStream out = null;
+
+ try {
+ // write XMI
+ out = new FileOutputStream(name);
+ XmiCasSerializer ser = new XmiCasSerializer(aCas.getTypeSystem());
+ XMLSerializer xmlSer = new XMLSerializer(out, false);
+ ser.serialize(aCas, xmlSer.getContentHandler());
+ } catch (Exception e) {
+ TextMarkerIdePlugin.error(e);
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ private List<IPath> getPaths(IResource resource) {
+ List<IPath> paths = new ArrayList<IPath>();
+ if (resource instanceof IFile) {
+ IFile file = (IFile) resource;
+ String fileExtension = file.getFileExtension();
+ if ("txt".equals(fileExtension) || "html".equals(fileExtension)
+ || "xmi".equals(fileExtension) || "htm".equals(fileExtension)) {
+ paths.add(file.getLocation());
+ }
+ } else if (resource instanceof IFolder) {
+ IFolder folder = (IFolder) resource;
+ try {
+ IResource[] members = folder.members();
+ for (IResource each : members) {
+ paths.addAll(getPaths(each));
+ }
+ } catch (CoreException e) {
+ }
+ }
+ return paths;
+ }
+
+ abstract void initAE(AnalysisEngine ae);
+
+ private static String getText(String each) {
+ try {
+ return org.apache.uima.pear.util.FileUtil.loadTextFile(new File(each), "UTF-8");
+ } catch (IOException e) {
+ DLTKCore.error(e.getMessage(), e);
+ }
+ return "";
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstractApplyScriptHandlerJob.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/AbstractApplyScriptHandlerJob.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsHandler.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsHandler.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsHandler.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.utils.apply;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IFile;
+
+public class ApplyScriptKeepBasicsHandler extends AbstarctApplyScriptHandler {
+
+ @Override
+ AbstractApplyScriptHandlerJob getJob(ExecutionEvent event, IFile path) {
+ return new ApplyScriptKeepBasicsJob(event, path);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsHandler.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsJob.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsJob.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsJob.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsJob.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.utils.apply;
+
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.textmarker.engine.TextMarkerEngine;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IFile;
+
+
+public class ApplyScriptKeepBasicsJob extends AbstractApplyScriptHandlerJob {
+
+ ApplyScriptKeepBasicsJob(ExecutionEvent event, IFile scriptFile) {
+ super(event, scriptFile, true);
+ }
+
+ @Override
+ void initAE(AnalysisEngine ae) {
+ ae.setConfigParameterValue(TextMarkerEngine.REMOVE_BASICS, false);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsJob.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptKeepBasicsJob.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIHandler.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIHandler.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIHandler.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.utils.apply;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IFile;
+
+public class ApplyScriptNoXMIHandler extends AbstarctApplyScriptHandler {
+
+ @Override
+ AbstractApplyScriptHandlerJob getJob(ExecutionEvent event, IFile path) {
+ return new ApplyScriptNoXMIJob(event, path);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIHandler.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIJob.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIJob.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIJob.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIJob.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.utils.apply;
+
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.textmarker.engine.TextMarkerEngine;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IFile;
+
+
+public class ApplyScriptNoXMIJob extends AbstractApplyScriptHandlerJob {
+
+ ApplyScriptNoXMIJob(ExecutionEvent event, IFile scriptFile) {
+ super(event, scriptFile, false);
+ }
+
+ @Override
+ void initAE(AnalysisEngine ae) {
+ ae.setConfigParameterValue(TextMarkerEngine.REMOVE_BASICS, false);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIJob.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptNoXMIJob.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsHandler.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsHandler.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsHandler.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.utils.apply;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IFile;
+
+public class ApplyScriptRemoveBasicsHandler extends AbstarctApplyScriptHandler {
+
+ @Override
+ AbstractApplyScriptHandlerJob getJob(ExecutionEvent event, IFile path) {
+ return new ApplyScriptRemoveBasicsJob(event, path);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsHandler.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsJob.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsJob.java?rev=1157050&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsJob.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsJob.java Fri Aug 12 11:14:14 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.utils.apply;
+
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.textmarker.engine.TextMarkerEngine;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.resources.IFile;
+
+
+public class ApplyScriptRemoveBasicsJob extends AbstractApplyScriptHandlerJob {
+
+ ApplyScriptRemoveBasicsJob(ExecutionEvent event, IFile scriptFile) {
+ super(event, scriptFile, true);
+ }
+
+ @Override
+ void initAE(AnalysisEngine ae) {
+ ae.setConfigParameterValue(TextMarkerEngine.REMOVE_BASICS, true);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsJob.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-addons/src/main/java/org/apache/uima/textmarker/utils/apply/ApplyScriptRemoveBasicsJob.java
------------------------------------------------------------------------------
svn:mime-type = text/plain