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/09/22 14:49:53 UTC

svn commit: r1174099 [1/8] - in /uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker: ./ action/ condition/ constraint/ engine/ parser/ resource/ rule/ rule/quantifier/ type/ verbalize/ visitor/

Author: joern
Date: Thu Sep 22 12:49:48 2011
New Revision: 1174099

URL: http://svn.apache.org/viewvc?rev=1174099&view=rev
Log:
UIMA-2207 New implementation of the rule inference.

Added:
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/AnnotationComparator.java   (with props)
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/ComposedRuleElementMatch.java   (with props)
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleElementCaretaker.java   (with props)
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleElementComparator.java   (with props)
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleElementContainer.java   (with props)
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleElementIsolator.java   (with props)
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerDisjunctiveTypeMatcher.java   (with props)
Removed:
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/DummyFSIterator.java
Modified:
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/FilterManager.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerAutomataBlock.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerBlock.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptBlock.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractStructureAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractTextMarkerAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AddAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AssignAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CallAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ClearAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ColorAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ComposedAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CreateAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DelAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExecAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/FillAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/FilterMarkupAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/FilterTypeAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/GatherAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/GetAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/GetFeatureAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/GetListAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/LogAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/MarkAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/MarkFastAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/MarkLastAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/MarkOnceAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/MarkTableAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/MatchedTextAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/MergeAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RemoveAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RemoveDuplicateAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ReplaceAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainMarkupAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/RetainTypeAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/SetFeatureAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TransferAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TrieAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/TypeSensitiveAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/UnmarkAllAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/VariableAction.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AbstractTextMarkerCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AfterCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/AndCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/BeforeCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ComposedTextMarkerCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContainsCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ContextCountCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/CountCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/CurrentCountCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/EndsWithCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/FeatureCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/IfCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/InListCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/IsCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/IsInTagCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/LastCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/MOfNCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/NearCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/NotCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/OrCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ParseCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/PartOfCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/PartOfNeqCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/PositionCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/RegExpCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/ScoreCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/SizeCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/StartsWithCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/TerminalTextMarkerCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/TotalCountCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/TypeSentiveCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/VariableCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/condition/VoteCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/constraint/BasicTypeConstraint.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/engine/TextMarkerEngine.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/engine/TextMarkerModifier.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.g
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/parser/TextMarkerParser.tokens
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/resource/AnonymousWordList.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/resource/MultiTreeWordList.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/AbstractRuleElement.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/ComposedRuleElement.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/EvaluatedCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleApply.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleElement.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleElementMatch.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/RuleMatch.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerLiteralMatcher.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerMatcher.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRule.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerRuleElement.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/TextMarkerTypeMatcher.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/MinMaxGreedy.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/MinMaxReluctant.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/NormalQuantifier.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/PlusGreedy.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/PlusReluctant.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/QuestionGreedy.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/QuestionReluctant.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/RuleElementQuantifier.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/StarGreedy.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/rule/quantifier/StarReluctant.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugBlockApply.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugBlockApply_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugEvaluatedCondition.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugEvaluatedCondition_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugFailedRuleMatch.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugFailedRuleMatch_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugMatchedRuleMatch.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugMatchedRuleMatch_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugRuleApply.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugRuleApply_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugRuleElementMatch.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugRuleElementMatch_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugRuleElementMatches.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugRuleElementMatches_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugRuleMatch.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugRuleMatch_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugScriptApply.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/DebugScriptApply_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/EvalAnnotation.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/EvalAnnotation_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/FalseNegative.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/FalseNegative_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/FalsePositive.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/FalsePositive_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/ProfiledAnnotation.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/ProfiledAnnotation_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/Statistics.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/Statistics_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TextMarkerAnnotation.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TextMarkerAnnotation_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TextMarkerBasic.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TextMarkerBasic_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TextMarkerColoring.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TextMarkerColoring_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TextMarkerFrame.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TextMarkerFrame_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TruePositive.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/type/TruePositive_Type.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/verbalize/ScriptVerbalizer.java
    uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/visitor/DebugInfoFactory.java

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/FilterManager.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/FilterManager.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/FilterManager.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/FilterManager.java Thu Sep 22 12:49:48 2011
@@ -167,11 +167,7 @@ public class FilterManager {
   }
 
   private FSMatchConstraint createTypeConstraint(Collection<Type> types) {
-    List<String> typeList = new ArrayList<String>();
-    for (Type each : types) {
-      typeList.add(each.getName());
-    }
-    BasicTypeConstraint result = new BasicTypeConstraint(cf.createTypeConstraint(), typeList, null);
+    BasicTypeConstraint result = new BasicTypeConstraint(cf.createTypeConstraint(), types);
     for (Type each : types) {
       result.add(each);
     }
@@ -230,8 +226,7 @@ public class FilterManager {
     return windowType;
   }
 
-  public FSIterator<AnnotationFS> createFilteredIterator(CAS cas, FSIterator<AnnotationFS> basic,
-          Type basicType) {
+  public FSIterator<AnnotationFS> createFilteredIterator(CAS cas, Type basicType) {
     if (windowAnnotation != null) {
       FSIterator<AnnotationFS> windowIt = cas.getAnnotationIndex(basicType).subiterator(
               windowAnnotation);

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerAutomataBlock.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerAutomataBlock.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerAutomataBlock.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerAutomataBlock.java Thu Sep 22 12:49:48 2011
@@ -27,6 +27,7 @@ import org.apache.uima.cas.text.Annotati
 import org.apache.uima.textmarker.rule.RuleApply;
 import org.apache.uima.textmarker.rule.RuleMatch;
 import org.apache.uima.textmarker.rule.TextMarkerRule;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
 public class TextMarkerAutomataBlock extends TextMarkerBlock {
@@ -44,15 +45,18 @@ public class TextMarkerAutomataBlock ext
     RuleApply apply = rule.apply(stream, crowd, true);
     for (RuleMatch eachMatch : apply.getList()) {
       if (eachMatch.matched()) {
-        AnnotationFS each = eachMatch.getMatchedAnnotation(stream, null);
+        AnnotationFS each = eachMatch.getMatchedAnnotations(stream, null, null).get(0);
         if (each == null) {
           continue;
         }
-        Type type = rule.getElements().get(0).getMatcher().getType(getParent(), stream);
-        TextMarkerStream window = stream.getWindowStream(each, type);
-        for (TextMarkerStatement element : getElements()) {
-          if (element != null) {
-            element.apply(window, crowd);
+        List<Type> types = ((TextMarkerRuleElement) rule.getRuleElements().get(0)).getMatcher()
+                .getTypes(getParent(), stream);
+        for (Type eachType : types) {
+          TextMarkerStream window = stream.getWindowStream(each, eachType);
+          for (TextMarkerStatement element : getElements()) {
+            if (element != null) {
+              element.apply(window, crowd);
+            }
           }
         }
       }
@@ -64,7 +68,7 @@ public class TextMarkerAutomataBlock ext
   @Override
   public String toString() {
     String ruleString = rule == null ? "Document" : rule.toString();
-    return "BLOCK(" + id + ") " + ruleString + " containing " + elements.size() + " Elements";
+    return "RULES(" + id + ") " + ruleString + " containing " + elements.size() + " Elements";
   }
 
   public void setMatchRule(TextMarkerRule rule) {

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerBlock.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerBlock.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerBlock.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerBlock.java Thu Sep 22 12:49:48 2011
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.textmarker;
 
@@ -24,7 +24,6 @@ import java.util.List;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.textmarker.rule.TextMarkerRule;
 
-
 public abstract class TextMarkerBlock extends TextMarkerStatement {
 
   protected final String id;
@@ -53,6 +52,10 @@ public abstract class TextMarkerBlock ex
     return rule;
   }
 
+  public void setRule(TextMarkerRule rule) {
+    this.rule = rule;
+  }
+
   @Override
   public TextMarkerEnvironment getEnvironment() {
     return environment;
@@ -67,7 +70,6 @@ public abstract class TextMarkerBlock ex
   }
 
   public TextMarkerModule getScript() {
-    // TODO refactor!
     if (getParent() != null) {
       return getParent().getScript();
     } else {

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptBlock.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptBlock.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptBlock.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptBlock.java Thu Sep 22 12:49:48 2011
@@ -27,6 +27,7 @@ import org.apache.uima.cas.text.Annotati
 import org.apache.uima.textmarker.rule.RuleApply;
 import org.apache.uima.textmarker.rule.RuleMatch;
 import org.apache.uima.textmarker.rule.TextMarkerRule;
+import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
 public class TextMarkerScriptBlock extends TextMarkerBlock {
@@ -43,15 +44,22 @@ public class TextMarkerScriptBlock exten
     RuleApply apply = rule.apply(stream, crowd, true);
     for (RuleMatch eachMatch : apply.getList()) {
       if (eachMatch.matched()) {
-        AnnotationFS each = eachMatch.getMatchedAnnotation(stream, null);
+        List<AnnotationFS> matchedAnnotations = eachMatch.getMatchedAnnotations(stream, null, null);
+        if (matchedAnnotations == null || matchedAnnotations.isEmpty()) {
+          continue;
+        }
+        AnnotationFS each = matchedAnnotations.get(0);
         if (each == null) {
           continue;
         }
-        Type type = rule.getElements().get(0).getMatcher().getType(getParent(), stream);
-        TextMarkerStream window = stream.getWindowStream(each, type);
-        for (TextMarkerStatement element : getElements()) {
-          if (element != null) {
-            element.apply(window, crowd);
+        List<Type> types = ((TextMarkerRuleElement) rule.getRuleElements().get(0)).getMatcher()
+                .getTypes(getParent(), stream);
+        for (Type eachType : types) {
+          TextMarkerStream window = stream.getWindowStream(each, eachType);
+          for (TextMarkerStatement element : getElements()) {
+            if (element != null) {
+              element.apply(window, crowd);
+            }
           }
         }
       }
@@ -66,8 +74,4 @@ public class TextMarkerScriptBlock exten
     return "BLOCK(" + id + ") " + ruleString + " containing " + elements.size() + " Elements";
   }
 
-  public void setMatchRule(TextMarkerRule rule) {
-    this.rule = rule;
-  }
-
 }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerScriptFactory.java Thu Sep 22 12:49:48 2011
@@ -37,13 +37,15 @@ import org.apache.uima.textmarker.expres
 import org.apache.uima.textmarker.expression.type.TypeExpression;
 import org.apache.uima.textmarker.rule.ComposedRuleElement;
 import org.apache.uima.textmarker.rule.RuleElement;
+import org.apache.uima.textmarker.rule.RuleElementContainer;
+import org.apache.uima.textmarker.rule.RuleElementIsolator;
+import org.apache.uima.textmarker.rule.TextMarkerDisjunctiveTypeMatcher;
 import org.apache.uima.textmarker.rule.TextMarkerLiteralMatcher;
 import org.apache.uima.textmarker.rule.TextMarkerRule;
 import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.rule.TextMarkerTypeMatcher;
 import org.apache.uima.textmarker.rule.quantifier.MinMaxGreedy;
 import org.apache.uima.textmarker.rule.quantifier.MinMaxReluctant;
-import org.apache.uima.textmarker.rule.quantifier.NormalQuantifier;
 import org.apache.uima.textmarker.rule.quantifier.PlusGreedy;
 import org.apache.uima.textmarker.rule.quantifier.PlusReluctant;
 import org.apache.uima.textmarker.rule.quantifier.QuestionGreedy;
@@ -54,7 +56,7 @@ import org.apache.uima.textmarker.rule.q
 
 public class TextMarkerScriptFactory {
 
-  private int idCounter = 0;
+  private static int idCounter = 0;
 
   public TextMarkerScriptFactory() {
     super();
@@ -106,54 +108,67 @@ public class TextMarkerScriptFactory {
     } catch (CASException e) {
       e.printStackTrace();
     }
-    result.setMatchRule(createRule(getDocumentRuleElement(result, cas), result));
-    return result;
-  }
 
-  private List<RuleElement> getDocumentRuleElement(TextMarkerBlock parent, CAS cas) {
-    List<RuleElement> result = new ArrayList<RuleElement>();
+    List<RuleElement> ruleElements = new ArrayList<RuleElement>();
 
-    result.add(createRuleElement(new SimpleTypeExpression(cas.getDocumentAnnotation().getType()),
-            null, null, null, parent));
+    RuleElementIsolator container = new RuleElementIsolator();
+    ruleElements.add(createRuleElement(new SimpleTypeExpression(cas.getDocumentAnnotation()
+            .getType()), null, null, null, container, result));
+    TextMarkerRule createRule = createRule(ruleElements, result);
+    container.setContainer(createRule);
+
+    result.setRule(createRule);
     return result;
   }
 
   public TextMarkerRule createRule(RuleElement element, TextMarkerBlock parent) {
     List<RuleElement> elements = new ArrayList<RuleElement>();
     elements.add(element);
-    return new TextMarkerRule(elements, parent, idCounter++);
+    return createRule(elements, parent);
   }
 
   public TextMarkerRule createRule(List<RuleElement> elements, TextMarkerBlock parent) {
+    // System.out.println("Rule: " + idCounter);
     return new TextMarkerRule(elements, parent, idCounter++);
   }
 
   public TextMarkerRuleElement createRuleElement(TypeExpression typeExpression,
           RuleElementQuantifier quantifier, List<AbstractTextMarkerCondition> conditions,
-          List<AbstractTextMarkerAction> actions, TextMarkerBlock parent) {
-    if (quantifier == null) {
-      quantifier = new NormalQuantifier();
-    }
+          List<AbstractTextMarkerAction> actions, RuleElementContainer container,
+          TextMarkerBlock parent) {
+
     TextMarkerTypeMatcher matcher = new TextMarkerTypeMatcher(typeExpression);
-    return new TextMarkerRuleElement(matcher, quantifier, conditions, actions, parent);
+    return new TextMarkerRuleElement(matcher, quantifier, conditions, actions, container, parent);
+  }
+
+  public TextMarkerRuleElement createRuleElement(List<TypeExpression> typeExprs,
+          RuleElementQuantifier quantifier, List<AbstractTextMarkerCondition> conditions,
+          List<AbstractTextMarkerAction> actions, RuleElementContainer container,
+          TextMarkerBlock parent) {
+    TextMarkerDisjunctiveTypeMatcher matcher = new TextMarkerDisjunctiveTypeMatcher(typeExprs);
+    return new TextMarkerRuleElement(matcher, quantifier, conditions, actions, container, parent);
   }
 
   public TextMarkerRuleElement createRuleElement(StringExpression stringExpression,
           RuleElementQuantifier quantifier, List<AbstractTextMarkerCondition> conditions,
-          List<AbstractTextMarkerAction> actions, TextMarkerBlock parent) {
-    if (quantifier == null) {
-      quantifier = new NormalQuantifier();
-    }
+          List<AbstractTextMarkerAction> actions, RuleElementContainer container,
+          TextMarkerBlock parent) {
+
     TextMarkerLiteralMatcher matcher = new TextMarkerLiteralMatcher(stringExpression);
-    return new TextMarkerRuleElement(matcher, quantifier, conditions, actions, parent);
+    return new TextMarkerRuleElement(matcher, quantifier, conditions, actions, container, parent);
   }
 
   public ComposedRuleElement createComposedRuleElement(List<RuleElement> res,
-          RuleElementQuantifier quantifier, TextMarkerBlock parent) {
-    if (quantifier == null) {
-      quantifier = new NormalQuantifier();
-    }
-    return new ComposedRuleElement(res, quantifier, parent);
+          RuleElementQuantifier quantifier, List<AbstractTextMarkerCondition> conditions,
+          List<AbstractTextMarkerAction> actions, RuleElementContainer container,
+          TextMarkerBlock parent) {
+
+    return new ComposedRuleElement(res, quantifier, conditions, actions, container, parent);
+  }
+
+  public ComposedRuleElement createComposedRuleElement(RuleElementContainer container,
+          TextMarkerBlock parent) {
+    return new ComposedRuleElement(null, null, null, null, container, parent);
   }
 
   public static RuleElementQuantifier createStarGreedyQuantifier() {
@@ -192,7 +207,7 @@ public class TextMarkerScriptFactory {
 
   public TextMarkerBlock createAutomataBlock(Token id, TextMarkerRuleElement re,
           List<TextMarkerStatement> body, TextMarkerBlock env, CAS cas) {
-    return null;
+    return createScriptBlock(id, re, body, env, cas);
   }
 
 }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/TextMarkerStream.java Thu Sep 22 12:49:48 2011
@@ -24,6 +24,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.TreeMap;
 
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.CASException;
@@ -61,6 +62,10 @@ public class TextMarkerStream extends FS
 
   private final List<TextMarkerBasic> basics;
 
+  private TreeMap<Integer, TextMarkerBasic> beginAnchors;
+
+  private TreeMap<Integer, TextMarkerBasic> endAnchors;
+
   private FilterManager filter;
 
   private Map<Integer, TextMarkerBasic> pointerMap = new HashMap<Integer, TextMarkerBasic>();
@@ -79,7 +84,7 @@ public class TextMarkerStream extends FS
     }
     if (current == null) {
       // TODO use here a subiterator??
-      currentIt = filter.createFilteredIterator(cas, basicIt, basicType);
+      currentIt = filter.createFilteredIterator(cas, basicType);
       // currentIt = cas.createFilteredIterator(basic, filter.getDefaultConstraint());
     } else {
       currentIt = current;
@@ -99,12 +104,20 @@ public class TextMarkerStream extends FS
     }
     // really faster???
     basics = new ArrayList<TextMarkerBasic>();
+    beginAnchors = new TreeMap<Integer, TextMarkerBasic>();
+    endAnchors = new TreeMap<Integer, TextMarkerBasic>();
     FSIterator<AnnotationFS> iterator = cas.getAnnotationIndex(basicType).subiterator(
             documentAnnotation);
     while (iterator.isValid()) {
-      basics.add((TextMarkerBasic) iterator.get());
+
+      TextMarkerBasic e = (TextMarkerBasic) iterator.get();
+      beginAnchors.put(e.getBegin(), e);
+      endAnchors.put(e.getEnd(), e);
+
+      basics.add(e);
       iterator.moveToNext();
     }
+
   }
 
   public TextMarkerStream(CAS cas, FSIterator<AnnotationFS> basic, Type basicType,
@@ -112,45 +125,93 @@ public class TextMarkerStream extends FS
     this(cas, basic, null, basicType, filter);
   }
 
-  public void addAnnotation(TextMarkerBasic anchor, AnnotationFS annotation) {
-    if (anchor == null)
-      return;
+  // public void addAnnotation(TextMarkerBasic anchor, AnnotationFS annotation) {
+  // if (anchor == null)
+  // return;
+  // Type type = annotation.getType();
+  // String name = type.getName();
+  // TypeSystem typeSystem = cas.getTypeSystem();
+  // Type parent = type;
+  // while (parent != null) {
+  // // anchor.setAnnotation(parent.getName(), annotation, parent == type);
+  // TextMarkerBasic beginAnchor = getBeginAnchor(annotation.getBegin());
+  // TextMarkerBasic endAnchor = getEndAnchor(annotation.getEnd());
+  // beginAnchor.addBegin(annotation);
+  // endAnchor.addEnd(annotation);
+  // parent = typeSystem.getParent(parent);
+  // }
+  // List<TextMarkerBasic> basicAnnotationsInWindow = getAllBasicsInWindow(annotation);
+  // for (TextMarkerBasic basic : basicAnnotationsInWindow) {
+  // basic.addPartOf(name);
+  // }
+  // }
+
+  public void addAnnotation(AnnotationFS annotation) {
     Type type = annotation.getType();
-    String name = type.getName();
     TypeSystem typeSystem = cas.getTypeSystem();
     Type parent = type;
     while (parent != null) {
-      anchor.setAnnotation(parent.getName(), annotation, parent == type);
+      // anchor.setAnnotation(parent.getName(), annotation, parent == type);
+      TextMarkerBasic beginAnchor = getBeginAnchor(annotation.getBegin());
+      TextMarkerBasic endAnchor = getEndAnchor(annotation.getEnd());
+      beginAnchor.addBegin(annotation, parent);
+      endAnchor.addEnd(annotation, parent);
       parent = typeSystem.getParent(parent);
     }
     List<TextMarkerBasic> basicAnnotationsInWindow = getAllBasicsInWindow(annotation);
     for (TextMarkerBasic basic : basicAnnotationsInWindow) {
-      basic.addPartOf(name);
+      basic.addPartOf(type);
     }
   }
 
-  public void removeAnnotation(TextMarkerBasic anchor, Type type) {
+  public void removeAnnotation(AnnotationFS annotationFS) {
+    removeAnnotation(annotationFS, annotationFS.getType());
+  }
+
+  public void removeAnnotation(AnnotationFS annotation, Type type) {
     TypeSystem typeSystem = cas.getTypeSystem();
-    String name = type.getName();
-    AnnotationFS expandAnchor = expandAnchor(anchor, type, true);
-    if (expandAnchor == null) {
-      // there is no annotation to remove
-      return;
-    }
-    List<TextMarkerBasic> basicAnnotationsInWindow = getAllBasicsInWindow(expandAnchor);
+    List<TextMarkerBasic> basicAnnotationsInWindow = getAllBasicsInWindow(annotation);
     for (TextMarkerBasic basic : basicAnnotationsInWindow) {
-      basic.removePartOf(name);
+      basic.removePartOf(type);
     }
     Type parent = type;
+    TextMarkerBasic beginAnchor = getBeginAnchor(annotation.getBegin());
+    TextMarkerBasic endAnchor = getEndAnchor(annotation.getEnd());
     while (parent != null) {
-      anchor.removeAnnotation(parent.getName(), parent == type);
+      beginAnchor.removeBegin(annotation, parent);
+      endAnchor.removeEnd(annotation, parent);
       parent = typeSystem.getParent(parent);
     }
-    if (!(expandAnchor instanceof TextMarkerBasic)) {
-      cas.removeFsFromIndexes(expandAnchor);
+    if (!(annotation instanceof TextMarkerBasic)) {
+      cas.removeFsFromIndexes(annotation);
     }
+
   }
 
+  // public void removeAnnotation(TextMarkerBasic anchor, Type type) {
+  // TypeSystem typeSystem = cas.getTypeSystem();
+  // String name = type.getName();
+  // AnnotationFS expandAnchor = expandAnchor(anchor, type, true);
+  // if (expandAnchor == null) {
+  // // there is no annotation to remove
+  // return;
+  // }
+  // List<TextMarkerBasic> basicAnnotationsInWindow = getAllBasicsInWindow(expandAnchor);
+  // for (TextMarkerBasic basic : basicAnnotationsInWindow) {
+  // basic.removePartOf(name);
+  // }
+  // Type parent = type;
+  // TextMarkerBasic beginAnchor = getBeginAnchor(annotation.getBegin());
+  // TextMarkerBasic endAnchor = getEndAnchor(annotation.getEnd());
+  // while (parent != null) {
+  // anchor.removeAnnotation(parent.getName(), parent == type);
+  // parent = typeSystem.getParent(parent);
+  // }
+  // if (!(expandAnchor instanceof TextMarkerBasic)) {
+  // cas.removeFsFromIndexes(expandAnchor);
+  // }
+  // }
+
   public FSIterator<AnnotationFS> getFilteredBasicIterator(FSMatchConstraint constraint) {
     ConstraintFactory cf = cas.getConstraintFactory();
     FSMatchConstraint matchConstraint = cf.and(constraint, filter.getDefaultConstraint());
@@ -167,8 +228,6 @@ public class TextMarkerStream extends FS
             filter.getDefaultRetainTags(), filter.getCurrentFilterTypes(),
             filter.getCurrentRetainTypes(), filter.getCurrentFilterTags(),
             filter.getCurrentRetainTags(), windowAnnotation, windowType, cas);
-    // TODO can I use the old currentIT here? check this please!
-
     TextMarkerStream stream = new TextMarkerStream(cas, basicIt, basicType, filterManager);
     return stream;
   }
@@ -272,14 +331,14 @@ public class TextMarkerStream extends FS
 
   public List<AnnotationFS> getAnnotationsInWindow2(AnnotationFS windowAnnotation, Type type) {
     List<AnnotationFS> result = new ArrayList<AnnotationFS>();
-    if (windowAnnotation instanceof TextMarkerBasic) {
-      TextMarkerBasic basic = (TextMarkerBasic) windowAnnotation;
-      AnnotationFS a = basic.getType(type.getName());
-      if (a != null) {
-        result.add(a);
-      }
-      return result;
-    }
+    // if (windowAnnotation instanceof TextMarkerBasic) {
+    // TextMarkerBasic basic = (TextMarkerBasic) windowAnnotation;
+    // AnnotationFS a = basic.getType(type.getName());
+    // if (a != null) {
+    // result.add(a);
+    // }
+    // return result;
+    // }
     windowAnnotation = cas.createAnnotation(type, windowAnnotation.getBegin(),
             windowAnnotation.getEnd() + 1);
     FSIterator<AnnotationFS> completeIt = getCas().getAnnotationIndex(type).iterator();
@@ -375,62 +434,14 @@ public class TextMarkerStream extends FS
     return null;
   }
 
-  public List<TextMarkerBasic> getAnnotationsOverlappingWindow(TextMarkerBasic basic, Type type) {
-    AnnotationFS expand = expandPartOf(basic, type);
-    if (expand != null) {
-      return getBasicsInWindow(expand);
+  public List<TextMarkerBasic> getAnnotationsOverlappingWindow(AnnotationFS annotation) {
+    if (annotation != null) {
+      return getBasicsInWindow(annotation);
     } else {
       return new ArrayList<TextMarkerBasic>();
     }
   }
 
-  private AnnotationFS expandPartOf(TextMarkerBasic currentBasic, Type type) {
-    if (type == null) {
-      return currentBasic;
-    }
-    AnnotationFS result = currentBasic.getType(type.getName());
-    if (result != null) {
-      return result;
-    }
-    if (currentBasic.isPartOf(type.getName())) {
-      moveTo(currentBasic);
-      while (isValid()) {
-        TextMarkerBasic each = (TextMarkerBasic) get();
-        if (each.isAnchorOf(type.getName())) {
-          AnnotationFS annotation = each.getType(type.getName());
-          if (annotation.getBegin() <= currentBasic.getBegin()
-                  && annotation.getEnd() >= currentBasic.getEnd()) {
-            return annotation;
-          }
-        }
-        moveToPrevious();
-      }
-    }
-    return null;
-  }
-
-  public AnnotationFS expandAnchor(TextMarkerBasic currentBasic, Type type) {
-    return expandAnchor(currentBasic, type, false);
-  }
-
-  public AnnotationFS expandAnchor(TextMarkerBasic currentBasic, Type type, boolean ret) {
-    if (type == null || currentBasic == null) {
-      return currentBasic;
-    }
-    AnnotationFS result = currentBasic.getType(type.getName());
-    if (result != null) {
-      return result;
-    }
-    if (type.getName().equals(getDocumentAnnotationType().getName())) {
-      return documentAnnotation;
-    }
-    if (!ret) {
-      return currentBasic;
-    } else {
-      return null;
-    }
-  }
-
   public FSIterator<AnnotationFS> getUnfilteredBasicIterator() {
     return basicIt;
   }
@@ -566,4 +577,20 @@ public class TextMarkerStream extends FS
     return new TextMarkerStream(getCas(), basicIt, basicType, defaultFilter);
   }
 
+  public int getHistogram(Type type) {
+    return cas.getAnnotationIndex(type).size();
+  }
+
+  public double getIndexPenalty() {
+    return 5;
+  }
+
+  public TextMarkerBasic getEndAnchor(int end) {
+    return endAnchors.get(end);
+  }
+
+  public TextMarkerBasic getBeginAnchor(int begin) {
+    return beginAnchors.get(begin);
+  }
+
 }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractMarkAction.java Thu Sep 22 12:49:48 2011
@@ -19,13 +19,16 @@
 
 package org.apache.uima.textmarker.action;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.jcas.tcas.Annotation;
 import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.expression.number.NumberExpression;
 import org.apache.uima.textmarker.expression.type.TypeExpression;
-import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.type.TextMarkerBasic;
 
 public abstract class AbstractMarkAction extends TypeSensitiveAction {
@@ -34,16 +37,13 @@ public abstract class AbstractMarkAction
     super(type);
   }
 
-  protected void createAnnotation(RuleMatch match, TextMarkerRuleElement element,
-          TextMarkerStream stream, AnnotationFS matchedAnnotation) {
+  protected void createAnnotation(AnnotationFS matchedAnnotation, RuleElement element,
+          TextMarkerStream stream) {
     TextMarkerBasic first = stream.getFirstBasicInWindow(matchedAnnotation);
-    if (first == null) {
-      first = match.getFirstBasic();
-    }
     createAnnotation(first, element, stream, matchedAnnotation);
   }
 
-  protected Annotation createAnnotation(TextMarkerBasic anchor, TextMarkerRuleElement element,
+  protected Annotation createAnnotation(TextMarkerBasic anchor, RuleElement element,
           TextMarkerStream stream, AnnotationFS matchedAnnotation) {
     Type t = type.getType(element.getParent());
     AnnotationFS newAnnotationFS = stream.getCas().createAnnotation(t,
@@ -55,7 +55,7 @@ public abstract class AbstractMarkAction
     } else {
       return null;
     }
-    stream.addAnnotation(anchor, newAnnotation);
+    stream.addAnnotation(newAnnotation);
     return newAnnotation;
   }
 
@@ -64,4 +64,22 @@ public abstract class AbstractMarkAction
     return super.toString() + "," + type.getClass().getSimpleName();
   }
 
+  protected List<Integer> getIndexList(RuleElement element, List<NumberExpression> list) {
+    List<Integer> indexList = new ArrayList<Integer>();
+    if (list == null || list.isEmpty()) {
+      int self = element.getContainer().getRuleElements().indexOf(element) + 1;
+      indexList.add(self);
+      return indexList;
+    }
+    int last = Integer.MAX_VALUE - 1;
+    for (NumberExpression each : list) {
+      int value = each.getIntegerValue(element.getParent());
+      for (int i = Math.min(value, last + 1); i < value; i++) {
+        indexList.add(i);
+      }
+      indexList.add(value);
+    }
+    return indexList;
+  }
+
 }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractStructureAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractStructureAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractStructureAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractStructureAction.java Thu Sep 22 12:49:48 2011
@@ -37,13 +37,17 @@ import org.apache.uima.textmarker.expres
 import org.apache.uima.textmarker.expression.number.NumberExpression;
 import org.apache.uima.textmarker.expression.string.StringExpression;
 import org.apache.uima.textmarker.expression.type.TypeExpression;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.utils.UIMAUtils;
 
 public abstract class AbstractStructureAction extends AbstractTextMarkerAction {
 
+  public AbstractStructureAction() {
+    super();
+  }
+
   protected void fillFeatures(TOP structure, Map<StringExpression, TextMarkerExpression> features,
-          AnnotationFS matchedAnnotation, TextMarkerRuleElement element, TextMarkerStream stream) {
+          AnnotationFS matchedAnnotation, RuleElement element, TextMarkerStream stream) {
     Map<String, TextMarkerExpression> map = new HashMap<String, TextMarkerExpression>();
     for (Entry<StringExpression, TextMarkerExpression> each : features.entrySet()) {
       String value = each.getKey().getStringValue(element.getParent());

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractTextMarkerAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractTextMarkerAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractTextMarkerAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AbstractTextMarkerAction.java Thu Sep 22 12:49:48 2011
@@ -15,20 +15,24 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.textmarker.action;
 
 import org.apache.uima.textmarker.TextMarkerElement;
 import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
 public abstract class AbstractTextMarkerAction extends TextMarkerElement {
 
-  public abstract void execute(RuleMatch match, TextMarkerRuleElement element,
-          TextMarkerStream stream, InferenceCrowd crowd);
+  public AbstractTextMarkerAction() {
+    super();
+  }
+
+  public abstract void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
+          InferenceCrowd crowd);
 
   @Override
   public String toString() {

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AddAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AddAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AddAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AddAction.java Thu Sep 22 12:49:48 2011
@@ -31,8 +31,8 @@ import org.apache.uima.textmarker.expres
 import org.apache.uima.textmarker.expression.number.NumberExpression;
 import org.apache.uima.textmarker.expression.string.StringExpression;
 import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
 public class AddAction extends AbstractTextMarkerAction {
@@ -57,7 +57,7 @@ public class AddAction extends AbstractT
 
   @SuppressWarnings("unchecked")
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
     TextMarkerBlock parent = element.getParent();
     TextMarkerEnvironment environment = parent.getEnvironment();

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AssignAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AssignAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AssignAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/AssignAction.java Thu Sep 22 12:49:48 2011
@@ -28,8 +28,8 @@ import org.apache.uima.textmarker.expres
 import org.apache.uima.textmarker.expression.number.NumberExpression;
 import org.apache.uima.textmarker.expression.string.StringExpression;
 import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
 public class AssignAction extends AbstractTextMarkerAction {
@@ -45,7 +45,7 @@ public class AssignAction extends Abstra
   }
 
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
     TextMarkerBlock parent = element.getParent();
     TextMarkerEnvironment environment = parent.getEnvironment();

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CallAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CallAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CallAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CallAction.java Thu Sep 22 12:49:48 2011
@@ -23,6 +23,7 @@ import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.TreeMap;
 
 import org.apache.uima.analysis_engine.AnalysisEngine;
@@ -39,8 +40,8 @@ import org.apache.uima.textmarker.Script
 import org.apache.uima.textmarker.TextMarkerBlock;
 import org.apache.uima.textmarker.TextMarkerModule;
 import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.type.TextMarkerBasic;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
@@ -54,7 +55,7 @@ public class CallAction extends Abstract
   }
 
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
 
     TextMarkerModule thisScript = element.getParent().getScript();
@@ -86,125 +87,127 @@ public class CallAction extends Abstract
 
   }
 
-  protected void callScript(String blockName, RuleMatch match, TextMarkerRuleElement element,
+  protected void callScript(String blockName, RuleMatch match, RuleElement element,
           TextMarkerStream stream, InferenceCrowd crowd, TextMarkerModule targetScript) {
     TextMarkerBlock block = targetScript.getBlock(blockName);
     if (block == null) {
       return;
     }
-    // TODO: add window stream, but how to behave with quantifier on rule element?
-    // List<Integer> indexes = new ArrayList<Integer>(1);
-    // int indexOf = match.getRule().getElements().indexOf(element);
-    // indexes.add(indexOf);
-    // AnnotationFS matchedAnnotation = match.getMatchedAnnotation(stream, indexes);
-    // List<RuleElementMatch> matchInfo = match.getMatchInfo(element);
-    // TextMarkerStream windowStream = stream.getWindowStream(matchedAnnotation, stream
-    // .getDocumentAnnotationType());
-    ScriptApply apply = block.apply(stream, crowd);
-    match.addDelegateApply(this, apply);
+    List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element, stream);
+    for (AnnotationFS annotationFS : matchedAnnotationsOf) {
+      TextMarkerStream windowStream = stream.getWindowStream(annotationFS,
+              stream.getDocumentAnnotationType());
+      ScriptApply apply = block.apply(windowStream, crowd);
+      match.addDelegateApply(this, apply);
+    }
+
   }
 
   protected void callEngine(RuleMatch match, InferenceCrowd crowd, AnalysisEngine targetEngine,
-          TextMarkerRuleElement element, TextMarkerStream stream)
-          throws ResourceInitializationException, AnalysisEngineProcessException {
+          RuleElement element, TextMarkerStream stream) throws ResourceInitializationException,
+          AnalysisEngineProcessException {
 
-    AnnotationFS matchedAnnotation = match.getMatchedAnnotation(stream, null);
-
-    StringBuilder newDocument = new StringBuilder();
-    TextMarkerStream windowStream = stream.getWindowStream(matchedAnnotation,
-            stream.getDocumentAnnotationType());
-    windowStream.moveToFirst();
-
-    CAS newCAS = targetEngine.newCAS();
-    List<Type> types = newCAS.getTypeSystem().getProperlySubsumedTypes(newCAS.getAnnotationType());
-
-    Collection<AnnotationFS> fsToAdd = new HashSet<AnnotationFS>();
-
-    Map<Integer, Integer> new2oldBegin = new TreeMap<Integer, Integer>();
-    Map<Integer, Integer> new2oldEnd = new TreeMap<Integer, Integer>();
-    Map<Integer, Integer> old2newBegin = new TreeMap<Integer, Integer>();
-    Map<Integer, Integer> old2newEnd = new TreeMap<Integer, Integer>();
-
-    int localBegin = 0;
-    int localEnd = 0;
-    while (windowStream.isValid()) {
-      FeatureStructure fs = windowStream.get();
-      if (fs instanceof TextMarkerBasic) {
-        TextMarkerBasic basic = (TextMarkerBasic) fs;
-        for (Type type : types) {
-          AnnotationFS a = basic.getType(type.getName());
-          if (a != null && !a.getType().getName().equals("uima.tcas.DocumentAnnotation")
-                  && !(a instanceof TextMarkerBasic)) {
-            fsToAdd.add(a);
+    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(stream, null,
+            element.getContainer());
+    for (AnnotationFS matchedAnnotation : matchedAnnotations) {
+
+      StringBuilder newDocument = new StringBuilder();
+      TextMarkerStream windowStream = stream.getWindowStream(matchedAnnotation,
+              stream.getDocumentAnnotationType());
+      windowStream.moveToFirst();
+
+      CAS newCAS = targetEngine.newCAS();
+      List<Type> types = newCAS.getTypeSystem()
+              .getProperlySubsumedTypes(newCAS.getAnnotationType());
+
+      Collection<AnnotationFS> fsToAdd = new HashSet<AnnotationFS>();
+
+      Map<Integer, Integer> new2oldBegin = new TreeMap<Integer, Integer>();
+      Map<Integer, Integer> new2oldEnd = new TreeMap<Integer, Integer>();
+      Map<Integer, Integer> old2newBegin = new TreeMap<Integer, Integer>();
+      Map<Integer, Integer> old2newEnd = new TreeMap<Integer, Integer>();
+
+      int localBegin = 0;
+      int localEnd = 0;
+      while (windowStream.isValid()) {
+        FeatureStructure fs = windowStream.get();
+        if (fs instanceof TextMarkerBasic) {
+          TextMarkerBasic basic = (TextMarkerBasic) fs;
+          for (Type type : types) {
+            Set<AnnotationFS> beginAnchors = basic.getBeginAnchors(type);
+            for (AnnotationFS a : beginAnchors) {
+              if (a != null && !a.getType().getName().equals("uima.tcas.DocumentAnnotation")
+                      && !(a instanceof TextMarkerBasic)) {
+                fsToAdd.add(a);
+              }
+            }
           }
-        }
-        int length = basic.getEnd() - basic.getBegin();
-        localEnd = localBegin + length;
+          int length = basic.getEnd() - basic.getBegin();
+          localEnd = localBegin + length;
 
-        new2oldBegin.put(localBegin, basic.getBegin());
-        old2newBegin.put(basic.getBegin(), localBegin);
-        new2oldEnd.put(localEnd, basic.getEnd());
-        old2newEnd.put(basic.getEnd(), localEnd);
+          new2oldBegin.put(localBegin, basic.getBegin());
+          old2newBegin.put(basic.getBegin(), localBegin);
+          new2oldEnd.put(localEnd, basic.getEnd());
+          old2newEnd.put(basic.getEnd(), localEnd);
 
-        newDocument.append(basic.getCoveredText());
+          newDocument.append(basic.getCoveredText());
 
-        localBegin += length;
-      }
-      windowStream.moveToNext();
-    }
-
-    String string = newDocument.toString();
-    newCAS.setDocumentText(string);
-    for (AnnotationFS each : fsToAdd) {
-      int beginOld = each.getBegin();
-      int endOld = each.getEnd();
-
-      Integer beginNew = old2newBegin.get(beginOld);
-      Integer endNew = old2newEnd.get(endOld);
-      if (endNew == null && beginNew != null) {
-        int delta = endOld - beginOld;
-        endNew = beginNew + delta;
-      } else if (endNew != null && beginNew == null) {
-        int delta = endOld - beginOld;
-        beginNew = endNew - delta;
-      } else if (endNew == null && beginNew == null) {
-        int index;
-        int deltaBefore = 0;
-        int deltaAfter = 0;
-        Integer valueBegin = null;
-        index = beginOld;
-        while (valueBegin == null) {
-          valueBegin = new2oldBegin.get(++index);
-          deltaBefore++;
-        }
-        Integer valueEnd = null;
-        index = endOld;
-        while (valueEnd == null) {
-          valueEnd = new2oldEnd.get(--index);
-          deltaAfter++;
+          localBegin += length;
         }
-        beginNew = valueBegin - deltaBefore;
-        endNew = valueEnd + deltaAfter;
-        // TODO what to do here? refactor and refine complete class!!
+        windowStream.moveToNext();
       }
 
-      String typeName = each.getType().getName();
-      Type type = newCAS.getTypeSystem().getType(typeName);
-      FeatureStructure newAnnotation = newCAS.createAnnotation(type, beginNew, endNew);
-      newCAS.addFsToIndexes(newAnnotation);
-    }
+      String string = newDocument.toString();
+      newCAS.setDocumentText(string);
+      for (AnnotationFS each : fsToAdd) {
+        int beginOld = each.getBegin();
+        int endOld = each.getEnd();
+
+        Integer beginNew = old2newBegin.get(beginOld);
+        Integer endNew = old2newEnd.get(endOld);
+        if (endNew == null && beginNew != null) {
+          int delta = endOld - beginOld;
+          endNew = beginNew + delta;
+        } else if (endNew != null && beginNew == null) {
+          int delta = endOld - beginOld;
+          beginNew = endNew - delta;
+        } else if (endNew == null && beginNew == null) {
+          int index;
+          int deltaBefore = 0;
+          int deltaAfter = 0;
+          Integer valueBegin = null;
+          index = beginOld;
+          while (valueBegin == null) {
+            valueBegin = new2oldBegin.get(++index);
+            deltaBefore++;
+          }
+          Integer valueEnd = null;
+          index = endOld;
+          while (valueEnd == null) {
+            valueEnd = new2oldEnd.get(--index);
+            deltaAfter++;
+          }
+          beginNew = valueBegin - deltaBefore;
+          endNew = valueEnd + deltaAfter;
+        }
 
-    targetEngine.process(newCAS);
+        String typeName = each.getType().getName();
+        Type type = newCAS.getTypeSystem().getType(typeName);
+        FeatureStructure newAnnotation = newCAS.createAnnotation(type, beginNew, endNew);
+        newCAS.addFsToIndexes(newAnnotation);
+      }
 
-    for (Type type : types) {
-      FSIterator<AnnotationFS> iterator = newCAS.getAnnotationIndex(type).iterator();
-      while (iterator.isValid()) {
-        AnnotationFS each = iterator.get();
-        transform(each, new2oldBegin, new2oldEnd, fsToAdd, stream);
-        iterator.moveToNext();
+      targetEngine.process(newCAS);
+
+      for (Type type : types) {
+        FSIterator<AnnotationFS> iterator = newCAS.getAnnotationIndex(type).iterator();
+        while (iterator.isValid()) {
+          AnnotationFS each = iterator.get();
+          transform(each, new2oldBegin, new2oldEnd, fsToAdd, stream);
+          iterator.moveToNext();
+        }
       }
     }
-
   }
 
   private void transform(FeatureStructure each, Map<Integer, Integer> new2oldBegin,
@@ -262,15 +265,13 @@ public class CallAction extends Abstract
       }
       beginNew = valueBegin - deltaBefore;
       endNew = valueEnd + deltaAfter;
-      // TODO what to do here? refactor and refinem complete class
     }
 
     if (newFS instanceof Annotation) {
       Annotation newA = (Annotation) newFS;
       newA.setBegin(beginNew);
       newA.setEnd(endNew);
-      TextMarkerBasic basic = stream.getFirstBasicInWindow(newA);
-      stream.addAnnotation(basic, newA);
+      stream.addAnnotation(newA);
     }
     return newFS;
   }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ClearAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ClearAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ClearAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ClearAction.java Thu Sep 22 12:49:48 2011
@@ -15,13 +15,13 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.textmarker.action;
 
 import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
 public class ClearAction extends AbstractTextMarkerAction {
@@ -34,7 +34,7 @@ public class ClearAction extends Abstrac
   }
 
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
     element.getParent().getEnvironment().setVariableValue(list, null);
   }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ColorAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ColorAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ColorAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ColorAction.java Thu Sep 22 12:49:48 2011
@@ -27,8 +27,8 @@ import org.apache.uima.textmarker.expres
 import org.apache.uima.textmarker.expression.string.SimpleStringExpression;
 import org.apache.uima.textmarker.expression.string.StringExpression;
 import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.type.TextMarkerColoring;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
@@ -52,7 +52,7 @@ public class ColorAction extends Abstrac
   }
 
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
     Type casType = stream.getJCas().getCasType(TextMarkerColoring.type);
     FeatureStructure newAnnotationFS = stream.getCas().createFS(casType);

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ComposedAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ComposedAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ComposedAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ComposedAction.java Thu Sep 22 12:49:48 2011
@@ -15,18 +15,17 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.textmarker.action;
 
 import java.util.List;
 
 import org.apache.uima.textmarker.TextMarkerStream;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
-
 public class ComposedAction extends AbstractTextMarkerAction {
 
   private final List<AbstractTextMarkerAction> actions;
@@ -37,7 +36,7 @@ public class ComposedAction extends Abst
   }
 
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
     for (AbstractTextMarkerAction each : actions) {
       crowd.beginVisit(each, null);

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CreateAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CreateAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CreateAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/CreateAction.java Thu Sep 22 12:49:48 2011
@@ -34,9 +34,8 @@ import org.apache.uima.textmarker.expres
 import org.apache.uima.textmarker.expression.number.NumberExpression;
 import org.apache.uima.textmarker.expression.string.StringExpression;
 import org.apache.uima.textmarker.expression.type.TypeExpression;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
-import org.apache.uima.textmarker.type.TextMarkerBasic;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
 public class CreateAction extends AbstractStructureAction {
@@ -57,38 +56,38 @@ public class CreateAction extends Abstra
   }
 
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
     List<Integer> indexList = getIndexList(match, element);
-    AnnotationFS matchedAnnotation = match.getMatchedAnnotation(stream, indexList);
-    if (matchedAnnotation == null) {
-      return;
-    }
-    Type type = structureType.getType(element.getParent());
-    FeatureStructure newFS = stream.getCas().createFS(type);
-    if (newFS instanceof Annotation) {
-      Annotation a = (Annotation) newFS;
-      a.setBegin(matchedAnnotation.getBegin());
-      a.setEnd(matchedAnnotation.getEnd());
-      TextMarkerBasic first = stream.getFirstBasicInWindow(matchedAnnotation);
-      if (first == null) {
-        first = match.getFirstBasic();
+    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(stream, indexList,
+            element.getContainer());
+    for (AnnotationFS matchedAnnotation : matchedAnnotations) {
+
+      if (matchedAnnotation == null) {
+        return;
+      }
+      Type type = structureType.getType(element.getParent());
+      FeatureStructure newFS = stream.getCas().createFS(type);
+      if (newFS instanceof Annotation) {
+        Annotation a = (Annotation) newFS;
+        a.setBegin(matchedAnnotation.getBegin());
+        a.setEnd(matchedAnnotation.getEnd());
+        stream.addAnnotation(a);
+      }
+      TOP newStructure = null;
+      if (newFS instanceof TOP) {
+        newStructure = (TOP) newFS;
+        fillFeatures(newStructure, features, matchedAnnotation, element, stream);
+        newStructure.addToIndexes();
       }
-      stream.addAnnotation(first, a);
-    }
-    TOP newStructure = null;
-    if (newFS instanceof TOP) {
-      newStructure = (TOP) newFS;
-      fillFeatures(newStructure, features, matchedAnnotation, element, stream);
-      newStructure.addToIndexes();
     }
   }
 
   // TODO refactor duplicate methods -> MarkAction
-  protected List<Integer> getIndexList(RuleMatch match, TextMarkerRuleElement element) {
+  protected List<Integer> getIndexList(RuleMatch match, RuleElement element) {
     List<Integer> indexList = new ArrayList<Integer>();
     if (indexes == null || indexes.isEmpty()) {
-      int self = match.getRule().getElements().indexOf(element) + 1;
+      int self = element.getContainer().getRuleElements().indexOf(element) + 1;
       indexList.add(self);
       return indexList;
     }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DelAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DelAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DelAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/DelAction.java Thu Sep 22 12:49:48 2011
@@ -15,19 +15,19 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.textmarker.action;
 
+import java.util.List;
+
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.textmarker.TextMarkerStream;
-import org.apache.uima.textmarker.rule.RuleElementMatch;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.type.TextMarkerBasic;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
-
 public class DelAction extends AbstractTextMarkerAction {
 
   public DelAction() {
@@ -35,14 +35,13 @@ public class DelAction extends AbstractT
   }
 
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
-    for (RuleElementMatch each : match.getMatchInfo(element)) {
-      for (AnnotationFS eachAnnotation : each.getTextsMatched()) {
-        if (eachAnnotation instanceof TextMarkerBasic) {
-          TextMarkerBasic basic = (TextMarkerBasic) eachAnnotation;
-          basic.setReplacement("");
-        }
+    List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element, stream);
+    for (AnnotationFS annotationFS : matchedAnnotationsOf) {
+      List<TextMarkerBasic> basicsInWindow = stream.getBasicsInWindow(annotationFS);
+      for (TextMarkerBasic basic : basicsInWindow) {
+        basic.setReplacement("");
       }
     }
   }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExecAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExecAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExecAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExecAction.java Thu Sep 22 12:49:48 2011
@@ -39,8 +39,8 @@ import org.apache.uima.textmarker.TextMa
 import org.apache.uima.textmarker.TextMarkerModule;
 import org.apache.uima.textmarker.TextMarkerStream;
 import org.apache.uima.textmarker.expression.list.TypeListExpression;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
 import org.apache.uima.textmarker.type.TextMarkerBasic;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
@@ -58,7 +58,7 @@ public class ExecAction extends CallActi
   }
 
   @Override
-  protected void callScript(String blockName, RuleMatch match, TextMarkerRuleElement element,
+  protected void callScript(String blockName, RuleMatch match, RuleElement element,
           TextMarkerStream stream, InferenceCrowd crowd, TextMarkerModule targetScript) {
     TextMarkerBlock block = targetScript.getBlock(blockName);
     if (block == null) {
@@ -71,8 +71,8 @@ public class ExecAction extends CallActi
 
   @Override
   protected void callEngine(RuleMatch match, InferenceCrowd crowd, AnalysisEngine targetEngine,
-          TextMarkerRuleElement element, TextMarkerStream stream)
-          throws ResourceInitializationException, AnalysisEngineProcessException {
+          RuleElement element, TextMarkerStream stream) throws ResourceInitializationException,
+          AnalysisEngineProcessException {
     CAS cas = stream.getCas();
     targetEngine.process(cas);
 
@@ -98,7 +98,7 @@ public class ExecAction extends CallActi
             cas.removeFsFromIndexes(each);
             stream.removeAnnotation(entry.getKey(), each.getType());
             cas.addFsToIndexes(each);
-            stream.addAnnotation(entry.getKey(), each);
+            stream.addAnnotation(each);
           }
         }
       }

Modified: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java?rev=1174099&r1=1174098&r2=1174099&view=diff
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java (original)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-engine/src/main/java/org/apache/uima/textmarker/action/ExpandAction.java Thu Sep 22 12:49:48 2011
@@ -21,15 +21,12 @@ package org.apache.uima.textmarker.actio
 
 import java.util.List;
 
-import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.textmarker.TextMarkerStream;
 import org.apache.uima.textmarker.expression.number.NumberExpression;
 import org.apache.uima.textmarker.expression.type.TypeExpression;
-import org.apache.uima.textmarker.rule.RuleElementMatch;
+import org.apache.uima.textmarker.rule.RuleElement;
 import org.apache.uima.textmarker.rule.RuleMatch;
-import org.apache.uima.textmarker.rule.TextMarkerRuleElement;
-import org.apache.uima.textmarker.type.TextMarkerBasic;
 import org.apache.uima.textmarker.visitor.InferenceCrowd;
 
 public class ExpandAction extends MarkAction {
@@ -39,22 +36,20 @@ public class ExpandAction extends MarkAc
   }
 
   @Override
-  public void execute(RuleMatch match, TextMarkerRuleElement element, TextMarkerStream stream,
+  public void execute(RuleMatch match, RuleElement element, TextMarkerStream stream,
           InferenceCrowd crowd) {
-    List<Integer> indexList = getIndexList(match, element);
-    AnnotationFS matchedAnnotation = match.getMatchedAnnotation(stream, indexList);
-
-    List<RuleElementMatch> matchInfo = match.getMatchInfo(element);
-    if (matchInfo == null || matchInfo.isEmpty()) {
-      return;
+    List<Integer> indexList = getIndexList(element, list);
+    List<AnnotationFS> matchedAnnotations = match.getMatchedAnnotations(stream, indexList,
+            element.getContainer());
+    for (AnnotationFS matchedAnnotation : matchedAnnotations) {
+      List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element, stream);
+      for (AnnotationFS annotationFS : matchedAnnotationsOf) {
+        if (matchedAnnotation.getBegin() >= annotationFS.getBegin()
+                && matchedAnnotation.getEnd() <= annotationFS.getEnd()) {
+          stream.removeAnnotation(annotationFS, annotationFS.getType());
+          createAnnotation(matchedAnnotation, element, stream);
+        }
+      }
     }
-    RuleElementMatch ruleElementMatch = matchInfo.get(0);
-    List<AnnotationFS> textsMatched = ruleElementMatch.getTextsMatched();
-    AnnotationFS first = textsMatched.get(0);
-    TextMarkerBasic anchor = stream.getFirstBasicInWindow(first);
-    Type t = type.getType(element.getParent());
-    stream.removeAnnotation(anchor, t);
-    createAnnotation(anchor, element, stream, matchedAnnotation);
   }
-
 }