Revision: 6382
http://languagetool.svn.sourceforge.net/languagetool/?rev=6382&view=rev
Author: dominikoeo
Date: 2012-01-29 23:33:06 +0000 (Sun, 29 Jan 2012)
Log Message:
-----------
- change to detect more errors in grammar.xml when doing "ant test"
when an exception implies another one as in:
<exception>xx</exception>
<exception postag="A">xx</exception>
In above example, 1st exception implies the 2nd exception so 2nd
exception is useless.
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-01-29 22:23:46 UTC (rev 6381)
+++
trunk/JLanguageTool/src/test/org/languagetool/rules/patterns/PatternRuleTest.java
2012-01-29 23:33:06 UTC (rev 6382)
@@ -199,7 +199,11 @@
* Predicate to check whether two exceptions are identical or whether
* one exception always implies the other.
*
- * There is no reason for a token to have two identical exceptions.
+ * Example #1, useless identical exceptions:
+ * <exception>xx</exception><exception>xx</exception>
+ *
+ * Example #2, first exception implies the second exception:
+ * <exception>xx</exception><exception postag="A">xx</exception>
*/
private static boolean equalException(final Element exception1,
final Element exception2)
@@ -213,7 +217,7 @@
string1 = string1.toLowerCase();
string2 = string2.toLowerCase();
}
- if (!string1.isEmpty() || !string2.isEmpty()) {
+ if (!string1.isEmpty() && !string2.isEmpty()) {
if (!string1.equals(string2)) {
return false;
}
@@ -221,12 +225,17 @@
final String posTag1 = exception1.getPOStag() == null ? "" :
exception1.getPOStag();
final String posTag2 = exception2.getPOStag() == null ? "" :
exception2.getPOStag();
- if (!posTag1.isEmpty() || !posTag2.isEmpty()) {
+ if (!posTag1.isEmpty() && !posTag2.isEmpty()) {
if (!posTag1.equals(posTag2)) {
return false;
}
}
+ if ( string1.isEmpty() != string2.isEmpty()
+ && posTag1.isEmpty() != posTag2.isEmpty()) {
+ return false;
+ }
+
// We should not need to check for:
// - isCaseSensitive() since an exception without isCaseSensitive
// imply the one with isCaseSensitive.
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Languagetool-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-cvs