コード例 #1
0
 @Override
 protected void setupEntities(Entities e) throws SQLException {
   inlinkImportance = new TIntDoubleHashMap();
   TIntObjectHashMap<int[]> neighbors = DataAccess.getInlinkNeighbors(e);
   double collectionSize = (double) DataAccess.getCollectionSize();
   for (int eId : e.getUniqueIds()) {
     double importance = (double) neighbors.get(eId).length / (double) collectionSize;
     inlinkImportance.put(eId, importance);
   }
 }
コード例 #2
0
 public static TIntObjectHashMap<String> getAllWordIds() {
   TObjectIntHashMap<String> wordIds = DataAccess.getAllWordIds();
   TIntObjectHashMap<String> idWords = new TIntObjectHashMap<String>(wordIds.size());
   for (TObjectIntIterator<String> itr = wordIds.iterator(); itr.hasNext(); ) {
     itr.advance();
     idWords.put(itr.value(), itr.key());
   }
   return idWords;
 }
コード例 #3
0
  private TIntHashSet getIntersection(TIntHashSet contextA, TIntHashSet contextB) {
    TIntHashSet is = new TIntHashSet();

    for (int a : contextA.toArray()) {
      if (contextB.contains(a) || contextB.contains(DataAccess.expandTerm(a))) {
        is.add(a);
      }
    }

    return is;
  }
コード例 #4
0
  private TIntHashSet getUnion(TIntHashSet contextA, TIntHashSet contextB) {
    TIntHashSet union = new TIntHashSet();

    for (int a : contextB.toArray()) {
      union.add(a);
    }

    for (int a : contextA.toArray()) {
      if (!union.contains(a) && !union.contains(DataAccess.expandTerm(a))) {
        union.add(a);
      }
    }

    return union;
  }
コード例 #5
0
  @Override
  public String getOutput() {
    Collections.sort(keyphrases);

    TIntLinkedList wordIds = new TIntLinkedList();
    for (keyphraseTracingObject kto : keyphrases) {
      for (int keyword : kto.keyphraseTokens) {
        wordIds.add(keyword);
      }
    }
    TIntObjectHashMap<String> id2word = DataAccess.getWordsForIds(wordIds.toArray());

    StringBuilder sb = new StringBuilder();
    sb.append(
        "<strong style='color: #0000FF;'> score = " + formatter.format(score) + " </strong><br />");
    int keyphraseCount = 0;
    for (keyphraseTracingObject keyphrase : keyphrases) {
      if (keyphraseCount == 5) {
        countForUI++;
        sb.append(
            "<a onclick=\"setVisibility('div"
                + countForUI
                + "', 'block');\">More ...</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a onclick=\"setVisibility('div"
                + countForUI
                + "', 'none');\">Less ...</a>");
        sb.append("<div id='div" + countForUI + "' style='display:none'>");
      }
      sb.append(
          "<span style='color: #005500;'>"
              + formatter.format(keyphrase.score)
              + "</span> - <span>\"");
      sb.append(
          buildKeyhraseHTMLEntry(keyphrase.keyphraseTokens, keyphrase.matchedKeywords, id2word));
      sb.append("\" </span> ");
      sb.append("<br />");
      keyphraseCount++;
    }
    if (keyphraseCount >= 5) {
      sb.append("</div>");
    }
    return sb.toString();
  }
コード例 #6
0
ファイル: StopWord.java プロジェクト: codepie/aida
 private void load() {
   File f = new File(pathStopWords);
   if (f.exists()) {
     try {
       BufferedReader reader = FileUtils.getBufferedUTF8Reader(f);
       String word = reader.readLine().trim();
       while (word != null) {
         words.add(word.trim());
         word = reader.readLine();
       }
       reader.close();
     } catch (Exception e) {
       logger.error(e.getLocalizedMessage());
     }
   } else {
     logger.error("Path does not exists " + pathStopWords);
   }
   f = new File(pathSymbols);
   if (f.exists()) {
     try {
       BufferedReader reader = FileUtils.getBufferedUTF8Reader(f);
       String word = reader.readLine().trim();
       while (word != null) {
         words.add(word.trim());
         symbols.add(word.charAt(0));
         word = reader.readLine();
       }
       reader.close();
     } catch (Exception e) {
       logger.error(e.getLocalizedMessage());
     }
   } else {
     logger.error("Path does not exists " + pathSymbols);
   }
   wordIds = new TIntHashSet(DataAccess.getIdsForWords(words).values());
 }