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 16:21:35 UTC
svn commit: r1152792 [5/10] - in /uima/sandbox/trunk/TextMarker:
org.apache.uima.tm.textruler.lp2/ org.apache.uima.tm.textruler.lp2/META-INF/
org.apache.uima.tm.textruler.lp2/bin/ org.apache.uima.tm.textruler.lp2/src/
org.apache.uima.tm.textruler.lp2/s...
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRule.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRule.java?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRule.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRule.java Mon Aug 1 14:21:12 2011
@@ -0,0 +1,204 @@
+package org.apache.uima.tm.textruler.whisk.generic;
+
+import org.apache.uima.tm.textruler.core.TextRulerBasicLearner;
+import org.apache.uima.tm.textruler.core.TextRulerExample;
+import org.apache.uima.tm.textruler.core.TextRulerMultiSlotRule;
+import org.apache.uima.tm.textruler.core.TextRulerRuleItem;
+import org.apache.uima.tm.textruler.core.TextRulerRulePattern;
+import org.apache.uima.tm.textruler.core.TextRulerSlotPattern;
+import org.apache.uima.tm.textruler.core.TextRulerStatisticsCollector;
+import org.apache.uima.tm.textruler.core.TextRulerTarget;
+import org.apache.uima.tm.textruler.core.TextRulerToolkit;
+
+public class WhiskRule extends TextRulerMultiSlotRule {
+
+ TextRulerExample seedExample;
+
+ public WhiskRule(WhiskRule copyFrom) {
+ super(copyFrom);
+ seedExample = copyFrom.seedExample;
+ }
+
+ public WhiskRule(TextRulerBasicLearner parentAlgorithm, TextRulerTarget target,
+ TextRulerExample seedExample) {
+ super(parentAlgorithm, target);
+ this.seedExample = seedExample;
+ }
+
+ @Override
+ public WhiskRule copy() {
+ return new WhiskRule(this);
+ }
+
+ public double getLaplacian() {
+ int e = 0;
+ int n = 0;
+
+ if (coveringStatistics != null) {
+ e = coveringStatistics.getCoveredNegativesCount();
+ n = coveringStatistics.getCoveredNegativesCount()
+ + coveringStatistics.getCoveredPositivesCount();
+ }
+ return ((double) e + 1) / ((double) n + 1);
+ }
+
+ public TextRulerExample getSeedExample() {
+ return seedExample;
+ }
+
+ @Override
+ public void setCoveringStatistics(TextRulerStatisticsCollector c) {
+ super.setCoveringStatistics(c);
+ if (TextRulerToolkit.DEBUG && c != null) {
+ if (!c.getCoveredPositiveExamples().contains(seedExample)) {
+ TextRulerToolkit.log("ERROR, A WHISK RULE MUST COVER AT LEAST ITS SEED EXAMPLE!");
+ TextRulerToolkit.log("\tRULE: " + getRuleString());
+ }
+ }
+ }
+
+ public boolean containsTerm(WhiskRuleItem term) {
+ for (TextRulerSlotPattern sp : slotPatterns) {
+ for (TextRulerRuleItem i : sp.preFillerPattern)
+ if (i.equals(term))
+ return true;
+ for (TextRulerRuleItem i : sp.fillerPattern)
+ if (i.equals(term))
+ return true;
+ for (TextRulerRuleItem i : sp.postFillerPattern)
+ if (i.equals(term))
+ return true;
+ }
+ return false;
+ }
+
+ // public WhiskRuleItem searchItemWithTermNumber(int no) {
+ // for (TextRulerSlotPattern sp : slotPatterns) {
+ // for (TextRulerRuleItem i : sp.preFillerPattern) {
+ // if (((WhiskRuleItem) i).getTermNumberInExample() == no) {
+ // return (WhiskRuleItem) i;
+ // }
+ // }
+ // for (TextRulerRuleItem i : sp.fillerPattern) {
+ // if (((WhiskRuleItem) i).getTermNumberInExample() == no) {
+ // return (WhiskRuleItem) i;
+ // }
+ // }
+ // for (TextRulerRuleItem i : sp.postFillerPattern) {
+ // if (((WhiskRuleItem) i).getTermNumberInExample() == no) {
+ // return (WhiskRuleItem) i;
+ // }
+ // }
+ // }
+ // return null;
+ // }
+
+ // TODO this could be moved to the core framework (TextRulerMultiSlotRule)
+ public WhiskRuleItem searchNeighborOfItem(WhiskRuleItem item, boolean goToLeft) {
+ int slotIndex = -1;
+ int patternIndex = -1;
+ int slotI = 0;
+ for (TextRulerSlotPattern sp : slotPatterns) {
+ for (TextRulerRuleItem it : sp.preFillerPattern) {
+ if (it == item) {
+ slotIndex = slotI;
+ patternIndex = 0; // 0=preFiller
+ break;
+ }
+ }
+ if (slotIndex < 0) {
+ for (TextRulerRuleItem it : sp.fillerPattern) {
+ if (it == item) {
+ slotIndex = slotI;
+ patternIndex = 1; // 1=filler
+ break;
+ }
+ }
+ }
+ if (slotIndex < 0) {
+ for (TextRulerRuleItem it : sp.postFillerPattern) {
+ if (it == item) {
+ slotIndex = slotI;
+ patternIndex = 2; // 2=postFiller
+ break;
+ }
+ }
+ }
+ if (slotIndex >= 0) {
+ break;
+ }
+ }
+ if (slotIndex < 0) // we didn't even find the item in our rule ?! how
+ // can this happen ?
+ return null;
+
+ TextRulerRulePattern currentPattern = getPattern(slotIndex, patternIndex);
+ while (currentPattern != null) {
+ int startIndex = currentPattern.indexOf(item); // this is only >= 0
+ // for the first
+ // pattern...
+ if (!goToLeft) // walk forward...
+ {
+ int startSearchFromIndex = startIndex + 1;
+ if (startSearchFromIndex < currentPattern.size())
+ return (WhiskRuleItem) currentPattern.get(startSearchFromIndex);
+ else // skip to next pattern
+ {
+ patternIndex++;
+ if (patternIndex > 2) {
+ patternIndex = 0;
+ slotIndex++;
+ if (slotIndex >= slotPatterns.size())
+ return null; // not found!
+ }
+ currentPattern = getPattern(slotIndex, patternIndex);
+ }
+ } else {
+ int startSearchFromIndex = startIndex >= 0 ? startIndex - 1 : currentPattern.size() - 1;
+ if (startSearchFromIndex >= 0 && currentPattern.size() > 0)
+ return (WhiskRuleItem) currentPattern.get(startSearchFromIndex);
+ else // skip to previous pattern
+ {
+ patternIndex--;
+ if (patternIndex < 0) {
+ patternIndex = 2;
+ slotIndex--;
+ if (slotIndex < 0)
+ return null; // not found!
+ }
+ currentPattern = getPattern(slotIndex, patternIndex);
+ }
+ }
+ }
+ return null;
+ }
+
+ private TextRulerRulePattern getPattern(int slotIndex, int patternIndex) {
+ TextRulerSlotPattern sp = slotPatterns.get(slotIndex);
+ if (patternIndex == 0)
+ return sp.preFillerPattern;
+ else if (patternIndex == 1)
+ return sp.fillerPattern;
+ else if (patternIndex == 2)
+ return sp.postFillerPattern;
+ else
+ return null;
+ }
+
+ public int totalConstraintPoints() {
+ int result = 0;
+ for (TextRulerSlotPattern sl : slotPatterns) {
+ for (TextRulerRuleItem i : sl.preFillerPattern) {
+ result += ((WhiskRuleItem) i).constraintPoints();
+ }
+ for (TextRulerRuleItem i : sl.fillerPattern) {
+ result += ((WhiskRuleItem) i).constraintPoints();
+ }
+ for (TextRulerRuleItem i : sl.postFillerPattern) {
+ result += ((WhiskRuleItem) i).constraintPoints();
+ }
+ }
+ return result;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRule.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRuleItem.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRuleItem.java?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRuleItem.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRuleItem.java Mon Aug 1 14:21:12 2011
@@ -0,0 +1,236 @@
+package org.apache.uima.tm.textruler.whisk.generic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.tm.textruler.core.TextRulerAnnotation;
+import org.apache.uima.tm.textruler.core.TextRulerRule;
+import org.apache.uima.tm.textruler.core.TextRulerRuleItem;
+import org.apache.uima.tm.textruler.core.TextRulerWordConstraint;
+
+public class WhiskRuleItem implements TextRulerRuleItem {
+
+ private TextRulerWordConstraint wordConstraint;
+
+ private boolean isStarWildCard = false;
+
+ // private int termNumberInExample = -1;
+
+ private boolean hideRegExp = false;
+
+ protected List<MLWhiskOtherConstraint> otherConstraints = new ArrayList<MLWhiskOtherConstraint>();
+
+ public static class MLWhiskOtherConstraint {
+
+ TextRulerAnnotation tokenAnnotation;
+
+ TextRulerAnnotation constraintAnnotation;
+
+ boolean canBeAnchor;
+
+ Type type;
+
+ public MLWhiskOtherConstraint(TextRulerAnnotation tokenAnnotation,
+ TextRulerAnnotation constraintAnnotation) {
+ this.tokenAnnotation = tokenAnnotation;
+ this.constraintAnnotation = constraintAnnotation;
+ this.type = constraintAnnotation.getType();
+ canBeAnchor = (tokenAnnotation.getBegin() == constraintAnnotation.getBegin())
+ && (tokenAnnotation.getEnd() == constraintAnnotation.getEnd());
+ // TODO is the matching END also a requirement ?
+ }
+
+ public boolean isTMBasicTypeTokenConstraint() {
+ return tokenAnnotation == constraintAnnotation;
+ }
+
+ public boolean canBeAnchorConstraint() {
+ return canBeAnchor;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ MLWhiskOtherConstraint co = (MLWhiskOtherConstraint) o;
+
+ return toString().equals(co.toString()) && (canBeAnchor == co.canBeAnchor);
+ }
+
+ @Override
+ public int hashCode() {
+ return toString().hashCode() * (canBeAnchor ? 2 : 1);
+ }
+
+ @Override
+ public String toString() {
+ return type.getShortName();
+ }
+
+ public MLWhiskOtherConstraint copy() {
+ return new MLWhiskOtherConstraint(tokenAnnotation, constraintAnnotation);
+ }
+
+ }
+
+ public WhiskRuleItem() {
+ super();
+ wordConstraint = null;
+ // termNumberInExample = -1;
+ }
+
+ public static WhiskRuleItem newWildCardItem(int startTermNumber) {
+ WhiskRuleItem i = new WhiskRuleItem();
+ i.setIsStarWildCard(true);
+ // i.setTermNumberInExample(startTermNumber);
+ return i;
+ }
+
+ public WhiskRuleItem(WhiskRuleItem copyFrom) {
+ super();
+ if (copyFrom.wordConstraint != null)
+ wordConstraint = copyFrom.wordConstraint.copy();
+ isStarWildCard = copyFrom.isStarWildCard;
+ // termNumberInExample = copyFrom.termNumberInExample;
+ hideRegExp = copyFrom.hideRegExp;
+ for (MLWhiskOtherConstraint c : copyFrom.otherConstraints)
+ otherConstraints.add(c.copy());
+ }
+
+ public WhiskRuleItem(TextRulerAnnotation tokenAnnotation) {
+ super();
+ setWordConstraint(new TextRulerWordConstraint(tokenAnnotation));
+ }
+
+ public void setWordConstraint(TextRulerWordConstraint c) {
+ wordConstraint = c;
+ }
+
+ public TextRulerWordConstraint getWordConstraint() {
+ return wordConstraint;
+ }
+
+ public TextRulerRuleItem copy() {
+ return new WhiskRuleItem(this);
+ }
+
+ public String getStringForRuleString(TextRulerRule rule, MLRuleItemType type,
+ int numberInPattern, int patternSize, int numberInRule, int ruleSize, int slotIndex) {
+
+ String result = "";
+ WhiskRule whiskRule = (WhiskRule) rule;
+ boolean isMarkingItem = type == MLRuleItemType.FILLER && numberInPattern == 0;
+ ArrayList<String> constraints = new ArrayList<String>();
+
+ String anchor = null;
+
+ if (wordConstraint != null) {
+ if (wordConstraint.isRegExpConstraint()) {
+ anchor = wordConstraint.typeShortName();
+ if (!hideRegExp)
+ constraints.add("REGEXP(\"" + wordConstraint + "\")");
+ } else
+ anchor = wordConstraint.toString();
+ }
+
+ MLWhiskOtherConstraint anchorConstraint = null;
+ if (anchor == null) {
+ for (MLWhiskOtherConstraint c : otherConstraints)
+ if (c.canBeAnchorConstraint()) {
+ anchorConstraint = c;
+ break;
+ }
+ }
+
+ for (MLWhiskOtherConstraint oc : otherConstraints) {
+ if (oc != anchorConstraint) {
+ if (oc.canBeAnchorConstraint())
+ constraints.add("IS(" + oc + ")");
+ else
+ constraints.add("PARTOF(" + oc + ")");
+ }
+ }
+ if (anchor == null) {
+ if (anchorConstraint != null)
+ anchor = anchorConstraint.toString();
+ else
+ anchor = "ALL";
+ }
+
+ if (constraints.size() > 0) {
+ String cStr = "";
+ for (String constraintStr : constraints) {
+ if (cStr.length() > 0)
+ cStr += ", ";
+ cStr += constraintStr;
+ }
+ result += "{" + cStr;
+ if (!isMarkingItem)
+ result += "}";
+ }
+
+ if (isMarkingItem) {
+ if (constraints.size() == 0)
+ result += "{";
+ result += "->MARKONCE(" + whiskRule.getMarkName(slotIndex);
+ if (patternSize > 1)
+ result += ", " + (numberInRule + 1) + ", " + (numberInRule + patternSize);
+ result += ")}";
+ }
+ if (isStarWildCard)
+ anchor += "*?";
+ return anchor + result;
+ }
+
+ public void setIsStarWildCard(boolean flag) {
+ isStarWildCard = flag;
+ }
+
+ public boolean isStarWildCard() {
+ return isStarWildCard;
+ }
+
+ // public void setTermNumberInExample(int i) {
+ // termNumberInExample = i;
+ // }
+
+ // public int getTermNumberInExample() {
+ // return termNumberInExample;
+ // }
+
+ public boolean equals(TextRulerRuleItem o) {
+ WhiskRuleItem it = (WhiskRuleItem) o;
+ if (wordConstraint != null)
+ if (!wordConstraint.equals(it.wordConstraint))
+ return false;
+
+ return isStarWildCard == it.isStarWildCard; // && termNumberInExample == it.termNumberInExample;
+ }
+
+ @Override
+ public String toString() {
+ return getStringForRuleString(null, null, 0, 0, 0, 0, 0);
+ }
+
+ public void setHideRegExp(boolean flag) {
+ hideRegExp = flag;
+ }
+
+ public void addOtherConstraint(MLWhiskOtherConstraint c) {
+ if (!otherConstraints.contains(c))
+ otherConstraints.add(c);
+ }
+
+ public List<MLWhiskOtherConstraint> getOtherConstraints() {
+ return otherConstraints;
+ }
+
+ public int constraintPoints() {
+ int result = 0;
+ if (wordConstraint != null)
+ result += hideRegExp ? 1 : 3; // a regexp constraint is less general
+ // so point it bad here!
+ result += otherConstraints.size();
+ return result;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRuleItem.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/generic/WhiskRuleItem.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/Whisk.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/Whisk.java?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/Whisk.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/Whisk.java Mon Aug 1 14:21:12 2011
@@ -0,0 +1,653 @@
+package org.apache.uima.tm.textruler.whisk.token;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.tm.textruler.core.TextRulerAnnotation;
+import org.apache.uima.tm.textruler.core.TextRulerBasicLearner;
+import org.apache.uima.tm.textruler.core.TextRulerExample;
+import org.apache.uima.tm.textruler.core.TextRulerExampleDocument;
+import org.apache.uima.tm.textruler.core.TextRulerRule;
+import org.apache.uima.tm.textruler.core.TextRulerRuleList;
+import org.apache.uima.tm.textruler.core.TextRulerRulePattern;
+import org.apache.uima.tm.textruler.core.TextRulerSlotPattern;
+import org.apache.uima.tm.textruler.core.TextRulerStatisticsCollector;
+import org.apache.uima.tm.textruler.core.TextRulerTarget;
+import org.apache.uima.tm.textruler.core.TextRulerToolkit;
+import org.apache.uima.tm.textruler.extension.TextRulerLearnerDelegate;
+import org.apache.uima.tm.textruler.whisk.token.WhiskRuleItem.MLWhiskOtherConstraint;
+
+public class Whisk extends TextRulerBasicLearner {
+
+ public final static String WINDOSIZE_KEY = "windowSize";
+
+ public final static String ERROR_THRESHOLD_KEY = "errorThreshold";
+
+ public final static String POSTAG_ROOTTYPE_KEY = "posTagRootType";
+
+ public final static int STANDARD_WINDOWSIZE = 5;
+
+ public final static float STANDARD_ERROR_THRESHOLD = 0.1f;
+
+ public final static String STANDARD_POSTAG_ROOTTYPE = "de.uniwue.ml.ML.postag";
+
+ TextRulerRuleList ruleList;
+
+ protected Set<TextRulerExample> coveredExamples;
+
+ protected int windowSize = STANDARD_WINDOWSIZE;
+
+ protected double errorThreshold = STANDARD_ERROR_THRESHOLD;
+
+ protected String posTagRootTypeName = STANDARD_POSTAG_ROOTTYPE;
+
+ int roundNumber = 0;
+
+ int allExamplesCount = 0;
+
+ private Map<String, TextRulerStatisticsCollector> cachedTestedRuleStatistics = new HashMap<String, TextRulerStatisticsCollector>();
+
+ public Whisk(String inputDir, String prePropTmFile, String tmpDir, String[] slotNames,
+ Set<String> filterSet, TextRulerLearnerDelegate delegate) {
+ super(inputDir, prePropTmFile, tmpDir, slotNames, filterSet, delegate);
+ }
+
+ @Override
+ public boolean collectNegativeCoveredInstancesWhenTesting() {
+ return false;
+ }
+
+ @Override
+ protected void doRun() {
+
+ // we don't use the same overall structure like the original WHISK since
+ // we do not
+ // repeat the whole process for some new training documents at the
+ // user's request, we
+ // learn like the other algorithms from the whole training set, so we
+ // for example do not
+ // need to test the intermediate rule base on a newly "incoming"
+ // training document since we
+ // tested all rules already on all training documents !
+
+ // this version of whisk is not tested for mutli slot learning since the
+ // seminar announcements
+ // are not quite suitable for this task: they do not all contain all 4
+ // slots and some of them
+ // occur more than once in one document ! And the order of them is not
+ // always the same as well!
+ // so this is now made only tested for the single slot case even if it
+ // is built capable of multislot
+ // examples!
+
+ // this is the inner loop of the WHISK pseudo-code:
+ // For each inst in Training
+ // for each tag
+
+ cachedTestedRuleStatistics.clear();
+ ruleList = new TextRulerRuleList();
+ coveredExamples = new HashSet<TextRulerExample>();
+
+ sendStatusUpdateToDelegate("Creating examples...", TextRulerLearnerState.ML_RUNNING, false);
+ TextRulerTarget target = new TextRulerTarget(slotNames[0], this); // only
+ // single-slot-target
+ // for now
+ exampleDocuments.createExamplesForTarget(target);
+
+ TextRulerExampleDocument[] docs = exampleDocuments.getSortedDocumentsInCacheOptimizedOrder();
+
+ allExamplesCount = exampleDocuments.getAllPositiveExamples().size();
+
+ for (TextRulerExampleDocument inst : docs) {
+ List<TextRulerExample> tags = inst.getPositiveExamples();
+
+ // for each uncovered example -> induce a new rule:
+ for (TextRulerExample tag : tags) {
+ if (!coveredExamples.contains(tag)) {
+ roundNumber++;
+ WhiskRule newRule = growRule(inst, tag);
+ if (shouldAbort())
+ break;
+ // if (newRule == null)
+ // break;
+ // else
+ if (newRule != null
+ && (newRule.getCoveringStatistics().getCoveredNegativesCount() == 00 || newRule
+ .getLaplacian() <= errorThreshold)) {
+ ruleList.addRule(newRule);
+ coveredExamples.addAll(newRule.getCoveringStatistics().getCoveredPositiveExamples());
+ sendStatusUpdateToDelegate("New Rule added...", TextRulerLearnerState.ML_RUNNING, true);
+ }
+ }
+ }
+ if (shouldAbort())
+ return;
+ }
+ sendStatusUpdateToDelegate("Done", TextRulerLearnerState.ML_DONE, true);
+ cachedTestedRuleStatistics.clear();
+ }
+
+ protected WhiskRule growRule(TextRulerExampleDocument doc, TextRulerExample example) {
+ sendStatusUpdateToDelegate("Creating new rule from seed...", TextRulerLearnerState.ML_RUNNING,
+ false);
+ WhiskRule theRule = new WhiskRule(this, example.getTarget(), example);
+ int numberOfSlotsInTag = example.getAnnotations().length;
+ for (int i = 0; i < numberOfSlotsInTag; i++)
+ theRule.getPatterns().add(new TextRulerSlotPattern());
+
+ List<WhiskRuleItem> allTerms = getAllTermsOfExample(example);
+
+ sendStatusUpdateToDelegate("Creating new rule: anchoring...", TextRulerLearnerState.ML_RUNNING,
+ false);
+ for (int i = 0; i < numberOfSlotsInTag; i++) {
+ theRule = anchor(theRule, doc, example, allTerms, i);
+ if (shouldAbort())
+ return null;
+ }
+
+ sendStatusUpdateToDelegate("Creating new rule: extending...", TextRulerLearnerState.ML_RUNNING,
+ false);
+ if (theRule != null) {
+ double oldLaplacian = theRule.getLaplacian();
+ int subRoundNumber = 0;
+ // repeat while we still make errors...
+ while (theRule.getCoveringStatistics().getCoveredNegativesCount() > 0) {
+ WhiskRule extendedRule = extendRule(theRule, doc, example, allTerms, subRoundNumber);
+ if (extendedRule == null) {
+ // this way we get the previous rule
+ // as the best rule...
+ break;
+ }
+ theRule = extendedRule;
+ TextRulerToolkit.log("----------------------------");
+ TextRulerToolkit.log("BEST EXTENSION IS: " + theRule.getRuleString());
+ TextRulerToolkit.log("Laplacian: " + theRule.getLaplacian() + " ; "
+ + theRule.getCoveringStatistics());
+ subRoundNumber++;
+
+ double newLaplacian = theRule.getLaplacian();
+ if (newLaplacian >= oldLaplacian) {
+ break;
+ }
+ oldLaplacian = newLaplacian;
+ }
+ TextRulerToolkit.log("----------------------------");
+ TextRulerToolkit.log("FINAL RULE IS : " + theRule.getRuleString());
+ }
+ return theRule;
+ }
+
+ protected WhiskRule extendRule(WhiskRule rule, TextRulerExampleDocument doc,
+ TextRulerExample example, List<WhiskRuleItem> allTerms, int subRoundNumber) {
+ WhiskRule bestRule = null;
+ double bestL = 1.0;
+ int bestRuleConstraintPoints = -1;
+ if (rule.getLaplacian() <= errorThreshold) {
+ bestRule = rule;
+ bestL = rule.getLaplacian();
+ }
+
+ List<WhiskRuleItem> slotTerms = getTermsWithinBounds(allTerms, example.getAnnotations()[0]
+ .getBegin(), example.getAnnotations()[0].getEnd());
+ WhiskRuleItem firstSlotTerm = slotTerms.get(0);
+ WhiskRuleItem lastSlotTerm = slotTerms.get(slotTerms.size() - 1);
+
+ List<TextRulerRule> rulesToTest = new ArrayList<TextRulerRule>();
+ for (WhiskRuleItem term : allTerms) {
+ if (rule.containsTerm(term)) {
+ continue;
+ }
+
+ boolean rejectTerm = false;
+ // for now this works only for slot 0 (no multislot stuff here yet!)
+ if (term.getTermNumberInExample() < firstSlotTerm.getTermNumberInExample())
+ rejectTerm = firstSlotTerm.getTermNumberInExample() - term.getTermNumberInExample() > windowSize;
+ else if (term.getTermNumberInExample() > lastSlotTerm.getTermNumberInExample())
+ rejectTerm = term.getTermNumberInExample() - firstSlotTerm.getTermNumberInExample() > windowSize;
+
+ if (rejectTerm) {
+ // out of window scope -> skip to next...
+ continue;
+ }
+
+ WhiskRule proposedRule = createNewRuleByAddingTerm(rule, term);
+ WhiskRuleItem t = proposedRule.searchItemWithTermNumber(term.getTermNumberInExample());
+
+ if (!rulesToTest.contains(proposedRule))
+ rulesToTest.add(proposedRule);
+
+ // add a second version where we remove the exact token content if
+ // it is a regexp item:
+ WhiskRule proposedRule2 = null;
+ WhiskRuleItem t2 = null;
+ if (t.getWordConstraint().isRegExpConstraint()) {
+ proposedRule2 = proposedRule.copy();
+ t2 = proposedRule2.searchItemWithTermNumber(term.getTermNumberInExample());
+ t2.setHideRegExp(true);
+ proposedRule2.setNeedsCompile(true);
+ if (!rulesToTest.contains(proposedRule2)) {
+ rulesToTest.add(proposedRule2);
+ }
+ }
+
+ // and now, for WHISK performance testing purposes, we also add POS
+ // tags:
+ // this is not very nice code and not dynamic feature capable, but
+ // for testpurposes
+ // in order to test WHISK with PosTag Terms...
+ if (posTagRootTypeName != null && posTagRootTypeName.length() > 0) {
+ TextRulerAnnotation tokenAnnotation = term.getWordConstraint().getTokenAnnotation();
+ CAS cas = example.getDocumentCAS();
+ TypeSystem ts = cas.getTypeSystem();
+ Type posTagsRootType = ts.getType(posTagRootTypeName);
+ if (ts != null) {
+ // POS-Tags created by our test hmm tagger.
+ List<AnnotationFS> posTagAnnotations = TextRulerToolkit.getAnnotationsWithinBounds(cas,
+ tokenAnnotation.getBegin(), tokenAnnotation.getEnd(), null, posTagsRootType);
+ if (posTagAnnotations.size() > 0) {
+ AnnotationFS posTag = posTagAnnotations.get(0);
+ if (posTag.getBegin() == tokenAnnotation.getBegin()
+ && posTag.getEnd() == tokenAnnotation.getEnd()) {
+ TextRulerAnnotation posTagAnnotation = new TextRulerAnnotation(posTag, doc);
+
+ // 1. most specific term with all constraints we
+ // have:
+ WhiskRule proposedRule3 = proposedRule.copy();
+ WhiskRuleItem t3 = proposedRule3.searchItemWithTermNumber(term
+ .getTermNumberInExample());
+ t3.addOtherConstraint(new MLWhiskOtherConstraint(tokenAnnotation, posTagAnnotation));
+ proposedRule3.setNeedsCompile(true);
+ if (!rulesToTest.contains(proposedRule3))
+ rulesToTest.add(proposedRule3);
+
+ // 2. the same without the regexp thingy:
+ if (proposedRule2 != null) {
+ WhiskRule proposedRule4 = proposedRule2.copy();
+ WhiskRuleItem t4 = proposedRule4.searchItemWithTermNumber(term
+ .getTermNumberInExample());
+ t4
+ .addOtherConstraint(new MLWhiskOtherConstraint(tokenAnnotation,
+ posTagAnnotation));
+ proposedRule4.setNeedsCompile(true);
+ if (!rulesToTest.contains(proposedRule4))
+ rulesToTest.add(proposedRule4);
+ }
+
+ // 3. last but not least: a rule with only the pos
+ // tag constraint:
+ WhiskRule proposedRule5 = proposedRule.copy();
+ WhiskRuleItem t5 = proposedRule5.searchItemWithTermNumber(term
+ .getTermNumberInExample());
+ t5.addOtherConstraint(new MLWhiskOtherConstraint(tokenAnnotation, posTagAnnotation));
+ t5.setWordConstraint(null);
+ proposedRule5.setNeedsCompile(true);
+ if (!rulesToTest.contains(proposedRule5))
+ rulesToTest.add(proposedRule5);
+ }
+ }
+ }
+ }
+
+ }
+ if (rulesToTest.size() == 0)
+ return bestRule;
+
+ sendStatusUpdateToDelegate(
+ "Round "
+ + roundNumber
+ + "."
+ + subRoundNumber
+ + " - Testing "
+ + rulesToTest.size()
+ + " rules... "
+ + " - uncovered examples: "
+ + (allExamplesCount - coveredExamples.size() + " / " + allExamplesCount
+ + " ; cs=" + cachedTestedRuleStatistics.size()),
+ TextRulerLearnerState.ML_RUNNING, false);
+
+ TextRulerToolkit.log("Testing " + rulesToTest.size() + " rules on training set...");
+ for (TextRulerRule r : rulesToTest)
+ TextRulerToolkit.log(r.getRuleString());
+ testRulesIfNotCached(rulesToTest); // testRulesOnDocumentSet(rulesToTest,
+ // exampleDocuments);
+ if (shouldAbort())
+ return null;
+ for (TextRulerRule r : rulesToTest) {
+ WhiskRule wr = (WhiskRule) r;
+ if (wr.getLaplacian() < bestL) {
+ bestL = wr.getLaplacian();
+ bestRule = wr;
+ bestRuleConstraintPoints = bestRule.totalConstraintPoints();
+ } else if (wr.getLaplacian() == bestL && bestRuleConstraintPoints >= 0) {
+ TextRulerToolkit.log("Same Laplacian! So prefer more general rule!");
+ if (wr.totalConstraintPoints() < bestRuleConstraintPoints) {
+ TextRulerToolkit.log("\tYes, prefered!");
+ bestL = wr.getLaplacian();
+ bestRule = wr;
+ bestRuleConstraintPoints = bestRule.totalConstraintPoints();
+ }
+ }
+ }
+ return bestRule;
+ }
+
+ protected WhiskRule createNewRuleByAddingTerm(WhiskRule baseRule, WhiskRuleItem term) {
+ WhiskRule newRule = baseRule.copy();
+ int foundSlotNumber = -1; // debug info
+ String foundSlotPattern = "";
+ int termNumber = term.getTermNumberInExample();
+ // determine, where this term is located relatively to the slots we
+ // have...
+ TextRulerRulePattern targetPattern = null;
+ TextRulerRulePattern previousSlotPostFillerPattern = null;
+ for (int i = 0; i < newRule.getPatterns().size(); i++) {
+ TextRulerSlotPattern slotPattern = newRule.getPatterns().get(i);
+ WhiskRuleItem it = (WhiskRuleItem) slotPattern.preFillerPattern.lastItem(); // look at the
+ // prefiller
+ // pattern
+ if (it != null && termNumber <= it.getTermNumberInExample())
+ targetPattern = slotPattern.preFillerPattern;
+ if (targetPattern == null && slotPattern.fillerPattern.size() > 0) // now
+ // look
+ // at
+ // the
+ // filler
+ // pattern
+ {
+ it = (WhiskRuleItem) slotPattern.fillerPattern.firstItem();
+ if (termNumber < it.getTermNumberInExample()) // it's still for
+ // the prefiller
+ // pattern but it
+ // seems to be
+ // emtpy so we
+ // could not find
+ // that out above!
+ targetPattern = slotPattern.preFillerPattern;
+ else {
+ it = (WhiskRuleItem) slotPattern.fillerPattern.lastItem();
+ if (termNumber <= it.getTermNumberInExample()) {
+ targetPattern = slotPattern.fillerPattern;
+ }
+ }
+ }
+ if (targetPattern == null && slotPattern.postFillerPattern.size() > 0) // now look at
+ // the
+ // postfiller
+ // pattern
+ {
+ it = (WhiskRuleItem) slotPattern.postFillerPattern.firstItem();
+ if (termNumber < it.getTermNumberInExample()) // it's still for
+ // the filler
+ // pattern but it
+ // seems to be
+ // emtpy so we
+ // could not find
+ // that out above!
+ targetPattern = slotPattern.fillerPattern;
+ else {
+ it = (WhiskRuleItem) slotPattern.postFillerPattern.lastItem();
+ if (termNumber <= it.getTermNumberInExample())
+ targetPattern = slotPattern.postFillerPattern;
+ }
+ }
+ if (targetPattern == null) {
+ targetPattern = previousSlotPostFillerPattern;
+ if (i > 0) {
+ TextRulerSlotPattern prevSlotPattern = newRule.getPatterns().get(i - 1);
+ foundSlotPattern = targetPattern == prevSlotPattern.preFillerPattern ? "PRE FILLER"
+ : (targetPattern == prevSlotPattern.fillerPattern ? "FILLER" : "POST FILLER");
+ foundSlotNumber = i - 1;
+ }
+ } else {
+ foundSlotPattern = targetPattern == slotPattern.preFillerPattern ? "PRE FILLER"
+ : (targetPattern == slotPattern.fillerPattern ? "FILLER" : "POST FILLER");
+ foundSlotNumber = i;
+ }
+ previousSlotPostFillerPattern = slotPattern.postFillerPattern;
+ }
+
+ if (targetPattern == null) {
+ targetPattern = previousSlotPostFillerPattern;
+ foundSlotNumber = newRule.getPatterns().size() - 1;
+ foundSlotPattern = "POST FILLER";
+ }
+
+ if (targetPattern == null) {
+ TextRulerToolkit.log("ERROR, NO TARGET PATTERN FOR NEW RULE TERM FOUND !");
+ } else {
+ // TextRulerToolkit.log("Ok, found for Rule: "+newRule.getRuleString());
+ // TextRulerToolkit.log("Term: "+term.getTermNumberInExample()+" ; "+term);
+ // TextRulerToolkit.log("Slot "+foundSlotNumber+" - Pattern: "+foundSlotPattern);
+ // now put that term into the rule:
+ int indexInPattern = -1;
+ if (targetPattern.size() == 0) {
+ targetPattern.add(term.copy());
+ indexInPattern = 0;
+ } else {
+ // 1. search if the term would replace a wildcard:
+ WhiskRuleItem wildCard = newRule.searchItemWithTermNumber(termNumber);
+ if (wildCard != null) {
+ if (!wildCard.isStarWildCard()) {
+ TextRulerToolkit
+ .log("ERROR, FOUND A TERM WITH THE SAME NUMBER THAT IS NOT A WILDCARD! HOW IS THAT???");
+ return null;
+ }
+ if (!targetPattern.contains(wildCard)) {
+ TextRulerToolkit.log("EVEN WORSE, THAT MUST NOT BE AT ALL!");
+ return null;
+ }
+ indexInPattern = targetPattern.indexOf(wildCard);
+ targetPattern.set(indexInPattern, term.copy());
+ } else {
+ // not a wildcard, so search for the insertion point:
+ for (int i = 0; i < targetPattern.size(); i++) {
+ WhiskRuleItem it = (WhiskRuleItem) targetPattern.get(i);
+ if (termNumber < it.getTermNumberInExample()) {
+ indexInPattern = i;
+ break;
+ }
+ }
+ if (indexInPattern < 0) {
+ indexInPattern = targetPattern.size();
+ targetPattern.add(term.copy());
+ } else
+ targetPattern.add(indexInPattern, term.copy());
+ }
+ }
+ // ok, now we have replaced a wildcard with the term or added the
+ // term between two other items.
+ // we now have to check the neighbors of the new term: if it is a
+ // direct neighbor (according to the termNumber),
+ // we have nothing special to do. but if it is not a direct
+ // neighbor, we have to add a wildcard between the two items (if the
+ // neighbor item
+ // is not a wildcard itself!
+ WhiskRuleItem newTerm = (WhiskRuleItem) targetPattern.get(indexInPattern);
+
+ // look at left neighbor:
+ WhiskRuleItem left = newRule.searchNeighborOfItem(newTerm, true);
+ if (left != null) {
+ // TextRulerToolkit.log("LEFT NEIGHBOR FOUND!");
+
+ // so we have a left neighbor. let's see if it also is the
+ // neighbor in our seed token stream:
+ if (left.getTermNumberInExample() < newTerm.getTermNumberInExample() - 1
+ && !left.isStarWildCard()) { // no direct neighbor and
+ // no wildcard yet,
+ // so insert a wildcard between us!
+ targetPattern.add(indexInPattern, WhiskRuleItem.newWildCardItem(left
+ .getTermNumberInExample() + 1));
+ indexInPattern++;
+ }
+ }
+
+ // look at right neighbor:
+ WhiskRuleItem right = newRule.searchNeighborOfItem(newTerm, false);
+ if (right != null) {
+ // TextRulerToolkit.log("RIGHT NEIGHBOR FOUND!");
+ // so we have a right neighbor. let's see if it also is the
+ // neighbor in our seed token stream:
+ if (right.getTermNumberInExample() > newTerm.getTermNumberInExample() + 1
+ && !right.isStarWildCard()) { // no direct neighbor and
+ // no wildcard yet,
+ // so insert a wildcard between us!
+ WhiskRuleItem wc = WhiskRuleItem.newWildCardItem(newTerm.getTermNumberInExample() + 1);
+ if (indexInPattern + 1 < targetPattern.size())
+ targetPattern.add(indexInPattern + 1, wc);
+ else
+ targetPattern.add(wc);
+ }
+ }
+
+ newRule.setNeedsCompile(true);
+ // TextRulerToolkit.log("BEFORE: "+baseRule.getRuleString());
+ // TextRulerToolkit.log("AFTER : "+newRule.getRuleString());
+ // TextRulerToolkit.log("");
+ }
+ if (newRule.getRuleString().equals(baseRule.getRuleString())) // this
+ // must
+ // not be!
+ return null;
+ else
+ return newRule;
+ }
+
+ protected WhiskRule anchor(WhiskRule rule, TextRulerExampleDocument doc,
+ TextRulerExample example, List<WhiskRuleItem> allTerms, int slotIndex) {
+ TextRulerAnnotation slotAnnotation = example.getAnnotations()[slotIndex];
+ List<WhiskRuleItem> inside = getTermsWithinBounds(allTerms, slotAnnotation.getBegin(),
+ slotAnnotation.getEnd());
+
+ if (rule == null || inside.isEmpty()) {
+ return null;
+ }
+ // create base 1 and base 2:
+ WhiskRule base1 = rule.copy(); // slot filler rule
+ TextRulerSlotPattern slotPattern = base1.getPatterns().get(slotIndex);
+ for (int i = 0; i < inside.size(); i++)
+ if (i == 0 || (i == inside.size() - 1))
+ slotPattern.fillerPattern.add(inside.get(i).copy());
+ else if (inside.size() > 2 && i < 2)
+ slotPattern.fillerPattern.add(WhiskRuleItem.newWildCardItem(inside.get(i)
+ .getTermNumberInExample()));
+
+ WhiskRule base2 = rule.copy(); // slot context rule
+ slotPattern = base2.getPatterns().get(slotIndex);
+
+ int firstOfSlot = allTerms.indexOf(inside.get(0));
+ int lastOfSlot = allTerms.indexOf(inside.get(inside.size() - 1));
+ if (firstOfSlot > 0)
+ slotPattern.preFillerPattern.add(allTerms.get(firstOfSlot - 1));
+ slotPattern.fillerPattern.add(WhiskRuleItem.newWildCardItem(inside.get(0)
+ .getTermNumberInExample()));
+ if (lastOfSlot + 1 < allTerms.size())
+ slotPattern.postFillerPattern.add(allTerms.get(lastOfSlot + 1));
+
+ TextRulerToolkit.log("base1: " + base1.getRuleString());
+ TextRulerToolkit.log("base2: " + base2.getRuleString());
+ List<TextRulerRule> testRules = new ArrayList<TextRulerRule>();
+ testRules.add(base1);
+ testRules.add(base2);
+ // testRulesOnDocumentSet(testRules, exampleDocuments);
+ testRulesIfNotCached(testRules);
+ if (shouldAbort())
+ return null;
+ TextRulerToolkit.log("\tbase1: " + base1.getCoveringStatistics() + " --> laplacian = "
+ + base1.getLaplacian());
+ TextRulerToolkit.log("\tbase2: " + base2.getCoveringStatistics() + " --> laplacian = "
+ + base2.getLaplacian());
+ if (base2.getCoveringStatistics().getCoveredPositivesCount() > base1.getCoveringStatistics()
+ .getCoveredPositivesCount())
+ return base2;
+ else
+ return base1;
+ }
+
+ public String getResultString() {
+ if (ruleList != null)
+ return getTMFileHeaderString() + ruleList.getRulesString("");
+ else
+ return "No results available yet!";
+ }
+
+ public void setParameters(Map<String, Object> params) {
+ if (TextRulerToolkit.DEBUG)
+ saveParametersToTempFolder(params);
+
+ // TODO try catch
+ if (params.containsKey(WINDOSIZE_KEY))
+ windowSize = (Integer) params.get(WINDOSIZE_KEY);
+
+ if (params.containsKey(ERROR_THRESHOLD_KEY))
+ errorThreshold = (Float) params.get(ERROR_THRESHOLD_KEY);
+
+ if (params.containsKey(POSTAG_ROOTTYPE_KEY))
+ posTagRootTypeName = (String) params.get(POSTAG_ROOTTYPE_KEY);
+
+ }
+
+ public List<WhiskRuleItem> getAllTermsOfExample(TextRulerExample example) {
+ CAS cas = example.getDocumentCAS();
+ Type tokensRootType = cas.getTypeSystem().getType(TextRulerToolkit.TM_ANY_TYPE_NAME);
+ List<AnnotationFS> all = TextRulerToolkit.getAnnotationsWithinBounds(cas, 0, cas
+ .getDocumentText().length() + 1, TextRulerToolkit.getFilterSetWithSlotNames(slotNames,
+ filterSet), tokensRootType);
+
+ List<WhiskRuleItem> result = new ArrayList<WhiskRuleItem>();
+ int i = 0;
+ for (AnnotationFS afs : all) {
+ WhiskRuleItem term = new WhiskRuleItem(new TextRulerAnnotation(afs, example.getDocument()));
+ term.setTermNumberInExample(i);
+ i++;
+ result.add(term);
+ }
+ return result;
+ }
+
+ public List<WhiskRuleItem> getTermsWithinBounds(List<WhiskRuleItem> allTerms, int startPos,
+ int endPos) {
+ List<WhiskRuleItem> result = new ArrayList<WhiskRuleItem>();
+ for (WhiskRuleItem term : allTerms) {
+ TextRulerAnnotation a = term.getWordConstraint().getTokenAnnotation();
+ if (a.getBegin() >= startPos && a.getEnd() <= endPos)
+ result.add(term);
+ if (a.getEnd() > endPos)
+ break;
+ }
+ return result;
+ }
+
+ // TODO share this between algorithms (e.g. LP2 and RAPIER, WHISK ?) and
+ // make a maximum size of the cache, etc. like CasCache?
+ protected void testRulesIfNotCached(List<TextRulerRule> rules) {
+ List<TextRulerRule> rulesToTest = new ArrayList<TextRulerRule>();
+
+ for (TextRulerRule r : rules) {
+ String key = r.getRuleString();
+ if (cachedTestedRuleStatistics.containsKey(key)) {
+ r.setCoveringStatistics(cachedTestedRuleStatistics.get(key).copy());
+ TextRulerToolkit.log("CACHE HIT !");
+ } else
+ rulesToTest.add(r);
+ }
+
+ if (rulesToTest.size() > 0) {
+ testRulesOnDocumentSet(rulesToTest, exampleDocuments);
+ if (shouldAbort())
+ return;
+ for (TextRulerRule r : rulesToTest) {
+ String key = r.getRuleString();
+ cachedTestedRuleStatistics.put(key, r.getCoveringStatistics().copy());
+ }
+ }
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/Whisk.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/Whisk.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskFactory.java?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskFactory.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskFactory.java Mon Aug 1 14:21:12 2011
@@ -0,0 +1,43 @@
+package org.apache.uima.tm.textruler.whisk.token;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.uima.tm.textruler.extension.TextRulerLearner;
+import org.apache.uima.tm.textruler.extension.TextRulerLearnerDelegate;
+import org.apache.uima.tm.textruler.extension.TextRulerLearnerFactory;
+import org.apache.uima.tm.textruler.extension.TextRulerLearnerParameter;
+import org.apache.uima.tm.textruler.extension.TextRulerLearnerParameter.MLAlgorithmParamType;
+
+public class WhiskFactory implements TextRulerLearnerFactory {
+
+ public TextRulerLearner createAlgorithm(String inputFolderPath, String additionalFolderPath,
+ String preprocessorTMfile, String tempFolderPath, String[] fullSlotTypeNames,
+ Set<String> filterSet, TextRulerLearnerDelegate delegate) {
+ return new Whisk(inputFolderPath, preprocessorTMfile, tempFolderPath, fullSlotTypeNames,
+ filterSet, delegate);
+ }
+
+ public Map<String, Object> getAlgorithmParameterStandardValues() {
+ Map<String, Object> result = new HashMap<String, Object>();
+ result.put(Whisk.WINDOSIZE_KEY, Whisk.STANDARD_WINDOWSIZE);
+ result.put(Whisk.ERROR_THRESHOLD_KEY, Whisk.STANDARD_ERROR_THRESHOLD);
+ result.put(Whisk.POSTAG_ROOTTYPE_KEY, Whisk.STANDARD_POSTAG_ROOTTYPE);
+ return result;
+ }
+
+ public TextRulerLearnerParameter[] getAlgorithmParameters() {
+ TextRulerLearnerParameter[] result = new TextRulerLearnerParameter[3];
+
+ result[0] = new TextRulerLearnerParameter(Whisk.WINDOSIZE_KEY, "Window Size",
+ MLAlgorithmParamType.ML_INT_PARAM);
+ result[1] = new TextRulerLearnerParameter(Whisk.ERROR_THRESHOLD_KEY, "Maximum Error Threshold",
+ MLAlgorithmParamType.ML_FLOAT_PARAM);
+ result[2] = new TextRulerLearnerParameter(Whisk.POSTAG_ROOTTYPE_KEY, "PosTag Root Type",
+ MLAlgorithmParamType.ML_STRING_PARAM);
+
+ return result;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskFactory.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRule.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRule.java?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRule.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRule.java Mon Aug 1 14:21:12 2011
@@ -0,0 +1,204 @@
+package org.apache.uima.tm.textruler.whisk.token;
+
+import org.apache.uima.tm.textruler.core.TextRulerBasicLearner;
+import org.apache.uima.tm.textruler.core.TextRulerExample;
+import org.apache.uima.tm.textruler.core.TextRulerMultiSlotRule;
+import org.apache.uima.tm.textruler.core.TextRulerRuleItem;
+import org.apache.uima.tm.textruler.core.TextRulerRulePattern;
+import org.apache.uima.tm.textruler.core.TextRulerSlotPattern;
+import org.apache.uima.tm.textruler.core.TextRulerStatisticsCollector;
+import org.apache.uima.tm.textruler.core.TextRulerTarget;
+import org.apache.uima.tm.textruler.core.TextRulerToolkit;
+
+public class WhiskRule extends TextRulerMultiSlotRule {
+
+ TextRulerExample seedExample;
+
+ public WhiskRule(WhiskRule copyFrom) {
+ super(copyFrom);
+ seedExample = copyFrom.seedExample;
+ }
+
+ public WhiskRule(TextRulerBasicLearner parentAlgorithm, TextRulerTarget target,
+ TextRulerExample seedExample) {
+ super(parentAlgorithm, target);
+ this.seedExample = seedExample;
+ }
+
+ @Override
+ public WhiskRule copy() {
+ return new WhiskRule(this);
+ }
+
+ public double getLaplacian() {
+ int e = 0;
+ int n = 0;
+
+ if (coveringStatistics != null) {
+ e = coveringStatistics.getCoveredNegativesCount();
+ n = coveringStatistics.getCoveredNegativesCount()
+ + coveringStatistics.getCoveredPositivesCount();
+ }
+ return ((double) e + 1) / ((double) n + 1);
+ }
+
+ public TextRulerExample getSeedExample() {
+ return seedExample;
+ }
+
+ @Override
+ public void setCoveringStatistics(TextRulerStatisticsCollector c) {
+ super.setCoveringStatistics(c);
+ if (TextRulerToolkit.DEBUG && c != null) {
+ if (!c.getCoveredPositiveExamples().contains(seedExample)) {
+ TextRulerToolkit.log("ERROR, A WHISK RULE MUST COVER AT LEAST ITS SEED EXAMPLE!");
+ TextRulerToolkit.log("\tRULE: " + getRuleString());
+ }
+ }
+ }
+
+ public boolean containsTerm(WhiskRuleItem term) {
+ for (TextRulerSlotPattern sp : slotPatterns) {
+ for (TextRulerRuleItem i : sp.preFillerPattern)
+ if (i.equals(term))
+ return true;
+ for (TextRulerRuleItem i : sp.fillerPattern)
+ if (i.equals(term))
+ return true;
+ for (TextRulerRuleItem i : sp.postFillerPattern)
+ if (i.equals(term))
+ return true;
+ }
+ return false;
+ }
+
+ public WhiskRuleItem searchItemWithTermNumber(int no) {
+ for (TextRulerSlotPattern sp : slotPatterns) {
+ for (TextRulerRuleItem i : sp.preFillerPattern) {
+ if (((WhiskRuleItem) i).getTermNumberInExample() == no) {
+ return (WhiskRuleItem) i;
+ }
+ }
+ for (TextRulerRuleItem i : sp.fillerPattern) {
+ if (((WhiskRuleItem) i).getTermNumberInExample() == no) {
+ return (WhiskRuleItem) i;
+ }
+ }
+ for (TextRulerRuleItem i : sp.postFillerPattern) {
+ if (((WhiskRuleItem) i).getTermNumberInExample() == no) {
+ return (WhiskRuleItem) i;
+ }
+ }
+ }
+ return null;
+ }
+
+ // TODO this could be moved to the core framework (TextRulerMultiSlotRule)
+ public WhiskRuleItem searchNeighborOfItem(WhiskRuleItem item, boolean goToLeft) {
+ int slotIndex = -1;
+ int patternIndex = -1;
+ int slotI = 0;
+ for (TextRulerSlotPattern sp : slotPatterns) {
+ for (TextRulerRuleItem it : sp.preFillerPattern) {
+ if (it == item) {
+ slotIndex = slotI;
+ patternIndex = 0; // 0=preFiller
+ break;
+ }
+ }
+ if (slotIndex < 0) {
+ for (TextRulerRuleItem it : sp.fillerPattern) {
+ if (it == item) {
+ slotIndex = slotI;
+ patternIndex = 1; // 1=filler
+ break;
+ }
+ }
+ }
+ if (slotIndex < 0) {
+ for (TextRulerRuleItem it : sp.postFillerPattern) {
+ if (it == item) {
+ slotIndex = slotI;
+ patternIndex = 2; // 2=postFiller
+ break;
+ }
+ }
+ }
+ if (slotIndex >= 0) {
+ break;
+ }
+ }
+ if (slotIndex < 0) // we didn't even find the item in our rule ?! how
+ // can this happen ?
+ return null;
+
+ TextRulerRulePattern currentPattern = getPattern(slotIndex, patternIndex);
+ while (currentPattern != null) {
+ int startIndex = currentPattern.indexOf(item); // this is only >= 0
+ // for the first
+ // pattern...
+ if (!goToLeft) // walk forward...
+ {
+ int startSearchFromIndex = startIndex + 1;
+ if (startSearchFromIndex < currentPattern.size())
+ return (WhiskRuleItem) currentPattern.get(startSearchFromIndex);
+ else // skip to next pattern
+ {
+ patternIndex++;
+ if (patternIndex > 2) {
+ patternIndex = 0;
+ slotIndex++;
+ if (slotIndex >= slotPatterns.size())
+ return null; // not found!
+ }
+ currentPattern = getPattern(slotIndex, patternIndex);
+ }
+ } else {
+ int startSearchFromIndex = startIndex >= 0 ? startIndex - 1 : currentPattern.size() - 1;
+ if (startSearchFromIndex >= 0 && currentPattern.size() > 0)
+ return (WhiskRuleItem) currentPattern.get(startSearchFromIndex);
+ else // skip to previous pattern
+ {
+ patternIndex--;
+ if (patternIndex < 0) {
+ patternIndex = 2;
+ slotIndex--;
+ if (slotIndex < 0)
+ return null; // not found!
+ }
+ currentPattern = getPattern(slotIndex, patternIndex);
+ }
+ }
+ }
+ return null;
+ }
+
+ private TextRulerRulePattern getPattern(int slotIndex, int patternIndex) {
+ TextRulerSlotPattern sp = slotPatterns.get(slotIndex);
+ if (patternIndex == 0)
+ return sp.preFillerPattern;
+ else if (patternIndex == 1)
+ return sp.fillerPattern;
+ else if (patternIndex == 2)
+ return sp.postFillerPattern;
+ else
+ return null;
+ }
+
+ public int totalConstraintPoints() {
+ int result = 0;
+ for (TextRulerSlotPattern sl : slotPatterns) {
+ for (TextRulerRuleItem i : sl.preFillerPattern) {
+ result += ((WhiskRuleItem) i).constraintPoints();
+ }
+ for (TextRulerRuleItem i : sl.fillerPattern) {
+ result += ((WhiskRuleItem) i).constraintPoints();
+ }
+ for (TextRulerRuleItem i : sl.postFillerPattern) {
+ result += ((WhiskRuleItem) i).constraintPoints();
+ }
+ }
+ return result;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRule.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRule.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRuleItem.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRuleItem.java?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRuleItem.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRuleItem.java Mon Aug 1 14:21:12 2011
@@ -0,0 +1,236 @@
+package org.apache.uima.tm.textruler.whisk.token;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.cas.Type;
+import org.apache.uima.tm.textruler.core.TextRulerAnnotation;
+import org.apache.uima.tm.textruler.core.TextRulerRule;
+import org.apache.uima.tm.textruler.core.TextRulerRuleItem;
+import org.apache.uima.tm.textruler.core.TextRulerWordConstraint;
+
+public class WhiskRuleItem implements TextRulerRuleItem {
+
+ private TextRulerWordConstraint wordConstraint;
+
+ private boolean isStarWildCard = false;
+
+ private int termNumberInExample = -1;
+
+ private boolean hideRegExp = false;
+
+ protected List<MLWhiskOtherConstraint> otherConstraints = new ArrayList<MLWhiskOtherConstraint>();
+
+ public static class MLWhiskOtherConstraint {
+
+ TextRulerAnnotation tokenAnnotation;
+
+ TextRulerAnnotation constraintAnnotation;
+
+ boolean canBeAnchor;
+
+ Type type;
+
+ public MLWhiskOtherConstraint(TextRulerAnnotation tokenAnnotation,
+ TextRulerAnnotation constraintAnnotation) {
+ this.tokenAnnotation = tokenAnnotation;
+ this.constraintAnnotation = constraintAnnotation;
+ this.type = constraintAnnotation.getType();
+ canBeAnchor = (tokenAnnotation.getBegin() == constraintAnnotation.getBegin())
+ && (tokenAnnotation.getEnd() == constraintAnnotation.getEnd());
+ // TODO is the matching END also a requirement ?
+ }
+
+ public boolean isTMBasicTypeTokenConstraint() {
+ return tokenAnnotation == constraintAnnotation;
+ }
+
+ public boolean canBeAnchorConstraint() {
+ return canBeAnchor;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ MLWhiskOtherConstraint co = (MLWhiskOtherConstraint) o;
+
+ return toString().equals(co.toString()) && (canBeAnchor == co.canBeAnchor);
+ }
+
+ @Override
+ public int hashCode() {
+ return toString().hashCode() * (canBeAnchor ? 2 : 1);
+ }
+
+ @Override
+ public String toString() {
+ return type.getShortName();
+ }
+
+ public MLWhiskOtherConstraint copy() {
+ return new MLWhiskOtherConstraint(tokenAnnotation, constraintAnnotation);
+ }
+
+ }
+
+ public WhiskRuleItem() {
+ super();
+ wordConstraint = null;
+ termNumberInExample = -1;
+ }
+
+ public static WhiskRuleItem newWildCardItem(int startTermNumber) {
+ WhiskRuleItem i = new WhiskRuleItem();
+ i.setIsStarWildCard(true);
+ i.setTermNumberInExample(startTermNumber);
+ return i;
+ }
+
+ public WhiskRuleItem(WhiskRuleItem copyFrom) {
+ super();
+ if (copyFrom.wordConstraint != null)
+ wordConstraint = copyFrom.wordConstraint.copy();
+ isStarWildCard = copyFrom.isStarWildCard;
+ termNumberInExample = copyFrom.termNumberInExample;
+ hideRegExp = copyFrom.hideRegExp;
+ for (MLWhiskOtherConstraint c : copyFrom.otherConstraints)
+ otherConstraints.add(c.copy());
+ }
+
+ public WhiskRuleItem(TextRulerAnnotation tokenAnnotation) {
+ super();
+ setWordConstraint(new TextRulerWordConstraint(tokenAnnotation));
+ }
+
+ public void setWordConstraint(TextRulerWordConstraint c) {
+ wordConstraint = c;
+ }
+
+ public TextRulerWordConstraint getWordConstraint() {
+ return wordConstraint;
+ }
+
+ public TextRulerRuleItem copy() {
+ return new WhiskRuleItem(this);
+ }
+
+ public String getStringForRuleString(TextRulerRule rule, MLRuleItemType type,
+ int numberInPattern, int patternSize, int numberInRule, int ruleSize, int slotIndex) {
+
+ String result = "";
+ WhiskRule whiskRule = (WhiskRule) rule;
+ boolean isMarkingItem = type == MLRuleItemType.FILLER && numberInPattern == 0;
+ ArrayList<String> constraints = new ArrayList<String>();
+
+ String anchor = null;
+
+ if (wordConstraint != null) {
+ if (wordConstraint.isRegExpConstraint()) {
+ anchor = wordConstraint.typeShortName();
+ if (!hideRegExp)
+ constraints.add("REGEXP(\"" + wordConstraint + "\")");
+ } else
+ anchor = wordConstraint.toString();
+ }
+
+ MLWhiskOtherConstraint anchorConstraint = null;
+ if (anchor == null) {
+ for (MLWhiskOtherConstraint c : otherConstraints)
+ if (c.canBeAnchorConstraint()) {
+ anchorConstraint = c;
+ break;
+ }
+ }
+
+ for (MLWhiskOtherConstraint oc : otherConstraints) {
+ if (oc != anchorConstraint) {
+ if (oc.canBeAnchorConstraint())
+ constraints.add("IS(" + oc + ")");
+ else
+ constraints.add("PARTOF(" + oc + ")");
+ }
+ }
+ if (anchor == null) {
+ if (anchorConstraint != null)
+ anchor = anchorConstraint.toString();
+ else
+ anchor = "ALL";
+ }
+
+ if (constraints.size() > 0) {
+ String cStr = "";
+ for (String constraintStr : constraints) {
+ if (cStr.length() > 0)
+ cStr += ", ";
+ cStr += constraintStr;
+ }
+ result += "{" + cStr;
+ if (!isMarkingItem)
+ result += "}";
+ }
+
+ if (isMarkingItem) {
+ if (constraints.size() == 0)
+ result += "{";
+ result += "->MARKONCE(" + whiskRule.getMarkName(slotIndex);
+ if (patternSize > 1)
+ result += ", " + (numberInRule + 1) + ", " + (numberInRule + patternSize);
+ result += ")}";
+ }
+ if (isStarWildCard)
+ anchor += "*?";
+ return anchor + result;
+ }
+
+ public void setIsStarWildCard(boolean flag) {
+ isStarWildCard = flag;
+ }
+
+ public boolean isStarWildCard() {
+ return isStarWildCard;
+ }
+
+ public void setTermNumberInExample(int i) {
+ termNumberInExample = i;
+ }
+
+ public int getTermNumberInExample() {
+ return termNumberInExample;
+ }
+
+ public boolean equals(TextRulerRuleItem o) {
+ WhiskRuleItem it = (WhiskRuleItem) o;
+ if (wordConstraint != null)
+ if (!wordConstraint.equals(it.wordConstraint))
+ return false;
+
+ return isStarWildCard == it.isStarWildCard && termNumberInExample == it.termNumberInExample;
+ }
+
+ @Override
+ public String toString() {
+ return getStringForRuleString(null, null, 0, 0, 0, 0, 0);
+ }
+
+ public void setHideRegExp(boolean flag) {
+ hideRegExp = flag;
+ }
+
+ public void addOtherConstraint(MLWhiskOtherConstraint c) {
+ if (!otherConstraints.contains(c))
+ otherConstraints.add(c);
+ }
+
+ public List<MLWhiskOtherConstraint> getOtherConstraints() {
+ return otherConstraints;
+ }
+
+ public int constraintPoints() {
+ int result = 0;
+ if (wordConstraint != null)
+ result += hideRegExp ? 1 : 3; // a regexp constraint is less general
+ // so point it bad here!
+ result += otherConstraints.size();
+ return result;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRuleItem.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskRuleItem.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskTokenPreferencePage.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskTokenPreferencePage.java?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskTokenPreferencePage.java (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskTokenPreferencePage.java Mon Aug 1 14:21:12 2011
@@ -0,0 +1,102 @@
+package org.apache.uima.tm.textruler.whisk.token;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.apache.uima.tm.textruler.TextRulerPlugin;
+import org.apache.uima.tm.textruler.extension.TextRulerController;
+import org.apache.uima.tm.textruler.extension.TextRulerLearnerController;
+import org.apache.uima.tm.textruler.extension.TextRulerLearnerFactory;
+import org.apache.uima.tm.textruler.extension.TextRulerLearnerParameter;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class WhiskTokenPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ public static String ID = "org.apache.uima.tm.textruler.algorithmPages";
+
+ private TextRulerLearnerController algorithmController;
+
+ private IPreferenceStore store;
+
+ private ArrayList<FieldEditor> fields = new ArrayList<FieldEditor>();
+
+ public WhiskTokenPreferencePage() {
+ TextRulerLearnerController ctrl = TextRulerController.getControllerForID("org.apache.uima.tm.textruler.whisk.token");
+ this.algorithmController = ctrl;
+ store = TextRulerPlugin.getDefault().getPreferenceStore();
+ setPreferenceStore(store);
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite top = new Composite(parent, SWT.LEFT);
+ top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ top.setLayout(new GridLayout());
+
+ TextRulerLearnerFactory f = algorithmController.getFactory();
+ TextRulerLearnerParameter[] params = f.getAlgorithmParameters();
+ Map<String, Object> values = f.getAlgorithmParameterStandardValues();
+ if (params != null) {
+ for (int i = 0; i < params.length; i++) {
+ TextRulerLearnerParameter p = params[i];
+ String id = algorithmController.getID() + "." + p.id;
+ FieldEditor l = null;
+ switch (p.type) {
+ case ML_BOOL_PARAM: {
+ l = new BooleanFieldEditor(id, p.name, top);
+ fields.add(l);
+ store.setDefault(id, (Boolean) values.get(p.id));
+ l.setPreferenceStore(store);
+ l.load();
+ break;
+ }
+
+ case ML_FLOAT_PARAM:
+ case ML_INT_PARAM:
+ case ML_STRING_PARAM: {
+ l = new StringFieldEditor(id, p.name, top);
+ fields.add(l);
+ store.setDefault(id, values.get(p.id).toString());
+ l.setPreferenceStore(store);
+ l.load();
+ break;
+ }
+ case ML_SELECT_PARAM:
+ break;
+ }
+ }
+ }
+ return top;
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ @Override
+ protected void performDefaults() {
+ for (FieldEditor f : fields)
+ f.loadDefault();
+ // super.performDefaults();
+ }
+
+ @Override
+ public boolean performOk() {
+ for (FieldEditor f : fields)
+ f.store();
+ // return super.performOk();
+ return true;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskTokenPreferencePage.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.whisk/src/main/src/org/apache/uima/tm/textruler/whisk/token/WhiskTokenPreferencePage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Aug 1 14:21:12 2011
@@ -0,0 +1 @@
+.settings
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.classpath
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.classpath?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.classpath (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.classpath Mon Aug 1 14:21:12 2011
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.classpath
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.classpath
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.project
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.project?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.project (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.project Mon Aug 1 14:21:12 2011
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.uima.tm.textruler.wien</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.project
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/.project
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/META-INF/MANIFEST.MF?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/META-INF/MANIFEST.MF (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/META-INF/MANIFEST.MF Mon Aug 1 14:21:12 2011
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: TextRuler Wien Plugin
+Bundle-SymbolicName: org.apache.uima.tm.textruler.wien;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.apache.uima.tm.textruler.wien.WienPlugin
+Bundle-Vendor: University of Würzburg
+Require-Bundle: org.eclipse.core.runtime,
+ org.apache.uima.tm.textruler,
+ org.apache.uima.runtime;bundle-version="2.3.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/build.properties
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/build.properties?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/build.properties (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/build.properties Mon Aug 1 14:21:12 2011
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/build.properties
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/build.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/plugin.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/plugin.xml?rev=1152792&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/plugin.xml (added)
+++ uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/plugin.xml Mon Aug 1 14:21:12 2011
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.apache.uima.tm.textruler.learners">
+ <learner
+ class="org.apache.uima.tm.textruler.wien.WienFactory"
+ id="org.apache.uima.tm.textruler.wien"
+ name="WIEN">
+ </learner>
+ </extension>
+
+</plugin>
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/plugin.xml
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/org.apache.uima.tm.textruler.wien/plugin.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain