Ejemplo n.º 1
0
def process_modified_concept(p, m, min_mod_impl, mod_concepts, new_preclosed):
    # p is of the form (extent, intent)
    for i in min_mod_impl:
        if i.premise <= p[1]:  # p[1] is no longer preclosed
            break
    else:  # p[1] becomes psuedo-closed
        impl = fca.Implication(p[1].copy(), p[1].copy())
        impl.get_conclusion().add(m)
        min_mod_impl.append(impl)
        new_preclosed.append((p[0], impl.premise, impl))
    p[1].add(m)
    mod_concepts.append(p)
Ejemplo n.º 2
0
def process_stable_concept(p, m, extent, new_stable_impl, new_preclosed,
                           closure):
    # p is of the form (extent, intent)
    new_extent = p[0] & extent
    new_premise = p[1].copy()
    new_premise.add(m)
    for i in new_stable_impl:
        if not i.is_respected(new_premise):
            break
    else:
        new_conclusion = closure(new_premise)
        if new_conclusion == new_premise:
            new_preclosed.append((new_extent, new_premise))
        else:
            impl = fca.Implication(new_premise, new_conclusion)
            new_stable_impl.append(impl)
            new_preclosed.append((new_extent, impl.premise, impl))
Ejemplo n.º 3
0
 def __iter__(self):
     for imp in self._get_implications():
         fca_imp = fca.Implication(imp.get_premise(), imp.get_conclusion())
         fca_imp.pk = imp.pk
         yield fca_imp
Ejemplo n.º 4
0
def test_unit_implication():
    imp = fca.Implication({1, 2, 3}, {4})
    uimp = fca.UnitImplication(imp.premise, imp.conclusion.pop())
    assert uimp == imp
Ejemplo n.º 5
0
 def get_as_fca_implication(self):
     return fca.Implication(
         set([attr.name for attr in self.premise.all()]),
         set([attr.name for attr in self.conclusion.all()]))