Revision: 9653
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=9653&view=rev
Author:   dnaber
Date:     2013-03-10 09:10:34 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
check marker position only in expert mode

Modified Paths:
--------------
    
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy

Modified: 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
===================================================================
--- 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
       2013-03-10 08:18:49 UTC (rev 9652)
+++ 
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
       2013-03-10 09:10:34 UTC (rev 9653)
@@ -58,7 +58,7 @@
         PatternRule patternRule = createPatternRule(language)
         List problems = []
         List shortProblems = []
-        checkExampleSentences(patternRule, language, problems, shortProblems)
+        checkExampleSentences(patternRule, language, problems, shortProblems, 
false)
         if (problems.size() == 0) {
           SearcherResult searcherResult = null
           boolean timeOut = false
@@ -114,7 +114,7 @@
         PatternRule patternRule = rules.get(0)
         List problems = []
         List shortProblems = []
-        checkExampleSentences(patternRule, language, problems, shortProblems)
+        checkExampleSentences(patternRule, language, problems, shortProblems, 
true)
         if (problems.size() > 0) {
             render(template: 'checkRuleProblem', model: [problems: problems, 
hasRegex: hasRegex(patternRule),
                     expertMode: true, isOff: patternRule.isDefaultOff()])
@@ -139,7 +139,7 @@
         }
     }
 
-    private void checkExampleSentences(PatternRule patternRule, Language 
language, List problems, List shortProblems) {
+    private void checkExampleSentences(PatternRule patternRule, Language 
language, List problems, List shortProblems, boolean checkMarker) {
         JLanguageTool langTool = getLanguageToolWithOneRule(language, 
patternRule)
         List correctExamples = patternRule.getCorrectExamples()
         if (correctExamples.size() == 0) {
@@ -158,20 +158,22 @@
             } else if (ruleMatches.size() == 1) {
                 def ruleMatch = ruleMatches.get(0)
                 def expectedReplacements = incorrectExample.corrections.sort()
-                int expectedMatchStart = 
incorrectExample.getExample().indexOf("<marker>")
-                int expectedMatchEnd = 
incorrectExample.getExample().indexOf("</marker>") - "<marker>".length()
-                if (expectedMatchStart == -1 || expectedMatchEnd == -1) {
-                    problems.add("No <marker> found in incorrect example 
sentence")
-                    break
-                }
-                if (!ruleMatch.getRule().isWithComplexPhrase()) {
-                    if (ruleMatch.getFromPos() != expectedMatchStart) {
-                        problems.add("Unexpected start position of 
<marker>...</marker> in incorrect example sentence: " + expectedMatchStart +  " 
but expected " + ruleMatch.getFromPos())
+                if (checkMarker) {
+                    int expectedMatchStart = 
incorrectExample.getExample().indexOf("<marker>")
+                    int expectedMatchEnd = 
incorrectExample.getExample().indexOf("</marker>") - "<marker>".length()
+                    if (expectedMatchStart == -1 || expectedMatchEnd == -1) {
+                        problems.add("No <marker> found in incorrect example 
sentence")
                         break
                     }
-                    if (ruleMatch.getToPos() != expectedMatchEnd) {
-                        problems.add("Unexpected end position of 
<marker>...</marker> in incorrect example sentence: " + expectedMatchEnd +  " 
but expected " + ruleMatch.getToPos())
-                        break
+                    if (!ruleMatch.getRule().isWithComplexPhrase()) {
+                        if (ruleMatch.getFromPos() != expectedMatchStart) {
+                            problems.add("Unexpected start position of 
<marker>...</marker> in incorrect example sentence: " + expectedMatchStart +  " 
but expected " + ruleMatch.getFromPos())
+                            break
+                        }
+                        if (ruleMatch.getToPos() != expectedMatchEnd) {
+                            problems.add("Unexpected end position of 
<marker>...</marker> in incorrect example sentence: " + expectedMatchEnd +  " 
but expected " + ruleMatch.getToPos())
+                            break
+                        }
                     }
                 }
                 def foundReplacements = 
ruleMatches.get(0).getSuggestedReplacements().sort()

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


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits

Reply via email to