Example #1
0
def main():
    testm = createModel('berkeley_db')
    br = Brain(testm)

    for i in range(1, 20):
        print br.generate_random()
        print
Example #2
0
def main():
    testm = createModel('shelve')
    br = Brain(testm)
    for line in open('brain.log'):
        stderr.write(".")
        try:
            br.learn(line.decode('utf-8'))
        except SequenceTooShortException:
            pass
    stderr.write("\n")
    br.sync()
Example #3
0
from dadacore.model import createModel, SequenceTooShortException, \
    StartWordException
from dadacore.brain import Brain, BrainIsEmptyException

urls = (
  '/', 'index',
  '/reply_to_line', 'reply_to_line',
  '/api/random', 'api_random',
  '/api/reply_to_line', 'api_reply_to_line',
)

render = web.template.render('templates/')

brain_lock = Lock()
with brain_lock:
    mmodel = createModel('shelve')

    brain = Brain(mmodel)

brainlog = open("brain.log", "a")

class index:
    def GET(self):
        try:
            with brain_lock:
                randomlines = [ brain.generate_random() for i in range(1,10) ]
        except BrainIsEmptyException:
            randomlines = [ "Brain is empty" ]
        except StartWordException:
            randomlines = [ "Error: %s %s" % exc_info()[0:1] ]
        return render.index(randomlines)
Example #4
0
from dadacore.model import createModel, SequenceTooShortException, \
    StartWordException
from dadacore.brain import Brain, BrainIsEmptyException

urls = (
  '/', 'index',
  '/reply_to_line', 'reply_to_line',
  '/api/random', 'api_random',
  '/api/reply_to_line', 'api_reply_to_line',
)

render = web.template.render('templates/')

brain_lock = Lock()
with brain_lock:
    mmodel = createModel('berkeley_db')

    brain = Brain(mmodel)

brainlog = open("brain.log", "a")

class index:
    def GET(self):
        try:
            with brain_lock:
                randomlines = [ brain.generate_random() for i in range(1,10) ]
        except BrainIsEmptyException:
            randomlines = [ "Brain is empty" ]
        except StartWordException:
            randomlines = [ "Error: %s %s" % exc_info()[0:1] ]
        return render.index(randomlines)