Revision: 9019
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=9019&view=rev
Author:   jaumeortola
Date:     2013-01-14 17:07:59 +0000 (Mon, 14 Jan 2013)
Log Message:
-----------
Solved an issue with white spaces using include_skipped.

Modified Paths:
--------------
    trunk/JLanguageTool/src/main/java/org/languagetool/rules/patterns/Match.java
    trunk/JLanguageTool/src/main/resources/org/languagetool/rules/xx/grammar.xml
    
trunk/JLanguageTool/src/test/java/org/languagetool/rules/patterns/MatchTest.java

Modified: 
trunk/JLanguageTool/src/main/java/org/languagetool/rules/patterns/Match.java
===================================================================
--- 
trunk/JLanguageTool/src/main/java/org/languagetool/rules/patterns/Match.java    
    2013-01-14 11:06:33 UTC (rev 9018)
+++ 
trunk/JLanguageTool/src/main/java/org/languagetool/rules/patterns/Match.java    
    2013-01-14 17:07:59 UTC (rev 9019)
@@ -170,8 +170,8 @@
         formattedToken = null;
       }
       for (int k = index + 1; k < index + next; k++) {
-        if (k > index + 1 && 
-            tokens[k].isWhitespaceBefore()) {
+        if (tokens[k].isWhitespaceBefore()
+                       && !(k==index+1 && includeSkipped == 
IncludeRange.FOLLOWING)) {
           sb.append(' ');
         }
         sb.append(tokens[k].getToken());

Modified: 
trunk/JLanguageTool/src/main/resources/org/languagetool/rules/xx/grammar.xml
===================================================================
--- 
trunk/JLanguageTool/src/main/resources/org/languagetool/rules/xx/grammar.xml    
    2013-01-14 11:06:33 UTC (rev 9018)
+++ 
trunk/JLanguageTool/src/main/resources/org/languagetool/rules/xx/grammar.xml    
    2013-01-14 17:07:59 UTC (rev 9019)
@@ -335,7 +335,7 @@
                <token>end</token>
        </pattern>
        <message>Warning: <suggestion><match no="1" 
include_skipped="all"></match> xyz</suggestion></message>
-       <example type="incorrect" correction="abcdef ghi xyz">This is 
<marker>abc def ghi end</marker>.</example>
+       <example type="incorrect" correction="abc def ghi xyz">This is 
<marker>abc def ghi end</marker>.</example>
        <example type="correct">foobar</example>
     </rule>
     <rule id="test_unification_skipping" name="Test unification and skipping"> 
@@ -350,9 +350,9 @@
     </pattern>
     <message>This is not visible anyway<suggestion><match no="2" 
include_skipped="all"></match></suggestion>.</message>
     <example type="incorrect" correction="Abc">This is <marker>Test1 Abc Xyz 
end</marker>.</example>
-    <example type="incorrect" correction="AbcDef">This is <marker>Test1 Abc 
Def Xyz end</marker>.</example>
+    <example type="incorrect" correction="Abc Def">This is <marker>Test1 Abc 
Def Xyz end</marker>.</example>
     <!-- skipped elements are NOT unified -->
-    <example type="incorrect" correction="Abcdef">This is <marker>Test1 Abc 
def Xyz end</marker>.</example>
+    <example type="incorrect" correction="Abc def">This is <marker>Test1 Abc 
def Xyz end</marker>.</example>
     <example type="correct">This is Test1 abc Cde End.</example>
     </rule>
     <rulegroup id="test_spacebefore" name="Test spacebefore on exceptions">

Modified: 
trunk/JLanguageTool/src/test/java/org/languagetool/rules/patterns/MatchTest.java
===================================================================
--- 
trunk/JLanguageTool/src/test/java/org/languagetool/rules/patterns/MatchTest.java
    2013-01-14 11:06:33 UTC (rev 9018)
+++ 
trunk/JLanguageTool/src/test/java/org/languagetool/rules/patterns/MatchTest.java
    2013-01-14 17:07:59 UTC (rev 9019)
@@ -228,16 +228,14 @@
        public void testIncludeAll() throws Exception {
                Match match = getMatch(null, null, Match.IncludeRange.ALL);
                match.setToken(getAnalyzedTokenReadings("inflectedform11 
inflectedform2 inflectedform122 inflectedform122"), 1, 3);
-               assertEquals("[inflectedform11inflectedform2 
inflectedform122]", Arrays.toString(match.toFinalString(null)));
-               // the first two tokens come together, it is a known issue
+               assertEquals("[inflectedform11 inflectedform2 
inflectedform122]", Arrays.toString(match.toFinalString(null)));
        }
 
        public void testPOSIncludeAll() throws Exception {
                Match match = getMatch("POS1", "POS3", Match.IncludeRange.ALL); 
                match.setToken(getAnalyzedTokenReadings("inflectedform11 
inflectedform2 inflectedform122 inflectedform122"), 1, 3);
-               assertEquals("[inflectedform123inflectedform2 
inflectedform122]", Arrays.toString(match.toFinalString(null)));
+               assertEquals("[inflectedform123 inflectedform2 
inflectedform122]", Arrays.toString(match.toFinalString(null)));
                // Note that in this case the first token has the requested POS 
(POS3 replaces POS1)
-               // the first two tokens come together, it is a known issue. 
        }
        
        // TODO ad tests for using Match.IncludeRange with {@link 
Match#staticLemma}

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


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 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_122412
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits

Reply via email to