コード例 #1
0
ファイル: ParseEssay.java プロジェクト: hogueyy/essayx
  /**
   * overhaulSentence is the main method of this class, that will search all words, and attempt to
   * swap the words that have a part of speech that we are swapping.
   *
   * @param sentence
   * @param partsSearching
   * @return new sentence with words replaced
   */
  public ArrayList<Word> overhaulSentence(
      ArrayList<Word> sentence, ArrayList<String> partsSearching) {
    int index = 0;
    String k;
    for (Word w : sentence) // iterate through sentence, check words, set newVals to synonyms
    {
      for (String part : partsSearching) {
        if (w.getPOS().equals(part)) {
          k = findSynonym(sentence, index);
          if (w.getNewLength() <= w.getOrigLength()) w.setNewValue(null);
        }
      }
      index++;
    }

    return sentence;
  }