コード例 #1
0
  public DynamicPathTree constructCategoryTree(SortedMap<Integer, Double> categoryDistribution)
      throws WikitException {
    DynamicPathTree tree = new DynamicPathTree(conf);
    for (Map.Entry<Integer, Double> score : categoryDistribution.entrySet()) {
      tree.addLeafNode(score.getKey(), score.getValue());
    }

    return tree;
  }
コード例 #2
0
  public List<SemanticPath> getSemanticPaths(DynamicPathTree categoryTree, int topN)
      throws WikitException {
    List<SemanticPath> paths = null;
    //        paths = categoryTree.getSemanticPaths();
    paths = categoryTree.getFilteredSemanticPaths();
    List<SemanticPath> results = new ArrayList<>();

    //        int count = 0;
    //        for (int i = paths.size() - 1; i >= 0; i--) {
    //            results.add(paths.get(i));
    //            if (++count >= 200) break;
    //        }

    GreedyMWIS greedyMWIS = new GreedyMWIS(treeCache);
    greedyMWIS.buildMWISGraph(paths);
    for (int i = 0; i < topN; i++) {
      SemanticPath topPath = greedyMWIS.findTopNode();
      if (topPath != null) {
        results.add(topPath);
      } else {
        break;
      }
    }
    return results;
  }
コード例 #3
0
 public CategoryDistribution getLevelOneDistribution(DynamicPathTree tree) throws WikitException {
   return tree.getLevelDistribution();
 }