class SentenceSource implements Iterator<Sentence> {

  static final int MIN_SENTENCE_LENGTH = 10;
  static final int MIN_SENTENCE_TOKEN_COUNT = 4;
  static final int MAX_SENTENCE_LENGTH = 300;

  private final Tokenizer wordTokenizer;
  private final Pattern acceptPattern;
  
  private int ignoreCount = 0;

  SentenceSource(Language language) {
    this(language, null);
  }

  /** @since 3.0 */
  SentenceSource(Language language, Pattern acceptPattern) {
    wordTokenizer = language.getWordTokenizer();
    this.acceptPattern = acceptPattern;
  }

  @Override
  public abstract boolean hasNext();

  /**
   * Return the next sentence. Sentences from the source are filtered by length
   * to remove very short and very long sentences.
   */
  @Override
  public abstract Sentence next();

  public abstract String getSource();

  @Override
  public void remove() {
    throw new UnsupportedOperationException("remove not supported");
  }

  @Override
  public String toString() {
    return getSource() + "-" + super.toString();
  }

  protected boolean acceptSentence(String sentence) {<FILL_FUNCTION_BODY>}
  
  int getIgnoredCount() {
    return ignoreCount;
  }
  
  private int countTokens(String sentence) {
    int realTokens = 0;
    List<String> allTokens = wordTokenizer.tokenize(sentence);
    for (String token : allTokens) {
      if (!token.trim().isEmpty()) {
        realTokens++;
      }
    }
    return realTokens;
  }

}

    if (acceptPattern != null) {
      if (!acceptPattern.matcher(sentence).find()) {
        // useful speedup: we don't consider sentences that cannot match anyway
        ignoreCount++;
        return false;
      }
    }
    String trimSentence = sentence.trim();
    boolean accept = trimSentence.length() >= MIN_SENTENCE_LENGTH && trimSentence.length() <= MAX_SENTENCE_LENGTH
      && countTokens(trimSentence) >= MIN_SENTENCE_TOKEN_COUNT;
    if (accept) {
      return true;
    } else {
      ignoreCount++;
      return false;
    }
  
<no_super_class>