Revision: 6813
          
http://languagetool.svn.sourceforge.net/languagetool/?rev=6813&view=rev
Author:   gulp21-1
Date:     2012-04-29 08:50:33 +0000 (Sun, 29 Apr 2012)
Log Message:
-----------
added test for overlapping rules - commented out for now

Modified Paths:
--------------
    
trunk/JLanguageTool/src/test/org/languagetool/rules/patterns/PatternRuleTest.java

Modified: 
trunk/JLanguageTool/src/test/org/languagetool/rules/patterns/PatternRuleTest.java
===================================================================
--- 
trunk/JLanguageTool/src/test/org/languagetool/rules/patterns/PatternRuleTest.java
   2012-04-28 09:42:18 UTC (rev 6812)
+++ 
trunk/JLanguageTool/src/test/org/languagetool/rules/patterns/PatternRuleTest.java
   2012-04-29 08:50:33 UTC (rev 6813)
@@ -86,7 +86,7 @@
     final HashMap<String, PatternRule> complexRules = new HashMap<String, 
PatternRule>();
     for (final PatternRule rule : rules) {
       testCorrectSentences(languageTool, allRulesLanguageTool, lang, rule);
-      testBadSentences(languageTool, lang, complexRules, rule);
+      testBadSentences(languageTool, allRulesLanguageTool, lang, complexRules, 
rule);
     }
     if (!complexRules.isEmpty()) {
       final Set<String> set = complexRules.keySet();
@@ -345,7 +345,7 @@
     }
   }
 
-  private void testBadSentences(JLanguageTool languageTool, Language lang,
+  private void testBadSentences(JLanguageTool languageTool, JLanguageTool 
allRulesLanguageTool, Language lang,
                                 HashMap<String, PatternRule> complexRules, 
PatternRule rule) throws IOException {
     final List<IncorrectExample> badSentences = rule.getIncorrectExamples();
       for (IncorrectExample origBadExample : badSentences) {
@@ -425,9 +425,30 @@
             assertSuggestionsDoNotCreateErrors(languageTool, rule, 
badSentence, matches);
           }
         }
+        
+        // check for overlapping rules
+        /*matches = getMatches(rule, badSentence, languageTool);
+        final List<RuleMatch> matchesAllRules = 
allRulesLanguageTool.check(badSentence);
+        for (RuleMatch match : matchesAllRules) {
+          if (!match.getRule().getId().equals(rule.getId()) && matches.length 
!= 0
+              && rangeIsOverlapping(matches[0].getFromPos(), 
matches[0].getToPos(), match.getFromPos(), match.getToPos()))
+            System.err.println("WARN: " + lang.getShortName() + ": '" + 
badSentence + "' in " 
+                    + rule.getId() + " also matched " + 
match.getRule().getId());
+        }*/
 
       }
   }
+  
+  /**
+   * returns true if [a, b] has at least one number in common with [x, y]
+   */
+  private boolean rangeIsOverlapping(int a, int b, int x, int y) {
+    if (a < x) {
+      return x <= b ? true : false;
+    } else {
+      return a <= y ? true : false;
+    }
+  }
 
   private void assertSuggestions(List<String> suggestedCorrections, Language 
lang, RuleMatch[] matches, Rule rule) {
     if (suggestedCorrections != null && suggestedCorrections.size() > 0) {

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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs

Reply via email to