gt:                     RakeNode rakeNode = (RakeNode) keyphrase.getNode();
context: package com.figueroa.nlp.rankup;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Collections;
  import java.util.Comparator;
  import java.util.HashMap;
  import java.util.List;
  
  import org.apache.log4j.Logger;
  
  import com.figueroa.nlp.rankup.GraphBasedKeywordExtractor.GraphBasedKeywordExtractionMethod;
  import com.figueroa.nlp.rankup.KeyPhraseGraph.SetLevel;
  import com.figueroa.nlp.POSTagger;
  import com.figueroa.nlp.KeyPhrase;
  import com.figueroa.nlp.Lemmatizer;
  import com.figueroa.nlp.Stopwords;
  import com.figueroa.nlp.rake.Rake;
  import com.figueroa.nlp.rake.RakeNode;
  import com.figueroa.nlp.rake.RakeNode.RakeNodeType;
  import com.figueroa.util.Abstract;
  import com.figueroa.util.AbstractManager;
  
  /**
   * RankUp is an unsupervised approach for keyphrase extraction
   * from short articles based on back propagation.
   *
   * @author Gerardo Figueroa
   * Institute of Information Systems and Applications
   * National Tsing Hua University
   * Hsinchu, Taiwan
   * May 2013
   */
  public class RankUp {
  
      // Logger and debugging
  	private static final Logger logger = Logger.getLogger(RankUp.class);
      private int errorCorrectorIterations;
  
      // MySQL AbstractManager and DatabaseManager
      private final AbstractManager abstractManager;
  
      // POSTagger and Lemmatizer
      private final POSTagger posTagger;
      private final Lemmatizer lemmatizer;
  
      // Stopwords
      private final Stopwords stopwords;
  
      // KeyPhrases
      private KeyPhraseGraph keyPhraseGraph;
      private List<KeyPhrase> originalKeyphraseList;
  
      // RankUp Properties
      private final RankUpProperties rankUpProperties;
  
      // Training Abstracts
      private final Collection<Abstract> trainingAbstracts;
      
      // Changes and bug fixes
      private final boolean MINMAX_MID_BUG_FIX;
      private final boolean CORRECT_NEGATIVE_WEIGHTS;
      private final boolean DENORMALIZE_MODIFICATION_VALUE;
      private final boolean USE_DIFFERENTIAL_CONVERGENCE;
      
      // RAKE
      private final Rake rake;
  
      /**
       * RankUp Constructor, initialized with all its necessary components.
       * @param abstractManager
       * @param posTagger
       * @param lemmatizer
       * @param stopwords
       * @param rake
       * @param rankUpProperties
       * @param trainingAbstracts
       * @param minMaxMidBugFix
       * @param correctNegativeWeights
       * @param denormalizeModificationValue
       * @param useDifferentialConvergence
       * @throws Exception
       */
      public RankUp(
              AbstractManager abstractManager,
              POSTagger posTagger, 
              Lemmatizer lemmatizer, 
              Stopwords stopwords,
              Rake rake,
              RankUpProperties rankUpProperties, 
              Collection<Abstract> trainingAbstracts,
              boolean minMaxMidBugFix, 
              boolean correctNegativeWeights,
              boolean denormalizeModificationValue,
              boolean useDifferentialConvergence)
              throws Exception {
  
          //this.textRank = textRank;
          this.abstractManager = abstractManager;
          this.posTagger = posTagger;
          this.lemmatizer = lemmatizer;
          this.stopwords = stopwords;
          this.rake = rake;
          this.keyPhraseGraph = null;
          this.rankUpProperties = rankUpProperties;
          this.trainingAbstracts = trainingAbstracts;
          this.MINMAX_MID_BUG_FIX = minMaxMidBugFix;
          this.CORRECT_NEGATIVE_WEIGHTS = correctNegativeWeights;
          this.DENORMALIZE_MODIFICATION_VALUE = denormalizeModificationValue;
          this.USE_DIFFERENTIAL_CONVERGENCE = useDifferentialConvergence;
      }
  
      /**
       * Set the features for all keyphrases extracted by the base keyphrase extraction
       * algorithm.
       * @param keyPhrases
       * @param abs
       * @param force
       * @throws Exception
       */
      public void setKeyPhraseFeatures(List<KeyPhrase> keyPhrases, Abstract abs, boolean force)
              throws Exception {
  
          // Check if the phrase features have been set or not
          if (!abs.phraseFeaturesSet() || force) {
              
              // First, get RAKE keywords
              HashMap<String, Double> rakeKeyphrases = null;
              if (rankUpProperties.keywordExtractionMethod == GraphBasedKeywordExtractionMethod.TEXTRANK) {
                  rakeKeyphrases = rake.runRake(abs.getOriginalText());
              }
              
              // Then, calculate individual keyphrase features
              for (KeyPhrase keyPhrase : keyPhrases) {
                  PhraseFeatures.setPhraseFeatures(
                          keyPhrase, abs, trainingAbstracts, abstractManager, posTagger,
                          lemmatizer, rakeKeyphrases);
              }
              
              abs.setPhraseFeatures();
          }
      }
  
      /**
       * Remove stop phrases and any subphrases that have lower ranks than their superphrases.
       * @param oldKeyphrases
       * @return
       * @throws Exception
       */
      private ArrayList postProcessKeyphrases(List<KeyPhrase> oldKeyphrases) throws Exception {
  
          ArrayList<KeyPhrase> newKeyphrases = new ArrayList<>();
  
          for (KeyPhrase oldKeyphrase : oldKeyphrases) {
              String originalOldKeyphrase = oldKeyphrase.text;
              String stemmedOldKeyphrase = oldKeyphrase.getFeatures() != null ?
                      oldKeyphrase.getFeatures().stemmedPhrase :
                      lemmatizer.stemText(oldKeyphrase.text, false);
              boolean hasSuperPhrase = false;
              for (KeyPhrase newKeyphrase : newKeyphrases) {
                  String originalNewKeyphrase = newKeyphrase.text;
                  String stemmedNewKeyphrase = newKeyphrase.getFeatures() != null ?
                          newKeyphrase.getFeatures().stemmedPhrase : 
                          lemmatizer.stemText(newKeyphrase.text, false);
  
                  if (originalNewKeyphrase.contains(originalOldKeyphrase) ||
                          originalNewKeyphrase.contains(stemmedOldKeyphrase) ||
                          stemmedNewKeyphrase.contains(originalOldKeyphrase) ||
                          stemmedNewKeyphrase.contains(stemmedOldKeyphrase)) {
                      hasSuperPhrase = true;
                      break;
                  }
                  // Old version
  //                if (newKeyphrase.text.contains(oldKeyphrase.text)) {
  //                    hasSuperPhrase = true;
  //                    break;
  //                }
              }
              //Remove subphrases and stop phrases
              if (!hasSuperPhrase && !stopwords.isStopPhrase(oldKeyphrase.text)) {
                  if (oldKeyphrase.getFeatures() != null) {
                      if (!stopwords.isStopPhrase(
                              oldKeyphrase.getFeatures().stemmedPhrase)) {
                          newKeyphrases.add(oldKeyphrase);
                      }
                  }
                  else {
                      newKeyphrases.add(oldKeyphrase);
                  }
              }
          }
  
          return newKeyphrases;
      }
  
      /**
       * Main RankUp algorithm.
       * @param abs
       * @param printGephiGraphs
       * @param keywordExtractor
       * @return
       */
      public List<KeyPhrase> runRankUp(
              Abstract abs,
              //boolean newMethod, 
              boolean printGephiGraphs,
              GraphBasedKeywordExtractor keywordExtractor) {
  
          try {
              // 1. Run Keyword Extractor (TextRank, RAKE, etc.) 
              // (3.1 Construct Graph and 3.2 Ranking Nodes)
              logger.info("1. Extracting " + keywordExtractor.keywordExtractionMethod + 
                      " keyphrases...");
              List<KeyPhrase> originalKeyphraseListFull = keywordExtractor.extractKeyphrases(abs);
  
              // Get Keyphrases to use in ErrorDetector and ErrorCorrector
              ArrayList<KeyPhrase> feedbackKeyphraseList;
              ArrayList<KeyPhrase> realKeyphraseList;
              // In TextRank, use all keyphrases in the graph
              if (rankUpProperties.keywordExtractionMethod == GraphBasedKeywordExtractionMethod.TEXTRANK) {
                  feedbackKeyphraseList = (ArrayList<KeyPhrase>) originalKeyphraseListFull;
                  realKeyphraseList = feedbackKeyphraseList;
              }
              // In RAKE, only use Word Nodes
              else if (rankUpProperties.keywordExtractionMethod == GraphBasedKeywordExtractionMethod.RAKE) {
                      feedbackKeyphraseList = new ArrayList<>();
                      realKeyphraseList = new ArrayList<>();
                  for (KeyPhrase keyphrase : originalKeyphraseListFull) {
  