Package org.apache.ctakes.ytex.kernel.model

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


  @Override
  public double getIC(String concept, boolean intrinsicICMap) {
    double ic = 0d;
    if (intrinsicICMap) {
      ConcRel cr = this.cg.getConceptMap().get(concept);
      if (cr != null)
        ic = cr.getIntrinsicInfoContent();
    } else {
      Double icC = null;
      if (isPreload()) {
        // we preloaded all ic - just look in the cache
        icC = this.corpusICMap.get(concept);
View Full Code Here


  // }

  public int getLCS(String concept1, String concept2, Set<String> lcses,
      List<LCSPath> lcsPaths) {
    int lcsDist = 0;
    ConcRel cr1 = getConceptGraph().getConceptMap().get(concept1);
    ConcRel cr2 = getConceptGraph().getConceptMap().get(concept2);
    if (cr1 != null && cr2 != null) {
      lcses.clear();
      if (lcsPaths == null) {
        // no need to get paths which we don't cache - look in the cache
        lcsDist = getLCSFromCache(cr1, cr2, lcses);
View Full Code Here

    if (corpusICMap == null || corpusICMap.isEmpty()) {
      log.warn("IC not found");
    }
    ImmutableMap.Builder<String, Double> mb = new ImmutableMap.Builder<String, Double>();
    for (Map.Entry<String, Double> corpusICEntry : corpusICMap.entrySet()) {
      ConcRel cr = cg.getConceptMap().get(corpusICEntry.getKey());
      if (cr != null) {
        mb.put(cr.getConceptID(), corpusICEntry.getValue());
      }
    }
    this.corpusICMap = mb.build();
    // ConceptInfo ci = this.conceptInfoCache[cr.getNodeIndex()];
    // if (ci == null) {
View Full Code Here

  public boolean isPreload() {
    return preload;
  }

  public int lcs(String concept1, String concept2, List<LCSPath> lcsPaths) {
    ConcRel cr1 = cg.getConceptMap().get(concept1);
    ConcRel cr2 = cg.getConceptMap().get(concept2);
    int dist = -1;
    if (cr1 != null && cr2 != null) {
      Set<ConcRel> crlcses = new HashSet<ConcRel>();
      Map<ConcRel, LCSPath> crpaths = new HashMap<ConcRel, LCSPath>();
      dist = ConcRel.getLeastCommonConcept(cr1, cr2, crlcses, crpaths);
View Full Code Here

    }
    // ignore self relations
    if (!childCUI.equals(parentCUI)) {
      boolean parNull = false;
      // get parent from cui map
      ConcRel crPar = cg.getConceptMap().get(parentCUI);
      if (crPar == null) {
        parNull = true;
        // parent not in cui map - add it
        crPar = cg.addConcept(parentCUI);
        // this is a candidate root - add it to the set of roots
        roots.add(parentCUI);
      }
      // get the child cui
      ConcRel crChild = cg.getConceptMap().get(childCUI);
      // crPar already has crChild, return
      if (crChild != null && crPar.getChildren().contains(crChild))
        return;
      // avoid cycles - don't add child cui if it is an ancestor
      // of the parent. if the child is not yet in the map, then it can't
      // possibly induce a cycle.
      // if the parent is not yet in the map, it can't induce a cycle
      // else check for cycles
      // @TODO: this is very inefficient. implement feedback arc algo
      boolean bCycle = !parNull && crChild != null && checkCycle
          && checkCycle(crPar, crChild);
      if (bCycle) {
        log.warn("skipping relation that induces cycle: par="
            + parentCUI + ", child=" + childCUI);
      } else {
        if (crChild == null) {
          // child not in cui map - add it
          crChild = cg.addConcept(childCUI);
        } else {
          // remove the cui from the list of candidate roots
          if (roots.contains(childCUI))
            roots.remove(childCUI);
        }
        // link child to parent and vice-versa
        crPar.getChildren().add(crChild);
        crChild.getParents().add(crPar);
      }
    }
  }
View Full Code Here

        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
View Full Code Here

TOP

Related Classes of org.apache.ctakes.ytex.kernel.model.ConcRel

Copyright © 2018 www.massapicom. 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.