Skip to content

Commit

Permalink
Merge pull request #878 from norm-ideal/cleanup
Browse files Browse the repository at this point in the history
Update on DoubleNagation output style
  • Loading branch information
takahi-i committed Jul 23, 2020
2 parents 81fc86b + cf5336a commit 4ea76e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public ExpressionRule addElement(TokenElement element) {
return this;
}

public String toSurface() {
String result = "";
for (int i = 0; i < elements.size(); i++)
result += elements.get(i).getSurface();
return result;
}

@Override
public String toString() {
return "ExpressionRule{" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@ public void validate(Sentence sentence) {
// validate with expressions (phrase)
for (ExpressionRule rule : invalidExpressions) {
if (rule.match(sentence.getTokens())) {
addLocalizedError(sentence, rule.toString());
addLocalizedError(sentence, rule.toSurface() );
return;
}
}

// validate with set of negative words
int count = 0;
for (String negativeWord : negativeWords) {
List<TokenElement> tokens = sentence.getTokens();
for (TokenElement token : tokens) {
if (token.getSurface().toLowerCase().equals(negativeWord)) {
count++;
}
if (count >= 2) {
addLocalizedErrorFromToken(sentence, token);
return;
}
String errorPart = "";
List<TokenElement> tokens = sentence.getTokens();
for (TokenElement token : tokens) {
if (negativeWords.contains(token.getSurface().toLowerCase())) {
count++;
errorPart += " " + token.getSurface().toLowerCase();
}
if (count >= 2) {
addLocalizedError(sentence, errorPart);
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ DoubledWordValidator=\u4E00\u6587\u306B\u4E8C\u56DE\u4EE5\u4E0A\u5229\u7528\u305
SuccessiveWordValidator=\u5358\u8A9E "{0}" \u306F\u9023\u7D9A\u3057\u3066\u4F7F\u7528\u3055\u308C\u3066\u3044\u307E\u3059\u3002
HankakuKanaValidator=\u534A\u89D2\u30AB\u30CA\u306E\u6587\u5B57 "{0}" \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F\u3002
JapaneseStyleValidator=\u4E0D\u6B63\u306A\u65E5\u672C\u8A9E\u306E\u30B9\u30BF\u30A4\u30EB\u3092\u767A\u898B\u3057\u307E\u3057\u305F "{0}"
DoubleNegativeValidator=\u4E8C\u91CD\u5426\u5B9A\u304C\u307F\u3064\u304B\u308A\u307E\u3057\u305F "{0}"
DoubleNegativeValidator=\u4E8C\u91CD\u5426\u5B9A\u304C\u307F\u3064\u304B\u308A\u307E\u3057\u305F\u3002 "{0}"
NumberFormatValidator.TooManyDecimals=\u6570\u5B57\u8868\u73FE {0} \u306B\u306F\u591A\u304F\u306E\u6570\u5B57\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059\u3002
NumberFormatValidator.UndelimitedSequenceTooLong=\u6570\u5024\u8868\u73FE {0} \u306F\u4E09\u3064\u306E\u6570\u5B57\u306B\u3064\u304D\u4E00\u3064\u306E\u30C7\u30EA\u30DF\u30BF\u5FC5\u8981\u3067\u3059\u3002
NumberFormatValidator.UndelimitedSequenceTooShort=\u6570\u5024\u8868\u73FE {0} \u306B\u304A\u3051\u308B\u30C7\u30EA\u30DF\u30BF\u306E\u4F4D\u7F6E\u304C\u4E0D\u6B63\u3067\u3059\u3002
Expand Down

0 comments on commit 4ea76e6

Please sign in to comment.