Revision: 9256
http://languagetool.svn.sourceforge.net/languagetool/?rev=9256&view=rev
Author: dnaber
Date: 2013-01-28 22:14:19 +0000 (Mon, 28 Jan 2013)
Log Message:
-----------
small code cleanup
Modified Paths:
--------------
trunk/languagetool/languagetool-core/src/main/java/org/languagetool/rules/LongSentenceRule.java
Modified:
trunk/languagetool/languagetool-core/src/main/java/org/languagetool/rules/LongSentenceRule.java
===================================================================
---
trunk/languagetool/languagetool-core/src/main/java/org/languagetool/rules/LongSentenceRule.java
2013-01-28 22:09:41 UTC (rev 9255)
+++
trunk/languagetool/languagetool-core/src/main/java/org/languagetool/rules/LongSentenceRule.java
2013-01-28 22:14:19 UTC (rev 9256)
@@ -28,6 +28,8 @@
public class LongSentenceRule extends Rule {
+ private static final int MAX_WORDS = 40;
+
public LongSentenceRule(final ResourceBundle messages) {
super(messages);
super.setCategory(new Category(messages.getString("category_misc")));
@@ -36,7 +38,7 @@
@Override
public String getDescription() {
- return "Readability: sentence over 40 words";
+ return "Readability: sentence over " + MAX_WORDS + " words";
}
@Override
@@ -51,19 +53,19 @@
final String msg = "Sentence is over 40 words long, consider revising.";
int numWords = 0;
int pos = 0;
- if (tokens.length < 41) { // just a short-circuit
+ if (tokens.length < MAX_WORDS + 1) { // just a short-circuit
return toRuleMatchArray(ruleMatches);
} else {
- for (int i=0;i<tokens.length;i++) {
- String token = tokens[i].getToken();
+ for (AnalyzedTokenReadings aToken : tokens) {
+ final String token = aToken.getToken();
pos += token.length(); // won't match the whole offending sentence,
but much of it
- if (!token.matches("[!-~]") && !tokens[i].isSentStart()) {
+ if (!token.matches("[!-~]") && !aToken.isSentStart()) {
numWords++;
}
}
}
- if (numWords > 40) {
- RuleMatch ruleMatch = new RuleMatch(this,0,pos,msg);
+ if (numWords > MAX_WORDS) {
+ final RuleMatch ruleMatch = new RuleMatch(this, 0, pos, msg);
ruleMatches.add(ruleMatch);
}
return toRuleMatchArray(ruleMatches);
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. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits