/**
 * redpen: a text inspection tool
 * Copyright (c) 2014-2015 Recruit Technologies Co., Ltd. and contributors
 * (see CONTRIBUTORS.md)
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cc.redpen.validator.document;

import cc.redpen.model.Sentence;
import cc.redpen.tokenizer.TokenElement;
import cc.redpen.validator.Validator;

import java.util.*;

import static java.util.Collections.singletonList;

public class JapaneseExpressionVariationValidator extends Validator {
    private Map<String, List<TokenElement>> words = new HashMap<>();

    @Override
    public void validate(Sentence sentence) {
        for (TokenElement token : sentence.getTokens()) {
            String reading = token.getTags().get(7);
            if (this.words.containsKey(reading)) {
                List<TokenElement> tokens = this.words.get(reading);
                for (TokenElement candidate : tokens) {
                    if (candidate != token && !token.getSurface().equals(candidate.getSurface())) {
                        addLocalizedErrorFromToken(sentence, token);
                    }
                }
            }
        }
    }

    @Override
    public void preValidate(Sentence sentence) {
        for (TokenElement token : sentence.getTokens()) {
            String reading = token.getTags().get(7);
            if (!this.words.containsKey(reading)) {
                this.words.put(reading, new LinkedList<TokenElement>());
            }
            this.words.get(reading).add(token);

        }
    }

    @Override
    public List<String> getSupportedLanguages() {
        return singletonList(Locale.JAPANESE.getLanguage());
    }
}

@@ -763,24 +763,17 @@
 n.model.
-Sentence
+*
 ;%0Aimport
@@ -1062,69 +1062,384 @@
 ();%0A
-%0A    @Override%0A    public void validate(Sentence sentence) %7B%0A
+    private Map%3CDocument, List%3CSentence%3E%3E sentenceMap = new HashMap%3C%3E();%0A%0A    @Override%0A    public void validate(Document document) %7B%0A        if (!sentenceMap.containsKey(document)) %7B%0A            throw new IllegalStateException(%22Document %22 + document.getFileName() + %22 does not have any sentence%22);%0A        %7D%0A%0A        for (Sentence sentence : sentenceMap.get(document)) %7B%0A    
     
@@ -1496,32 +1496,36 @@
 ) %7B%0A            
+    
 String reading =
@@ -1557,24 +1557,28 @@
             
+ 
+   
 if (this.wor
@@ -1620,16 +1620,20 @@
         
+   
+ 
 List%3CTok
@@ -1685,32 +1685,36 @@
                 
+    
 for (TokenElemen
@@ -1753,24 +1753,28 @@
             
+ 
+   
 if (candidat
@@ -1865,16 +1865,20 @@
         
+    
 addLocal
@@ -1914,16 +1914,42 @@
 token);%0A
+                        %7D%0A
         
@@ -2003,32 +2003,33 @@
        %7D%0A    %7D%0A%0A
+%0A
     @Override%0A  
@@ -2058,29 +2058,204 @@
 ate(
-Sentence sentence) %7B%0A
+Document document) %7B%0A        sentenceMap.put(document, extractSentences(document));%0A        List%3CSentence%3E sentences = sentenceMap.get(document);%0A        for (Sentence sentence : sentences) %7B%0A    
     
@@ -2312,32 +2312,36 @@
 ) %7B%0A            
+    
 String reading =
@@ -2373,24 +2373,28 @@
             
+   
+ 
 if (!this.wo
@@ -2413,32 +2413,36 @@
 Key(reading)) %7B%0A
+    
                 
@@ -2502,34 +2502,42 @@
 ));%0A            
+ 
-%7D%0A
+   %7D%0A    
             this
@@ -2568,26 +2568,685 @@
 token);%0A
-%0A        %7D
+            %7D%0A        %7D%0A    %7D%0A%0A    private List%3CSentence%3E extractSentences(Document document) %7B%0A        List%3CSentence%3E sentences = new ArrayList%3C%3E();%0A        for (Section section : document) %7B%0A            for (Paragraph paragraph : section.getParagraphs()) %7B%0A                sentences.addAll(paragraph.getSentences());%0A            %7D%0A            sentences.addAll(section.getHeaderContents());%0A            for (ListBlock listBlock : section.getListBlocks()) %7B%0A                for (ListElement listElement : listBlock.getListElements()) %7B%0A                    sentences.addAll(listElement.getSentences());%0A                %7D%0A            %7D%0A        %7D%0A        return sentences;
 %0A    %7D%0A%0A

Make parameter of validate Document object