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/01 17:21:14 UTC
svn commit: r1152822 [3/3] - in
/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions:
./ META-INF/ bin/ icons/ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/uima/ src/main/jav...
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/ExplainSelectionViewFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/ExplainSelectionViewFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/ExplainSelectionViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/ExplainSelectionViewPage.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/ExplainSelectionViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/ExplainSelectionViewPage.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,51 @@
+package org.apache.uima.tm.textmarker.cev.explain.selection;
+
+import org.apache.uima.tm.cev.data.CEVDocument;
+import org.apache.uima.tm.cev.editor.CEVViewer;
+import org.apache.uima.tm.textmarker.cev.explain.apply.ApplyTreeContentProvider;
+import org.apache.uima.tm.textmarker.cev.explain.apply.ApplyTreeLabelProvider;
+import org.apache.uima.tm.textmarker.cev.explain.apply.ApplyViewPage;
+import org.apache.uima.tm.textmarker.cev.explain.tree.ApplyRootNode;
+import org.apache.uima.tm.textmarker.cev.explain.tree.ExplainTree;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class ExplainSelectionViewPage extends ApplyViewPage implements IExplainSelectionViewPage {
+
+ private int offset = -1;
+
+ public ExplainSelectionViewPage(CEVViewer casViewer, CEVDocument casDoc, int index) {
+ super(casViewer, casDoc, index);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new ApplyTreeContentProvider());
+ viewer.setLabelProvider(new ApplyTreeLabelProvider(this));
+
+ viewer.addDoubleClickListener(this);
+ viewer.addSelectionChangedListener(this);
+ viewer.setInput(new ApplyRootNode(null, getCurrentCEVData().getCAS().getTypeSystem()));
+ }
+
+ public void viewChanged(int newIndex) {
+ getCurrentCEVData().removeAnnotationListener(this);
+ current = newIndex;
+ getCurrentCEVData().addAnnotationListener(this);
+ newSelection(offset);
+ }
+
+ public void newSelection(int offset) {
+ this.offset = offset;
+
+ if (offset >= 0) {
+ ExplainTree tree = new ExplainTree(getCurrentCEVData(), offset);
+ viewer.setInput(tree.getRoot());
+ viewer.refresh();
+ }
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/ExplainSelectionViewPage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/ExplainSelectionViewPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/IExplainSelectionViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/IExplainSelectionViewPage.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/IExplainSelectionViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/IExplainSelectionViewPage.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,7 @@
+package org.apache.uima.tm.textmarker.cev.explain.selection;
+
+import org.apache.uima.tm.cev.views.ICEVViewPage;
+
+public interface IExplainSelectionViewPage extends ICEVViewPage {
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/IExplainSelectionViewPage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/selection/IExplainSelectionViewPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ApplyRootNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ApplyRootNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ApplyRootNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ApplyRootNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,15 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.TypeSystem;
+
+public class ApplyRootNode extends ExplainAbstractTreeNode implements ExplainRootNode {
+
+ public ApplyRootNode(IExplainTreeNode parent, TypeSystem typeSystem) {
+ super(parent, null, typeSystem);
+ }
+
+ @Override
+ public String toString() {
+ return "Applied";
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ApplyRootNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ApplyRootNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/BlockApplyNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/BlockApplyNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/BlockApplyNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/BlockApplyNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,22 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+
+public class BlockApplyNode extends ExplainAbstractTreeNode {
+
+ private RuleApplyNode blockRuleNode;
+
+ public RuleApplyNode getBlockRuleNode() {
+ return blockRuleNode;
+ }
+
+ public BlockApplyNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
+ super(parent, fs, ts);
+ }
+
+ public void setBlockRuleApply(RuleApplyNode ruleNode) {
+ this.blockRuleNode = ruleNode;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/BlockApplyNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/BlockApplyNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ConditionNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ConditionNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ConditionNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ConditionNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,21 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+
+public class ConditionNode extends ExplainAbstractTreeNode implements IEvaluatedNode {
+
+ private boolean matched;
+
+ public ConditionNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
+ super(parent, fs, ts);
+ Feature f = fs.getType().getFeatureByBaseName(ExplainTree.VALUE);
+ matched = fs.getBooleanValue(f);
+ }
+
+ public boolean matched() {
+ return matched;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ConditionNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ConditionNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainAbstractTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainAbstractTreeNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainAbstractTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainAbstractTreeNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,62 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+
+public abstract class ExplainAbstractTreeNode implements IExplainTreeNode {
+
+ private IExplainTreeNode parent;
+
+ private List<IExplainTreeNode> children;
+
+ private FeatureStructure fs;
+
+ private TypeSystem ts;
+
+ public ExplainAbstractTreeNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
+ this.parent = parent;
+ this.children = new ArrayList<IExplainTreeNode>();
+ this.fs = fs;
+ this.ts = ts;
+ }
+
+ public IExplainTreeNode getParent() {
+ return parent;
+ }
+
+ public List<IExplainTreeNode> getChildren() {
+ return children;
+ }
+
+ public boolean hasChildren() {
+ if (children.size() > 0) {
+ return true;
+ }
+ return false;
+ }
+
+ public void addChild(IExplainTreeNode child) {
+ children.add(child);
+ }
+
+ public boolean removeChild(IExplainTreeNode child) {
+ return children.remove(child);
+ }
+
+ public FeatureStructure getFeatureStructure() {
+ return fs;
+ }
+
+ public TypeSystem getTypeSystem() {
+ return ts;
+ }
+
+ @Override
+ public String toString() {
+ return fs.toString();
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainAbstractTreeNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainAbstractTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainRootNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainRootNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainRootNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainRootNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,5 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+public interface ExplainRootNode {
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainRootNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainRootNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainTree.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainTree.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainTree.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainTree.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,330 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.ArrayFS;
+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.tm.cev.data.CEVData;
+import org.apache.uima.tm.textmarker.cev.TextMarkerCEVPlugin;
+
+
+public class ExplainTree {
+
+ public static final String BASE_CONDITION = "baseCondition";
+
+ public static final String MATCHES = "matches";
+
+ public static final String ELEMENTS = "elements";
+
+ public static final String MATCHED = "matched";
+
+ public static final String DELEGATES = "delegates";
+
+ public static final String RULES = "rules";
+
+ public static final String INNER_APPLY = "innerApply";
+
+ public static final String CONDITIONS = "conditions";
+
+ public static final String VALUE = "value";
+
+ public static final String APPLIED = "applied";
+
+ public static final String TRIED = "tried";
+
+ public static final String ELEMENT = "element";
+
+ public static final String TIME = "time";
+
+ private IExplainTreeNode root;
+
+ private Type ruleMatchType;
+
+ private Type blockApplyType;
+
+ private Type ruleApplyType;
+
+ private Type ruleElementMatchType;
+
+ private Type ruleElementMatchesType;
+
+ private Type evaluatedConditionType;
+
+ private Type matchedRuleMatchType;
+
+ private Type failedRuleMatchType;
+
+ public ExplainTree(CEVData casData) {
+ this(casData, -1);
+ }
+
+ public ExplainTree(CEVData casData, int offset) {
+ this(casData, offset, false);
+ if (offset >= 0) {
+ prune(root);
+ }
+ }
+
+ public ExplainTree(CEVData casData, int offset, boolean onlyRules) {
+ createTree(casData, offset, onlyRules);
+ }
+
+ public IExplainTreeNode getRoot() {
+ return root;
+ }
+
+ private void createTree(CEVData casData, int offset, boolean onlyRules) {
+ TypeSystem ts = casData.getCAS().getTypeSystem();
+ Type scriptApply = ts.getType(TextMarkerCEVPlugin.SCRIPT_APPLY_TYPE);
+
+ blockApplyType = ts.getType(TextMarkerCEVPlugin.BLOCK_APPLY_TYPE);
+ ruleApplyType = ts.getType(TextMarkerCEVPlugin.RULE_APPLY_TYPE);
+ ruleMatchType = ts.getType(TextMarkerCEVPlugin.RULE_MATCH_TYPE);
+ matchedRuleMatchType = ts.getType(TextMarkerCEVPlugin.MATCHED_RULE_MATCH_TYPE);
+ failedRuleMatchType = ts.getType(TextMarkerCEVPlugin.FAILED_RULE_MATCH_TYPE);
+ ruleElementMatchType = ts.getType(TextMarkerCEVPlugin.RULE_ELEMENT_MATCH_TYPE);
+ ruleElementMatchesType = ts.getType(TextMarkerCEVPlugin.RULE_ELEMENT_MATCHES_TYPE);
+ evaluatedConditionType = ts.getType(TextMarkerCEVPlugin.EVAL_CONDITION_TYPE);
+
+ if (scriptApply == null)
+ return;
+ FSIterator<AnnotationFS> it = casData.getCAS().getAnnotationIndex(scriptApply).iterator();
+ root = new ApplyRootNode(null, ts);
+
+ if (it.isValid()) {
+ it.moveToFirst();
+ while (it.isValid()) {
+ AnnotationFS fs = it.get();
+ buildTree(fs, root, ts, offset, onlyRules);
+ it.moveToNext();
+ }
+ }
+
+ }
+
+ private void buildTree(FeatureStructure fs, IExplainTreeNode parent, TypeSystem ts, int offset,
+ boolean onlyRules) {
+ if (blockApplyType != null && blockApplyType.equals(fs.getType())) {
+ processBlockApply((AnnotationFS) fs, parent, ts, offset, onlyRules);
+ } else if (ruleApplyType != null && ruleApplyType.equals(fs.getType())) {
+ processRuleApply((AnnotationFS) fs, parent, ts, offset, onlyRules);
+ } else if ((matchedRuleMatchType != null && matchedRuleMatchType.equals(fs.getType()))
+ || (failedRuleMatchType != null && failedRuleMatchType.equals(fs.getType()))) {
+ processRuleMatch((AnnotationFS) fs, parent, ts, offset, onlyRules);
+ } else if (ruleElementMatchesType != null && ruleElementMatchesType.equals(fs.getType())) {
+ processRuleElementMatches(fs, parent, ts, offset, onlyRules);
+ } else if (ruleElementMatchType != null && ruleElementMatchType.equals(fs.getType())) {
+ processRuleElementMatch((AnnotationFS) fs, parent, ts, offset, onlyRules);
+ } else if (evaluatedConditionType != null && evaluatedConditionType.equals(fs.getType())) {
+ processEvaluatedCondition(fs, parent, ts, offset, onlyRules);
+ }
+ }
+
+ private void processBlockApply(AnnotationFS fs, IExplainTreeNode parent, TypeSystem ts,
+ int offset, boolean onlyRules) {
+ if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
+ return;
+ }
+ BlockApplyNode blockNode = null;
+ if (!onlyRules) {
+ blockNode = new BlockApplyNode(parent, fs, ts);
+ parent.addChild(blockNode);
+ processBlockRuleApply(fs, blockNode, ts, offset, onlyRules);
+ }
+ Feature feature = blockApplyType.getFeatureByBaseName(INNER_APPLY);
+ FeatureStructure featureValue = fs.getFeatureValue(feature);
+ ArrayFS value = (ArrayFS) featureValue;
+ FeatureStructure[] fsarray = value.toArray();
+ for (FeatureStructure each : fsarray) {
+ if (!onlyRules) {
+ buildTree(each, blockNode, ts, offset, onlyRules);
+ } else {
+ buildTree(each, parent, ts, offset, onlyRules);
+ }
+
+ }
+ }
+
+ private void processBlockRuleApply(AnnotationFS fs, BlockApplyNode parent, TypeSystem ts,
+ int offset, boolean onlyRules) {
+ if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
+ return;
+ }
+ RuleApplyNode ruleNode = new RuleApplyNode(parent, fs, ts);
+ parent.setBlockRuleApply(ruleNode);
+
+ Feature feature = ruleApplyType.getFeatureByBaseName(RULES);
+ ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
+ if (value == null)
+ return;
+ FeatureStructure[] fsarray = value.toArray();
+
+ MatchedRootNode matched = new MatchedRootNode(ruleNode, ts);
+ FailedRootNode failed = new FailedRootNode(ruleNode, ts);
+ ruleNode.addChild(matched);
+ ruleNode.addChild(failed);
+
+ for (FeatureStructure eachRuleMatch : fsarray) {
+ Feature f = eachRuleMatch.getType().getFeatureByBaseName(MATCHED);
+ boolean matchedValue = eachRuleMatch.getBooleanValue(f);
+ if (matchedValue) {
+ buildTree(eachRuleMatch, matched, ts, offset, onlyRules);
+ } else {
+ buildTree(eachRuleMatch, failed, ts, offset, onlyRules);
+ }
+
+ Feature df = eachRuleMatch.getType().getFeatureByBaseName(DELEGATES);
+ if (df != null) {
+ ArrayFS dv = (ArrayFS) eachRuleMatch.getFeatureValue(df);
+ if (dv != null) {
+ FeatureStructure[] da = dv.toArray();
+ for (FeatureStructure delegateFS : da) {
+ buildTree(delegateFS, ruleNode, ts, offset, onlyRules);
+ }
+ }
+ }
+
+ }
+ }
+
+ private void processRuleApply(AnnotationFS fs, IExplainTreeNode parent, TypeSystem ts,
+ int offset, boolean onlyRules) {
+ if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
+ return;
+ }
+ RuleApplyNode ruleNode = new RuleApplyNode(parent, fs, ts);
+ parent.addChild(ruleNode);
+
+ Feature feature = ruleApplyType.getFeatureByBaseName(RULES);
+ ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
+ FeatureStructure[] fsarray = value.toArray();
+
+ MatchedRootNode matched = new MatchedRootNode(ruleNode, ts);
+ FailedRootNode failed = new FailedRootNode(ruleNode, ts);
+ ruleNode.addChild(matched);
+ ruleNode.addChild(failed);
+
+ for (FeatureStructure eachRuleMatch : fsarray) {
+ Feature f = eachRuleMatch.getType().getFeatureByBaseName(MATCHED);
+ boolean matchedValue = eachRuleMatch.getBooleanValue(f);
+ if (matchedValue) {
+ buildTree(eachRuleMatch, matched, ts, offset, onlyRules);
+ } else {
+ buildTree(eachRuleMatch, failed, ts, offset, onlyRules);
+ }
+
+ Feature df = eachRuleMatch.getType().getFeatureByBaseName(DELEGATES);
+ if (df != null) {
+ ArrayFS dv = (ArrayFS) eachRuleMatch.getFeatureValue(df);
+ if (dv != null) {
+ FeatureStructure[] da = dv.toArray();
+ for (FeatureStructure delegateFS : da) {
+ buildTree(delegateFS, ruleNode, ts, offset, onlyRules);
+ }
+ }
+ }
+
+ }
+ }
+
+ private void processRuleMatch(AnnotationFS fs, IExplainTreeNode parent, TypeSystem ts,
+ int offset, boolean onlyRules) {
+ if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
+ return;
+ }
+ RuleMatchNode matchNode = new RuleMatchNode(parent, fs, ts);
+ parent.addChild(matchNode);
+
+ RuleElementRootNode remRoot = new RuleElementRootNode(matchNode, ts);
+ matchNode.addChild(remRoot);
+
+ Feature feature = ruleMatchType.getFeatureByBaseName(ELEMENTS);
+ ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
+ FeatureStructure[] fsarray = value.toArray();
+ for (FeatureStructure each : fsarray) {
+ buildTree(each, remRoot, ts, offset, onlyRules);
+ }
+ }
+
+ private void processRuleElementMatches(FeatureStructure fs, IExplainTreeNode parent,
+ TypeSystem ts, int offset, boolean onlyRules) {
+ RuleElementMatchesNode remsNode = new RuleElementMatchesNode(parent, fs, ts);
+ parent.addChild(remsNode);
+
+ Feature feature = ruleElementMatchesType.getFeatureByBaseName(MATCHES);
+ ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
+ FeatureStructure[] fsarray = value.toArray();
+ for (FeatureStructure each : fsarray) {
+ buildTree(each, remsNode, ts, offset, onlyRules);
+ }
+ }
+
+ private void processRuleElementMatch(AnnotationFS fs, IExplainTreeNode parent, TypeSystem ts,
+ int offset, boolean onlyRules) {
+ if (offset >= 0 && (fs.getBegin() >= offset || fs.getEnd() <= offset)) {
+ return;
+ }
+ RuleElementMatchNode remNode = new RuleElementMatchNode(parent, fs, ts);
+ parent.addChild(remNode);
+
+ Feature feature = ruleElementMatchType.getFeatureByBaseName(BASE_CONDITION);
+ FeatureStructure base = fs.getFeatureValue(feature);
+ buildTree(base, remNode, ts, offset, onlyRules);
+
+ feature = ruleElementMatchType.getFeatureByBaseName(CONDITIONS);
+ ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
+ FeatureStructure[] fsarray = value.toArray();
+ for (FeatureStructure each : fsarray) {
+ buildTree(each, remNode, ts, offset, onlyRules);
+ }
+ }
+
+ private void processEvaluatedCondition(FeatureStructure fs, IExplainTreeNode parent,
+ TypeSystem ts, int offset, boolean onlyRules) {
+ ConditionNode condNode = new ConditionNode(parent, fs, ts);
+ parent.addChild(condNode);
+
+ Feature feature = evaluatedConditionType.getFeatureByBaseName(CONDITIONS);
+ ArrayFS value = (ArrayFS) fs.getFeatureValue(feature);
+ if (value != null) {
+ FeatureStructure[] fsarray = value.toArray();
+ for (FeatureStructure each : fsarray) {
+ buildTree(each, condNode, ts, offset, onlyRules);
+ }
+ }
+ }
+
+ private void prune(IExplainTreeNode node) {
+ List<IExplainTreeNode> children = node.getChildren();
+ IExplainTreeNode parent = node.getParent();
+ for (IExplainTreeNode each : new ArrayList<IExplainTreeNode>(children)) {
+ prune(each);
+ }
+ if (node instanceof ApplyRootNode) {
+ } else if (node instanceof BlockApplyNode) {
+ } else if (node instanceof ConditionNode) {
+ } else if (node instanceof FailedRootNode) {
+ if (!node.hasChildren()) {
+ parent.removeChild(node);
+ }
+ } else if (node instanceof MatchedRootNode) {
+ if (!node.hasChildren()) {
+ parent.removeChild(node);
+ }
+ } else if (node instanceof RuleApplyNode) {
+ if (!node.hasChildren()) {
+ parent.removeChild(node);
+ }
+ } else if (node instanceof RuleElementMatchesNode) {
+ } else if (node instanceof RuleElementMatchNode) {
+ } else if (node instanceof RuleElementRootNode) {
+ } else if (node instanceof RuleMatchNode) {
+ }
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainTree.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/ExplainTree.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/FailedRootNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/FailedRootNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/FailedRootNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/FailedRootNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,15 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.TypeSystem;
+
+public class FailedRootNode extends ExplainAbstractTreeNode implements ExplainRootNode {
+
+ public FailedRootNode(IExplainTreeNode parent, TypeSystem ts) {
+ super(parent, null, ts);
+ }
+
+ @Override
+ public String toString() {
+ return "Failed";
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/FailedRootNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/FailedRootNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IEvaluatedNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IEvaluatedNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IEvaluatedNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IEvaluatedNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,7 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+public interface IEvaluatedNode {
+
+ boolean matched();
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IEvaluatedNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IEvaluatedNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IExplainTreeNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IExplainTreeNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IExplainTreeNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IExplainTreeNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,23 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import java.util.List;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+
+public interface IExplainTreeNode {
+
+ IExplainTreeNode getParent();
+
+ List<IExplainTreeNode> getChildren();
+
+ boolean hasChildren();
+
+ void addChild(IExplainTreeNode node);
+
+ boolean removeChild(IExplainTreeNode node);
+
+ FeatureStructure getFeatureStructure();
+
+ TypeSystem getTypeSystem();
+}
\ No newline at end of file
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IExplainTreeNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/IExplainTreeNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/MatchedRootNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/MatchedRootNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/MatchedRootNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/MatchedRootNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,15 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.TypeSystem;
+
+public class MatchedRootNode extends ExplainAbstractTreeNode implements ExplainRootNode {
+
+ public MatchedRootNode(IExplainTreeNode parent, TypeSystem ts) {
+ super(parent, null, ts);
+ }
+
+ @Override
+ public String toString() {
+ return "Matched";
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/MatchedRootNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/MatchedRootNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleApplyNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleApplyNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleApplyNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleApplyNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,34 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+
+public class RuleApplyNode extends ExplainAbstractTreeNode {
+
+ private FailedRootNode failedNode;
+
+ private MatchedRootNode matchedNode;
+
+ public RuleApplyNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
+ super(parent, fs, ts);
+ }
+
+ @Override
+ public void addChild(IExplainTreeNode node) {
+ super.addChild(node);
+ if (node instanceof FailedRootNode) {
+ failedNode = (FailedRootNode) node;
+ } else if (node instanceof MatchedRootNode) {
+ matchedNode = (MatchedRootNode) node;
+ }
+ }
+
+ public FailedRootNode getFailedNode() {
+ return failedNode;
+ }
+
+ public MatchedRootNode getMatchedChild() {
+ return matchedNode;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleApplyNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleApplyNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,45 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.ArrayFS;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.tm.cev.data.tree.ICEVAnnotationNode;
+
+
+public class RuleElementMatchNode extends ExplainAbstractTreeNode implements IEvaluatedNode,
+ ICEVAnnotationNode {
+
+ private boolean matched;
+
+ public RuleElementMatchNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
+ super(parent, fs, ts);
+ Feature f = fs.getType().getFeatureByBaseName(ExplainTree.BASE_CONDITION);
+ FeatureStructure baseFS = fs.getFeatureValue(f);
+ Feature baseFeat = baseFS.getType().getFeatureByBaseName(ExplainTree.VALUE);
+ matched = baseFS.getBooleanValue(baseFeat);
+
+ f = fs.getType().getFeatureByBaseName(ExplainTree.CONDITIONS);
+ ArrayFS value = (ArrayFS) fs.getFeatureValue(f);
+ FeatureStructure[] fsarray = value.toArray();
+ for (FeatureStructure each : fsarray) {
+ Feature eachFeat = each.getType().getFeatureByBaseName(ExplainTree.VALUE);
+ boolean eachValue = each.getBooleanValue(eachFeat);
+ matched &= eachValue;
+ }
+ }
+
+ public boolean matched() {
+ return matched;
+ }
+
+ public AnnotationFS getAnnotation() {
+ FeatureStructure fs = getFeatureStructure();
+ if (fs instanceof AnnotationFS) {
+ return (AnnotationFS) fs;
+ }
+ return null;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchesNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchesNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchesNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchesNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,22 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+
+public class RuleElementMatchesNode extends ExplainAbstractTreeNode implements IEvaluatedNode {
+
+ public RuleElementMatchesNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
+ super(parent, fs, ts);
+ }
+
+ public boolean matched() {
+ boolean result = true;
+ for (IExplainTreeNode each : getChildren()) {
+ if (each instanceof IEvaluatedNode) {
+ result &= ((IEvaluatedNode) each).matched();
+ }
+ }
+ return result;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchesNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementMatchesNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementRootNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementRootNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementRootNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementRootNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,15 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.TypeSystem;
+
+public class RuleElementRootNode extends ExplainAbstractTreeNode implements ExplainRootNode {
+
+ public RuleElementRootNode(IExplainTreeNode parent, TypeSystem ts) {
+ super(parent, null, ts);
+ }
+
+ @Override
+ public String toString() {
+ return "Element";
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementRootNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleElementRootNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleMatchNode.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleMatchNode.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleMatchNode.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleMatchNode.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,23 @@
+package org.apache.uima.tm.textmarker.cev.explain.tree;
+
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.tm.cev.data.tree.ICEVAnnotationNode;
+
+
+public class RuleMatchNode extends ExplainAbstractTreeNode implements ICEVAnnotationNode {
+
+ public RuleMatchNode(IExplainTreeNode parent, FeatureStructure fs, TypeSystem ts) {
+ super(parent, fs, ts);
+ }
+
+ public AnnotationFS getAnnotation() {
+ FeatureStructure fs = getFeatureStructure();
+ if (fs instanceof AnnotationFS) {
+ return (AnnotationFS) fs;
+ }
+ return null;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleMatchNode.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/explain/tree/RuleMatchNode.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategy.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategy.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategy.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategy.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,77 @@
+package org.apache.uima.tm.textmarker.cev.searchStrategy;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.uima.tm.cev.dialog.CEVCollectionContentProvider;
+import org.apache.uima.tm.cev.extension.ICEVSearchStrategy;
+import org.apache.uima.tm.dltk.internal.core.builder.TextMarkerProjectUtils;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.dialogs.ListDialog;
+
+
+public class DescriptorFolderSearchStrategy implements ICEVSearchStrategy {
+
+ private int priority;
+
+ public DescriptorFolderSearchStrategy(int priority) {
+ super();
+ this.priority = priority;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public IFile searchDescriptor(IFile file) {
+ IProject project = file.getProject();
+ IFolder folder = project.getFolder(TextMarkerProjectUtils.getDefaultDescriptorLocation());
+ try {
+ List<IFile> list = collectTypeSystems(folder);
+ ListDialog ld = new ListDialog(Display.getCurrent().getActiveShell());
+ ld.setContentProvider(new CEVCollectionContentProvider<LinkedList<IFile>>());
+ ld.setLabelProvider(new LabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return ((IFile) element).getName();
+ }
+ });
+ if (list == null || list.isEmpty()) {
+ return null;
+ }
+
+ ld.setTitle("Select Type System Descriptor");
+ ld.setInput(list);
+ ld.open();
+
+ if (ld.getResult() != null) {
+ return (IFile) ld.getResult()[0];
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ return null;
+ }
+
+ }
+
+ private List<IFile> collectTypeSystems(IFolder folder) throws CoreException {
+ List<IFile> result = new ArrayList<IFile>();
+ for (IResource each : folder.members()) {
+ if (each instanceof IFolder) {
+ result.addAll(collectTypeSystems((IFolder) each));
+ } else if (each instanceof IFile && each.getFileExtension() != null
+ && each.getFileExtension().equals("xml")) {
+ result.add((IFile) each);
+ }
+ }
+ return result;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategy.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategy.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategyFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategyFactory.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategyFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategyFactory.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,15 @@
+package org.apache.uima.tm.textmarker.cev.searchStrategy;
+
+import org.apache.uima.tm.cev.extension.ICEVSearchStrategy;
+import org.apache.uima.tm.cev.extension.ICEVSearchStrategyFactory;
+
+public class DescriptorFolderSearchStrategyFactory implements ICEVSearchStrategyFactory {
+
+ public DescriptorFolderSearchStrategyFactory() {
+ }
+
+ public ICEVSearchStrategy createSearchStrategy(int priority) {
+ return new DescriptorFolderSearchStrategy(priority);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategyFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/DescriptorFolderSearchStrategyFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategy.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategy.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategy.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategy.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,48 @@
+package org.apache.uima.tm.textmarker.cev.searchStrategy;
+
+import org.apache.uima.tm.cev.extension.ICEVSearchStrategy;
+import org.apache.uima.tm.dltk.internal.core.builder.TextMarkerProjectUtils;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.dltk.internal.launching.LaunchConfigurationUtils;
+import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
+
+
+public class LastLaunchSearchStrategy implements ICEVSearchStrategy {
+
+ private int priority;
+
+ public LastLaunchSearchStrategy(int priority) {
+ super();
+ this.priority = priority;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public IFile searchDescriptor(IFile file) {
+ IProject project = file.getProject();
+ ILaunchConfiguration lastRun = DebugUITools
+ .getLastLaunch("org.eclipse.debug.ui.launchGroup.run");
+ String scriptName = LaunchConfigurationUtils.getString(lastRun,
+ ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME, "");
+ if (scriptName != null && scriptName.length() != 0 && new Path(scriptName).segmentCount() > 0
+ && Path.ROOT.isValidPath(scriptName)) {
+ final IFile scriptFile = project.getFile(scriptName);
+ if (scriptFile.exists()) {
+ IPath path = TextMarkerProjectUtils.getTypeSystemDescriptorPath(scriptFile
+ .getProjectRelativePath(), project);
+ IFile ts = project.getFile(path.makeRelativeTo(project.getLocation()));
+ if (ts.exists()) {
+ return ts;
+ }
+ }
+ }
+ return null;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategy.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategy.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategyFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategyFactory.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategyFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategyFactory.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,12 @@
+package org.apache.uima.tm.textmarker.cev.searchStrategy;
+
+import org.apache.uima.tm.cev.extension.ICEVSearchStrategy;
+import org.apache.uima.tm.cev.extension.ICEVSearchStrategyFactory;
+
+public class LastLaunchSearchStrategyFactory implements ICEVSearchStrategyFactory {
+
+ public ICEVSearchStrategy createSearchStrategy(int priority) {
+ return new LastLaunchSearchStrategy(priority);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategyFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/searchStrategy/LastLaunchSearchStrategyFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/EntryComparator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/EntryComparator.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/EntryComparator.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/EntryComparator.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,42 @@
+package org.apache.uima.tm.textmarker.cev.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/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/EntryComparator.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/EntryComparator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/IStatisticsViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/IStatisticsViewPage.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/IStatisticsViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/IStatisticsViewPage.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,7 @@
+package org.apache.uima.tm.textmarker.cev.statistics;
+
+import org.apache.uima.tm.cev.views.ICEVViewPage;
+
+public interface IStatisticsViewPage extends ICEVViewPage {
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/IStatisticsViewPage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/IStatisticsViewPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsContentProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsContentProvider.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsContentProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsContentProvider.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,23 @@
+package org.apache.uima.tm.textmarker.cev.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/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsContentProvider.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsContentProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsEntry.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsEntry.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsEntry.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsEntry.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,87 @@
+package org.apache.uima.tm.textmarker.cev.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.tm.textmarker.kernel.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/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsEntry.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsEntry.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsLabelProvider.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsLabelProvider.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsLabelProvider.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsLabelProvider.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,37 @@
+package org.apache.uima.tm.textmarker.cev.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/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsLabelProvider.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsLabelProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsView.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsView.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsView.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsView.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,18 @@
+package org.apache.uima.tm.textmarker.cev.statistics;
+
+import org.apache.uima.tm.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/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsView.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsView.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewFactory.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewFactory.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,21 @@
+package org.apache.uima.tm.textmarker.cev.statistics;
+
+import org.apache.uima.tm.cev.data.CEVDocument;
+import org.apache.uima.tm.cev.editor.CEVViewer;
+import org.apache.uima.tm.cev.extension.ICEVView;
+import org.apache.uima.tm.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/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewPage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewPage.java?rev=1152822&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewPage.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewPage.java Mon Aug 1 15:20:50 2011
@@ -0,0 +1,262 @@
+package org.apache.uima.tm.textmarker.cev.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.tm.cev.data.CEVData;
+import org.apache.uima.tm.cev.data.CEVDocument;
+import org.apache.uima.tm.cev.editor.CEVViewer;
+import org.apache.uima.tm.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.tm.textmarker.kernel.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/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewPage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textmarker.cev.extensions/src/main/java/org/apache/uima/tm/textmarker/cev/statistics/StatisticsViewPage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain