Examples of ConceptGraph


Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

  @Override
  public void exportSubtree(String conceptID, Properties props)
      throws IOException {
    Set<String> nodes = new HashSet<String>();
    ConceptGraph cg = this.conceptDao.getConceptGraph(props
        .getProperty("org.apache.ctakes.ytex.conceptGraphName"));
    ConcRel cr = cg.getConceptMap().get(conceptID);
    if (cr != null) {
      addSubtree(nodes, cr);
    }
    BufferedWriter w = null;
    try {
View Full Code Here

Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

    if (!(params.getCorpusName() != null
        && params.getConceptGraphName() != null
        && params.getLabelQuery() != null && params
        .getClassFeatureQuery() != null))
      return false;
    ConceptGraph cg = conceptDao.getConceptGraph(params
        .getConceptGraphName());
    InstanceData instanceData = kernelUtil.loadInstances(params
        .getLabelQuery());
    for (String label : instanceData.getLabelToInstanceMap().keySet()) {
      evaluateCorpusLabel(params, cg, instanceData, label);
View Full Code Here

Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

      ytexProps.putAll(System.getProperties());
      ConceptDao conceptDao = KernelContextHolder.getApplicationContext()
          .getBean(ConceptDao.class);
      PageRankService pageRankService = KernelContextHolder
          .getApplicationContext().getBean(PageRankService.class);
      ConceptGraph cg = conceptDao.getConceptGraph(ytexProps
          .getProperty("org.apache.ctakes.ytex.conceptGraphName"));
      if (line.hasOption("sim")) {
        String cs = line.getOptionValue("sim");
        String concept[] = cs.split(",");
        System.out.println(pageRankService.sim(concept[0], concept[1],
View Full Code Here

Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

   */
  @Override
  public void evaluateCorpusInfoContent(final String freqQuery,
      final String corpusName, final String conceptGraphName,
      final String conceptSetName) {
    ConceptGraph cg = conceptDao.getConceptGraph(conceptGraphName);
    classifierEvaluationDao.deleteFeatureEvaluation(corpusName,
        conceptSetName, null, INFOCONTENT, 0, 0d, conceptGraphName);
    FeatureEvaluation eval = new FeatureEvaluation();
    eval.setCorpusName(corpusName);
    if (conceptSetName != null)
      eval.setFeatureSetName(conceptSetName);
    eval.setEvaluationType(INFOCONTENT);
    eval.setParam2(conceptGraphName);
    // CorpusEvaluation eval = corpusDao.getCorpus(corpusName,
    // conceptGraphName, conceptSetName);
    // if (eval == null) {
    // eval = new CorpusEvaluation();
    // eval.setConceptGraphName(conceptGraphName);
    // eval.setConceptSetName(conceptSetName);
    // eval.setCorpusName(corpusName);
    // this.corpusDao.addCorpus(eval);
    // }
    Map<String, Double> rawFreq = getFrequencies(freqQuery);
    double totalFreq = 0d;
    // map of cui to cumulative frequency
    Map<String, Double> conceptFreq = new HashMap<String, Double>(cg
        .getConceptMap().size());
    // recurse through the tree
    totalFreq = getFrequency(cg.getConceptMap().get(cg.getRoot()),
        conceptFreq, rawFreq);
    List<FeatureRank> featureRankList = new ArrayList<FeatureRank>(
        conceptFreq.size());
    // update information content
    double log2inv = -1d / Math.log(2);
View Full Code Here

Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

    jdbcTemplate
        .execute("insert into test_concepts values ('bacteria', 'e coli')");
    conceptDao.createConceptGraph(null, "test",
        "select child, parent from test_concepts", true,
        Collections.EMPTY_SET);
    ConceptGraph cg = conceptDao.getConceptGraph("test");
    Assert.assertNotNull(cg);
    ((ConfigurableApplicationContext) appCtx).close();
  }
View Full Code Here

Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

  public void evaluateIntrinsicInfoContent(final Properties props)
      throws IOException {
    String conceptGraphName = props.getProperty("org.apache.ctakes.ytex.conceptGraphName");
    String conceptGraphDir = props.getProperty("org.apache.ctakes.ytex.conceptGraphDir",
        System.getProperty("java.io.tmpdir"));
    ConceptGraph cg = this.conceptDao.getConceptGraph(conceptGraphName);
    evaluateIntrinsicInfoContent(conceptGraphName, conceptGraphDir, cg);
  }
View Full Code Here

Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

        .execute("insert into test_concepts values ('bacteria', 'e coli')");
    System.out.println("Create concept graph");
    conceptDao.createConceptGraph(null, "test",
        "select child, parent from test_concepts", true,
        Collections.EMPTY_SET);
    ConceptGraph cg = conceptDao.getConceptGraph("test");
    Assert.notNull(cg);
    ((ConfigurableApplicationContext) appCtx).close();
  }
View Full Code Here

Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

   */
  @Override
  public void createConceptGraph(String dir, String name, String query,
      final boolean checkCycle, final Set<String> forbiddenConcepts)
      throws IOException {
    ConceptGraph conceptGraph = this.readConceptGraph(name);
    if (conceptGraph != null) {
      if (log.isWarnEnabled())
        log.warn("createConceptGraph(): concept graph already exists, will not create a new one.  Delete existing concept graph if you want to recreate it.");
    } else {
      String outputDir = dir;
      if (Strings.isNullOrEmpty(outputDir)) {
        outputDir = getDefaultConceptGraphDir();
      }
      if (Strings.isNullOrEmpty(outputDir)) {
        throw new IllegalArgumentException(
            "could not determine default concept graph directory; please set property org.apache.ctakes.ytex.conceptGraphDir");
      }
      if (log.isInfoEnabled())
        log.info("createConceptGraph(): file not found, creating concept graph from database.");
      final ConceptGraph cg = new ConceptGraph();
      final Set<String> roots = new HashSet<String>();
      this.jdbcTemplate.query(query, new RowCallbackHandler() {
        int nRowsProcessed = 0;

        @Override
        public void processRow(ResultSet rs) throws SQLException {
          String child = rs.getString(1);
          String parent = rs.getString(2);
          addRelation(cg, roots, child, parent, checkCycle,
              forbiddenConcepts);
          nRowsProcessed++;
          if (nRowsProcessed % 10000 == 0) {
            log.info("processed " + nRowsProcessed + " edges");
          }
        }
      });
      // set the root
      // if there is only one potential root, use it
      // else use a synthetic root and add all the roots as its children
      String rootId = null;
      if (log.isDebugEnabled())
        log.debug("roots: " + roots);
      if (roots.size() == 1) {
        rootId = roots.iterator().next();
      } else {
        rootId = System
            .getProperty("org.apache.ctakes.ytex.defaultRootId",
                DEFAULT_ROOT_ID);
        ConcRel crRoot = cg.addConcept(rootId);
        for (String crChildId : roots) {
          ConcRel crChild = cg.getConceptMap().get(crChildId);
          crRoot.getChildren().add(crChild);
          crChild.getParents().add(crRoot);
        }
      }
      cg.setRoot(rootId);
      // can't get the maximum depth unless we're sure there are no
      // cycles
      if (checkCycle) {
        log.info("computing intrinsic info for concept graph: " + name);
        this.intrinsicInfoContentEvaluator
View Full Code Here

Examples of org.apache.ctakes.ytex.kernel.model.ConceptGraph

   * @see
   * org.apache.ctakes.ytex.kernel.dao.ConceptDao#getConceptGraph(java.util
   * .Set)
   */
  public ConceptGraph getConceptGraph(String name) {
    ConceptGraph cg = this.readConceptGraph(name);
    if (cg != null) {
      this.initializeConceptGraph(cg);
      if (log.isInfoEnabled()) {
        log.info(String.format("concept graph %s, vertices: %s", name,
            cg.getConceptList().size()));
      }
    }
    return cg;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.