/**
  * calculate the score which is the worst score of the derived word scores
  *
  * @param list input
  * @return calculated score
  */
 public int getOutputScore(List<AnalysisOutput> list) {
   int score = 100;
   for (AnalysisOutput o : list) {
     score = Math.min(score, o.getScore());
   }
   return score;
 }
  /**
   * when the fragment can be analyzed as a verb, check whether if noun is included in the fragment.
   * prevent from being divided such as "전복사고==>전^복사고"
   *
   * @param candidate all candidate list
   * @param dividedOutput this analysis output
   * @return check result
   */
  private boolean includeNoun(WordListCandidate candidate, AnalysisOutput dividedOutput, int pos) {

    if (candidate.getWordList().size() > 1) {
      AnalysisOutput nextOutput = candidate.getWordList().get(1).get(0);
      if (nextOutput.getSource().length() > 1
          && nextOutput.getPatn() == PatternConstants.PTN_N
          && nextOutput.getScore() == AnalysisOutput.SCORE_CORRECT) return true;
    }

    return false;
  }
  /**
   * @param candiateList all candidate list
   * @param dividedOutput the dividing analysis output
   */
  private void removeInvalidCandidate(
      List<WordListCandidate> candiateList, AnalysisOutput dividedOutput) {

    List<WordListCandidate> removes = new ArrayList<WordListCandidate>();
    for (int i = 0; i < candiateList.size(); i++) {

      WordListCandidate candidate = candiateList.get(i);
      AnalysisOutput output = candidate.getWordList().get(0).get(0);

      if (!output.getSource().equals(dividedOutput.getSource())
          && !includeNoun(candidate, dividedOutput, i)) removes.add(candidate);
    }

    candiateList.removeAll(removes);
  }
  /**
   * return the start position of the longest valid noun before the start position
   *
   * @param output analysis output
   * @param start start position
   * @param inputText input text
   * @param isLast whether if this is the last word.
   * @return the start position of the longest valid noun
   */
  private int validWord(AnalysisOutput output, int start, String inputText, boolean isLast) {

    int newStart = -1;
    if (output.getScore() != AnalysisOutput.SCORE_CORRECT
        || start == 0
        || output.getSource().length() < 2) return newStart;

    if (!isLast && output.getJosa() == null && output.getEomi() == null) return newStart;

    if (output.getScore() == AnalysisOutput.SCORE_CORRECT) newStart = start;

    // the word with greater than 6 length doesn't exist
    int minPos = start - 6;
    if (minPos < 0) minPos = 0;

    for (int i = start - 1; i >= minPos; i--) {
      String word = inputText.substring(i, start) + output.getStem();
      if (DictionaryUtil.getWord(word) != null) {
        newStart = i;
      }
    }

    return newStart;
  }