/**
   * 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;
  }