Пример #1
0
 /**
  * @param v The synsets
  * @param t The Topic
  * @return The number of words in the synset also found in the topic
  */
 public static int checkAmbig(Vector<Synset> v, Topic t) {
   int count = 0;
   boolean result = false;
   if (v == null) return count;
   for (Synset set : v) {
     Word[] w = set.getWords();
     for (Word word : w) {
       String rec = word.getLemma();
       String toLookup = WNLookup.getStaticStem(rec);
       result = t.containsKey(toLookup);
       if (result || t.containsKey(rec)) {
         count++;
         Log.logger.debug(
             "[found a related word on my mind: '"
                 + toLookup
                 + "', recent count for this topic '"
                 + t.getName()
                 + "' is: "
                 + count
                 + "]");
       }
     }
   }
   return count;
 }
Пример #2
0
 /**
  * Check how good a given Vector of words matches a given topic by counting how many of the words
  * in the vector are keywords for the given topic.
  *
  * @param v The Vector of words to check for applicability to the topic
  * @param t The topic to check for applicability on the words
  * @param isWordNetEnabled If true words are stemmed
  * @return Returns a score, the number of words in the Vector that are keywords for the topic
  * @throws JWNLException If sometinhg goes wrong during the WordNet-lookup
  */
 public static int checkSimple(Vector<String> v, Topic t, boolean isWordNetEnabled) {
   int count = 0;
   boolean result = false;
   if (v == null) return count;
   for (String rec : v) {
     String toLookup = rec;
     if (isWordNetEnabled) {
       toLookup = WNLookup.getStaticStem(rec);
     }
     result = t.containsKey(toLookup);
     if (result || t.containsKey(rec)) {
       count++;
       Log.logger.debug(
           "[found a related word on my mind: '"
               + toLookup
               + "', recent count for this topic '"
               + t.getName()
               + "' is: "
               + count
               + "]");
     }
   }
   return count;
 }