Exemple #1
0
 def luup(x, y):
   if x == cl.forest_tnu or y == cl.forest_tnu: return
   assert cl.get_checklist(x) != cl.get_checklist(y)
   if in_chain(x, y0) and in_chain(y, x0):
     bar = best.get(x)
     if bar and find_in_chain(bar.cod, y, x0):
       if bar.cod == y:
         art.proclaim(proposal, art.change_relation(bar, rel.eq, "extensional"))
         luup(cl.get_parent(x), cl.get_parent(y))
       else:
         art.proclaim(proposal, art.extensional(y, x, rel.lt, "refines", "refined by"))
         luup(x, cl.get_parent(y))
     else:
       bar = best.get(y)
       if bar and find_in_chain(bar.cod, x, y0):
         if bar.cod == y:
           art.proclaim(proposal, bar)
           luup(cl.get_parent(x), cl.get_parent(y))
         else:
           art.proclaim(proposal, art.extensional(x, y, rel.lt, "refines*", "refined by*"))
           luup(cl.get_parent(x), y)
       else:
         # neither x nor y matches by name
         art.proclaim(proposal, art.extensional(x, y, rel.eq, "similar="))
         luup(cl.get_parent(x), cl.get_parent(y))
Exemple #2
0
 def luup(x, y):
   if x == cl.forest_tnu or y == cl.forest_tnu: return
   assert cl.get_checklist(x) != cl.get_checklist(y)
   if in_chain(x, y0) and in_chain(y, x0):
     bar = best.get(x)
     if bar and find_in_chain(bar.cod, y, x0):
       if bar.cod == y:
         art.proclaim(draft, art.change_relation(bar, rel.eq, "extensional"))
         luup(cl.get_parent(x), cl.get_parent(y))
       else:
         art.proclaim(draft, art.extensional(y, x, rel.lt, "presumed 0"))
         luup(x, cl.get_parent(y))
     else:
       bar = best.get(y)
       if bar and find_in_chain(bar.cod, x, y0):
         if bar.cod == y:
           art.proclaim(draft, bar)
           luup(cl.get_parent(x), cl.get_parent(y))
         else:
           art.proclaim(draft, art.extensional(x, y, rel.lt, "presumed 1"))
           luup(cl.get_parent(x), y)
       else:
         # neither x nor y matches by name
         art.proclaim(draft, art.extensional(x, y, rel.eq, "presumed mutual"))
         luup(cl.get_parent(x), cl.get_parent(y))
Exemple #3
0
def is_match(ar):
    c1 = cl.get_checklist(ar.dom)
    c2 = cl.get_checklist(ar.cod)
    if c1 == c2:
        print("%s and %s both in %s" %
              (cl.get_name(c1), c2.get_name(c2), c1.prefix))
        return False
    return True
Exemple #4
0
def is_informative(syn):
    name = cl.get_value(syn, canonical_name)
    nodes = cl.get_nodes_with_value(cl.get_checklist(syn), canonical_name,
                                    name)
    if len(nodes) > 1:
        # deal with tangle around Saimiri boliviensis and subspecies
        return False
    #if cl.is_accepted(nodes[0]):
    #  return False
    return True
Exemple #5
0
 def subinfer_partners(x, other):
   y = None
   for child in cl.get_children(x):
     child_ar = subinfer_partners(child, other) # an articulation
     if child_ar != None:
       child_y = child_ar.cod
       if y == None:
         y = child_y
       else:
         y = cl.mrca(y, child_y)
   if y != None:
     ar = art.extensional(x, y, rel.matches, "cross-mrca")
   else:
     ar = get_mutual(best, x)
   if ar:
     assert cl.get_checklist(ar.cod) != cl.get_checklist(x)
     if dribble.watch(x):
       dribble.log("# Cross-mrca: %s" % (art.express(ar)))
     xmrcas[x] = ar
   return ar             # in B
Exemple #6
0
def analyze_cross_mrcas(A, B, tipwards):
  cross_mrcas = {}
  def half_analyze_cross_mrcas(checklist, other):
    def subanalyze_cross_mrcas(node, other):
      result = None
      probe = tipwards.get(node)
      if probe:
        # Could be: = < or >
        result = probe.cod
      else:
        children = cl.get_children(node)
        if children:
          m = None      # None is the identity for mrca
          for child in children:
            m2 = subanalyze_cross_mrcas(child, other)
            if m2 != None:
              m = cl.mrca(m, m2) if m != None else m2
          if m != None:
            result = m
      if result:
        assert cl.get_checklist(result) != cl.get_checklist(node)
        if dribble.watch(node):
          dribble.log("# Cross-mrca(%s) = %s" %
                      (cl.get_unique(node), cl.get_unique(result)))
        cross_mrcas[node] = result
      return result             # in B
    for root in cl.get_roots(checklist):
      subanalyze_cross_mrcas(root, other)
  half_analyze_cross_mrcas(A, B)
  half_analyze_cross_mrcas(B, A)

  # Sanity check
  for node in cross_mrcas:
    cross = cross_mrcas[node]
    probe = cross_mrcas.get(cross)
    if probe:
      assert cl.get_checklist(probe) == cl.get_checklist(node)
    else:
      dribble.log("# No return cross-MRCA for %s -> %s -> ..." %\
                  (cl.get_unique(node), cl.get_unique(cross)))
  return cross_mrcas
Exemple #7
0
 def subanalyze_cross_mrcas(node, other):
   result = None
   probe = tipwards.get(node)
   if probe:
     # Could be: = < or >
     result = probe.cod
   else:
     children = cl.get_children(node)
     if children:
       m = None      # None is the identity for mrca
       for child in children:
         m2 = subanalyze_cross_mrcas(child, other)
         if m2 != None:
           m = cl.mrca(m, m2) if m != None else m2
       if m != None:
         result = m
   if result:
     assert cl.get_checklist(result) != cl.get_checklist(node)
     if dribble.watch(node):
       dribble.log("# Cross-mrca(%s) = %s" %
                   (cl.get_unique(node), cl.get_unique(result)))
     cross_mrcas[node] = result
   return result             # in B
Exemple #8
0
def direct_matches(node, other):
    assert node > 0
    assert cl.get_checklist(node) != other
    seen = []
    arts = []
    for prop in [
            cl.ncbi_id, cl.eol_page_id, cl.scientific_name, cl.canonical_name,
            cl.gbif_id
    ]:
        val = cl.get_value(node, prop)
        if val != None:
            more = cl.get_nodes_with_value(other, prop, val)
            for hit in more:
                if hit and not hit in seen:
                    seen.append(hit)
                    arts.append(intensional(node, hit, prop.pet_name))
    return arts
Exemple #9
0
def bridge(dom, cod, re, reason, revreason=None):
    assert cl.get_checklist(dom) != cl.get_checklist(cod)
    assert reason
    return _articulation(dom, cod, re, reason=reason, revreason=revreason)