Revision: 9652
http://languagetool.svn.sourceforge.net/languagetool/?rev=9652&view=rev
Author: dnaber
Date: 2013-03-10 08:18:49 +0000 (Sun, 10 Mar 2013)
Log Message:
-----------
fix: Rule Creator does not complain about missing <marker> - sourceforge bug
#3607433
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 07:53:05 UTC (rev 9651)
+++
trunk/ltcommunity/grails-app/controllers/org/languagetool/RuleEditorController.groovy
2013-03-10 08:18:49 UTC (rev 9652)
@@ -151,19 +151,36 @@
}
for (incorrectExample in incorrectExamples) {
String sentence =
incorrectExample.getExample().replace("<marker>", "").replace("</marker>", "")
- List expectedRuleMatches = langTool.check(sentence)
- if (expectedRuleMatches.size() == 0) {
+ List ruleMatches = langTool.check(sentence)
+ if (ruleMatches.size() == 0) {
problems.add("The rule did not find the expected error in
'${sentence}'")
shortProblems.add("errorNotFound")
- } else if (expectedRuleMatches.size() == 1) {
+ } else if (ruleMatches.size() == 1) {
+ def ruleMatch = ruleMatches.get(0)
def expectedReplacements = incorrectExample.corrections.sort()
- def foundReplacements =
expectedRuleMatches.get(0).getSuggestedReplacements().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())
+ 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()
if (expectedReplacements.size() > 0 && expectedReplacements !=
foundReplacements) {
problems.add("Found wrong correction(s) in '${sentence}:
'${foundReplacements}' but expected '${expectedReplacements}'")
shortProblems.add("wrongCorrection")
}
} else {
- log.warn("Got ${expectedRuleMatches.size()} matches, expected
zero or one: ${incorrectExample}")
+ log.warn("Got ${ruleMatches.size()} matches, expected zero or
one: ${incorrectExample}")
}
}
for (correctExample in correctExamples) {
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