Esempio n. 1
0
def main():

    builder = OntoBuilder()
    builder.build_knowledge_base('data/knowledge_base.txt')
    builder.build_facts('data/fact_base.txt')
    # builder.store('data/knowledge_base.json')

    onto_container = OntoContainer()
    # onto_container.load("data/sample1.json")
    onto_container.load("data/knowledge_base.json")
    onto_container.build_secondary_connections()

    algo1 = Algorithm(onto_container=onto_container,
                      filename='algo/patterns/because_i_know.json')
    algo2 = Algorithm(onto_container=onto_container,
                      filename='algo/patterns/inference_bridge.json')
    algo3 = Algorithm(onto_container=onto_container,
                      filename='algo/patterns/resolve_ambiguity.json')

    algo_container = AlgoContainer()
    algo_container.add_algorithm(algo1)
    algo_container.add_algorithm(algo2)
    algo_container.add_algorithm(algo3)

    brain = Brain(onto_container=onto_container, algo_container=algo_container)

    input = 'what language do people speak in english speaking country?'
    # input = 'what language people speak in Russia?'
    # input = ['country', 'check', 'side', 'left', 'cross', 'street']
    graph_walker = GraphWalker(brain=brain)
    result = graph_walker.resolve(input)
    print(result)
def main():
    builder = OntoBuilder2()
    # builder.build_knowledge_base('data/knowledge_base.txt')
    builder.build_facts('data/fact_base.txt')
    builder.store('data/knowledge_base.json')

    onto_container = OntoContainer()
    onto_container.load("data/knowledge_base.json")
    onto_container.build_secondary_connections()

    algo1 = Algorithm(onto_container=onto_container, filename='algo/patterns/simple_connection.json')

    algo_container = AlgoContainer()
    algo_container.add_algorithm(algo1)

    brain = Brain(onto_container=onto_container, algo_container=algo_container)
    estimator = Estimator(brain)

    algo_builder = AlgoBuilder(brain)
    algo_builder.build_from('data/algo_base.txt', './algo/patterns')

    # input = 'do people in a slavic speaking country speak english?'
    input = 'do people in a USA speak english?'
    # input = 'does USA have people?'

    graph_walker = GraphWalker(brain=brain)
    graph_walker.train_mode = True
    result = graph_walker.resolve(input)
    print(result)
    exit()
Esempio n. 3
0
def main():
    builder = OntoBuilder()
    builder.build_knowledge_base('data/knowledge_base.txt')
    builder.build_facts('data/fact_base.txt')
    # builder.store('data/knowledge_base.json')

    onto_container = OntoContainer()
    onto_container.load("data/knowledge_base.json")
    onto_container.build_secondary_connections()

    algo1 = Algorithm(onto_container=onto_container,
                      filename='algo/patterns/simple_connection.json')

    algo_container = AlgoContainer()
    algo_container.add_algorithm(algo1)

    brain = Brain(onto_container=onto_container, algo_container=algo_container)
    estimator = Estimator(brain)
    algo_composer = AlgoComposer(brain=brain, estimator=estimator)

    input = 'do people in Russia speak english?'
    # input = 'does USA have people?'

    graph_walker = GraphWalker(brain=brain)
    graph_walker.train_mode = True
    result = graph_walker.resolve(input)
    print(result)
    exit()

    algorithm = algo_composer.compose(input, 'right')
    if algorithm:
        algorithm.save('algo/patterns/composed.json')
def main():
    builder = OntoBuilder2()
    builder.build_facts('data/fact_base.txt')
    builder.store('data/knowledge_base.json')

    onto_container = OntoContainer()
    onto_container.load("data/knowledge_base.json")
    onto_container.build_secondary_connections()

    algo_container = AlgoContainer()

    brain = Brain(onto_container=onto_container, algo_container=algo_container)
    estimator = Estimator(brain)

    algo_builder = AlgoBuilder(brain)
    algo_builder.build_from('data/algo_base.txt', './algo/patterns')

    algo_container.add_algorithm(
        Algorithm(onto_container=onto_container,
                  filename='algo/patterns/closed_q_reply.json'))
    algo_container.add_algorithm(
        Algorithm(onto_container=onto_container,
                  filename='algo/patterns/what_question_reply.json'))
    algo_container.add_algorithm(
        Algorithm(onto_container=onto_container,
                  filename='algo/patterns/switch_context.json'))
    algo_container.add_algorithm(
        Algorithm(onto_container=onto_container,
                  filename='algo/patterns/get_closest.json'))
    algo_container.attach_to_brain(brain)

    # input = 'do people in a slavic speaking country speak english?'
    input = 'do people in a USA speak english?'
    # input = 'does USA have people?'

    algo_runner = AlgoRunner(brain=brain)
    result = algo_runner.run(input)
    print(result)
Esempio n. 5
0
from nlp import Clause
from onto.onto_container import OntoContainer
from onto_resolver import OntoResolver

container = OntoContainer()
container.load("onto/moneycare.json")

clause = Clause()
clause.load("test/sample_query3.json")

resolver = OntoResolver(container)
reply = resolver.get_reply(clause)

print(reply)
Esempio n. 6
0
from onto.onto_container import OntoContainer

container = OntoContainer()
container.load("light_match.json")