Revision: 8761
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=8761&view=rev
Author:   jaumeortola
Date:     2013-01-01 12:53:31 +0000 (Tue, 01 Jan 2013)
Log Message:
-----------
[ca] New disambiguation action: "filterall". 
Fixed bug in DisambiguationPatternRule: startPos attribute was lost in function 
replaceTokens().

Modified Paths:
--------------
    
trunk/JLanguageTool/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationPatternRule.java
    
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/disambiguation.xsd

Modified: 
trunk/JLanguageTool/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationPatternRule.java
===================================================================
--- 
trunk/JLanguageTool/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationPatternRule.java
      2013-01-01 12:42:29 UTC (rev 8760)
+++ 
trunk/JLanguageTool/src/main/java/org/languagetool/tagging/disambiguation/rules/DisambiguationPatternRule.java
      2013-01-01 12:53:31 UTC (rev 8761)
@@ -40,7 +40,7 @@
 
   /** Possible disambiguator actions. **/
   public enum DisambiguatorAction {
-    ADD, FILTER, REMOVE, REPLACE, UNIFY, IMMUNIZE;
+    ADD, FILTER, REMOVE, REPLACE, UNIFY, IMMUNIZE, FILTERALL;
 
     /**
      * Converts string to the constant enum.
@@ -105,7 +105,8 @@
         && disambAction != DisambiguatorAction.ADD
         && disambAction != DisambiguatorAction.REMOVE
         && disambAction != DisambiguatorAction.IMMUNIZE
-        && disambAction != DisambiguatorAction.REPLACE) {
+        && disambAction != DisambiguatorAction.REPLACE
+        && disambAction != DisambiguatorAction.FILTERALL) {
       throw new NullPointerException("disambiguated POS cannot be null");
     }    
     this.disambiguatedPOS = disamb;
@@ -276,10 +277,28 @@
         }
       }
       break;
+    case FILTERALL:
+               for (int i = 0; i < matchingTokens - startPositionCorrection
+                               + endPositionCorrection; i++) {
+                       final int position = 
text.getOriginalPosition(firstMatchToken
+                                       + correctedStPos + i);
+                       final Element myEl = 
patternElements.get(i+startPositionCorrection);
+                       final Match tmpMatchToken = new Match(myEl.getPOStag(), 
null,
+                                       true, myEl.getPOStag(), 
//myEl.isPOStagRegularExpression()
+                                       null, Match.CaseConversion.NONE, false, 
false,
+                                       Match.IncludeRange.NONE);
+                       tmpMatchToken.setToken(whTokens[position]);
+                       final String prevValue = whTokens[position].toString();
+                       final String prevAnot = whTokens[position]
+                                       .getHistoricalAnnotations();
+                       whTokens[position] = tmpMatchToken.filterReadings();
+                       annotateChange(whTokens[position], prevValue, prevAnot);
+               }
+               break;
     case IMMUNIZE: 
       for (int i = 0; i < matchingTokens - startPositionCorrection + 
endPositionCorrection; i++) {
         whTokens[text.getOriginalPosition(firstMatchToken + correctedStPos + 
i)].immunize();
-      }
+      }      
     case FILTER:
       if (matchElement == null) { // same as REPLACE if using <match>
         final Match tmpMatchToken = new Match(disambiguatedPOS, null, true,
@@ -358,6 +377,7 @@
       final boolean isSentEnd = oldAtr.isSentEnd();
       final boolean isParaEnd = oldAtr.isParaEnd();
       final boolean spaceBefore = oldAtr.isWhitespaceBefore();
+      final int startPosition = oldAtr.getStartPos();
       AnalyzedTokenReadings a = newAtr;      
       if (isSentEnd) {
           a.setSentEnd();            
@@ -366,6 +386,7 @@
             a.setParaEnd();
         }
       a.setWhitespaceBefore(spaceBefore);
+      a.setStartPos(startPosition);
       annotateChange(a, prevValue, prevAnot);
       return a;
   }

Modified: 
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/disambiguation.xsd
===================================================================
--- 
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/disambiguation.xsd
 2013-01-01 12:42:29 UTC (rev 8760)
+++ 
trunk/JLanguageTool/src/main/resources/org/languagetool/resource/disambiguation.xsd
 2013-01-01 12:53:31 UTC (rev 8761)
@@ -105,6 +105,7 @@
                                                <xs:enumeration value="replace" 
/>
                                                <xs:enumeration value="unify" />
                                                <xs:enumeration 
value="immunize" />
+                                               <xs:enumeration 
value="filterall" />
                                        </xs:restriction>
                                </xs:simpleType>
                        </xs:attribute>

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits

Reply via email to