Пример #1
0
def three_concept_graph():
    graph = gel.KnowledgeBase('bot', 'top')
    graph.add_concept(gel.Concept('C'))
    graph.add_concept(gel.Concept('C_prime'))
    graph.add_concept(gel.Concept('D'))
    graph.add_role(gel.Role('i'))
    return graph
Пример #2
0
def graph_pre_role_inclusion():
    graph = gel.KnowledgeBase('bot', 'top')
    graph.add_concept(gel.Concept('C'))
    graph.add_concept(gel.Concept('D'))

    graph.add_role(gel.Role('i'))
    graph.add_role(gel.Role('j'))
    return graph
Пример #3
0
def init_bot_graph():
    graph = gel.KnowledgeBase('bot', 'top')
    graph.add_concept(gel.Concept('C'))
    graph.add_concept(gel.IndividualConcept('a'))
    graph.add_role(gel.Role('r'))
    graph.add_axiom('a', 'C', graph.is_a.iri)
    graph.add_axiom('C', 'bot', graph.is_a.iri)
    return graph
Пример #4
0
def simple_graph():
    graph = gel.KnowledgeBase('bot', 'top')
    graph.add_concept(gel.Concept('C'))
    graph.add_concept(gel.IndividualConcept('a'))
    graph.add_role(gel.Role('r'))

    graph.add_concept(gel.ExistentialConcept('r', 'C'))
    graph.add_axiom('a', 'C', graph.is_a.iri)
    return graph
Пример #5
0
def test_graph_add_pbox_axiom():
    graph = gel.KnowledgeBase('bot', 'top')
    assert graph.pbox_axioms == {}

    graph.add_concept(gel.Concept('C'))
    graph.add_concept(gel.Concept('D'))
    graph.add_axiom('C', 'D', graph.is_a, pbox_id=0)

    expected_axiom = (
        graph.get_concept('C'),
        graph.get_concept('D'),
        graph.is_a
    )

    assert graph.pbox_axioms == {0: expected_axiom}
Пример #6
0
def get_kb(onto):
    owl_concepts = list(onto.classes())
    owl_individuals = list(onto.individuals())
    owl_roles = onto.object_properties()

    kb = gel.KnowledgeBase(owl.Nothing.iri, owl.Thing.iri)

    add_concepts(kb, owl_concepts, gel.Concept)
    add_concepts(kb, owl_individuals, gel.IndividualConcept)
    add_roles(kb, owl_roles)

    add_role_inclusions_from_roles(kb, owl_roles)
    owl_basic_concepts = [owl.Thing] + owl_concepts + owl_individuals
    add_axioms_from_concepts(kb, owl_basic_concepts)
    return kb
Пример #7
0
def graph_complete_rule_5():
    graph = gel.KnowledgeBase('bot', 'top')
    graph.add_concept(gel.Concept('C'))
    graph.add_concept(gel.Concept('D'))
    graph.add_concept(gel.Concept('C1'))
    graph.add_concept(gel.Concept('C2'))
    graph.add_axiom('C', 'C1', graph.is_a)
    graph.add_axiom('C1', 'C2', graph.is_a)

    graph.add_concept(gel.Concept('D1'))
    graph.add_axiom('D', 'D1', graph.is_a)

    graph.add_role(gel.Role('i'))
    graph.add_concept(gel.Concept('D-1'))
    graph.add_axiom('D-1', 'D', 'i')

    graph.add_concept(gel.IndividualConcept('a'))

    graph.add_axiom('C2', 'a', graph.is_a)
    graph.add_axiom('D1', 'a', graph.is_a)
    graph.add_axiom('a', 'C', graph.is_a)
    graph.add_axiom('a', 'D-1', graph.is_a)
    return graph
Пример #8
0
def test_graph_add_axiom():
    graph = gel.KnowledgeBase('bot', 'top')
    graph.add_concept(gel.Concept('C'))
    graph.add_concept(gel.Concept('D'))
    assert graph.add_axiom('C', 'D', graph.is_a)
    assert not graph.add_axiom('C', 'D', graph.is_a)