Пример #1
0
def update(inCmd,
           inStr,
           speak=True,
           partialChat=False,
           onlyChat=False,
           matches=[[], []]):

    #global CMDS, CMDE, SETTINGS, EMOTIONS, CHATDATA, BLACKLIST

    if speak and not onlyChat:
        say(getResponse(inCmd), more=False, speak=setting("SPEAK"))

    # only load part of chat file for speed reasons

    if partialChat:
        GLOB['CHATDATA'] = []
        allChatData = load(DATA_DIR + "chatList.txt", LPC=1, addQuotes=True)

        i = 0
        while i < len(allChatData) - 1:
            # decide whether to include next two lines
            if randint(0, 19) <= 4:  # load a random 25% of the lines
                GLOB['CHATDATA'].append(allChatData[i])
                GLOB['CHATDATA'].append(allChatData[i + 1])
            i += 2
    else:
        GLOB['CHATDATA'] = load(DATA_DIR + "chatList.txt",
                                LPC=1,
                                addQuotes=True)

    if onlyChat: return True

    GLOB['CORRECTIONS'] = load(DATA_DIR + "corrections.txt", LPC=1)
    GLOB['CORRECTIONS'] = [s[0] for s in GLOB['CORRECTIONS']]

    GLOB['CMDS'] = load(SETS_DIR + "CMDS.txt", LPC=6)
    GLOB['CMDE'] = load(SETS_DIR + "CMDE.txt", LPC=7)

    GLOB['SETTINGS'] = load(SETS_DIR + "settings.txt", LPC=1)
    GLOB['SETTINGS'] = [s[0] for s in GLOB['SETTINGS']]

    GLOB['EMOTIONS'] = load(SETS_DIR + "emotions.txt", LPC=1)
    GLOB['EMOTIONS'] = [s[0] for s in GLOB['EMOTIONS']]

    GLOB['FACTUAL_MEMORY'] = jsonLoad(DATA_DIR + 'factual_memory.txt')
    GLOB['AUTOBIOGRAPHIC_MEMORY'] = jsonLoad(DATA_DIR +
                                             'autobiographic_memory.txt')
    if GLOB['AUTOBIOGRAPHIC_MEMORY'] == {}: GLOB['AUTOBIOGRAPHIC_MEMORY'] = []

    return True
Пример #2
0
	def loadFile(self):
		data = fileIO.jsonLoad(self.fileName)
		
		if data == {}:
			return


		self.curZoom = data['zoom']

		geom = data['root_geometry']
		#geom = geom.split('+')[0]+'+0+0'
		#self.root.geometry(geom)
		
		geomD = geom.replace('+', ' ').replace('x', ' ').split()
		geomD = [int(d) for d in geomD]
		geomD2 = (geomD[0], geomD[1], int(g.WIDTH/2 - geomD[0]/2), int(g.HEIGHT/2 - geomD[1]/2))
		geom = '%sx%s+%s+%s'%geomD2
		self.root.geometry(geom)

		self.root.update()
		self.resize()

		for t in data['thoughts']:
			self.addThought(coords=t['pixLoc'], data=t)

		for l in data['links']:
			self.linkA = l['tA']
			self.linkB = l['tB']
			self.linkImportance = l['importance']
			self.addLink()
Пример #3
0
def update(inCmd, inStr, speak=True, partialChat=False, onlyChat=False, matches=[[],[]]):

	#global CMDS, CMDE, SETTINGS, EMOTIONS, CHATDATA, BLACKLIST

	if speak and not onlyChat:
		say(getResponse(inCmd), more=False, speak=setting("SPEAK"))

	# only load part of chat file for speed reasons
	
	if partialChat:
		GLOB['CHATDATA']=[]
		allChatData = load(DATA_DIR+"chatList.txt", LPC=1, addQuotes=True)

		i=0
		while i < len(allChatData)-1:
			# decide whether to include next two lines
			if randint(0,19) <= 4: # load a random 25% of the lines
				GLOB['CHATDATA'].append(allChatData[i])
				GLOB['CHATDATA'].append(allChatData[i+1])
			i += 2	
	else:
		GLOB['CHATDATA'] = load(DATA_DIR+"chatList.txt", LPC=1, addQuotes=True)

	if onlyChat: return True

	GLOB['CORRECTIONS'] = load(DATA_DIR+"corrections.txt", LPC=1)
	GLOB['CORRECTIONS']=[s[0] for s in GLOB['CORRECTIONS']]

	GLOB['CMDS']=load(SETS_DIR+"CMDS.txt", LPC=6)
	GLOB['CMDE']=load(SETS_DIR+"CMDE.txt", LPC=7)

	GLOB['SETTINGS']=load(SETS_DIR+"settings.txt", LPC=1)
	GLOB['SETTINGS']=[s[0] for s in GLOB['SETTINGS']]

	GLOB['EMOTIONS']=load(SETS_DIR+"emotions.txt", LPC=1)
	GLOB['EMOTIONS']=[s[0] for s in GLOB['EMOTIONS']]

	GLOB['FACTUAL_MEMORY'] = jsonLoad(DATA_DIR+'factual_memory.txt')
	GLOB['AUTOBIOGRAPHIC_MEMORY'] = jsonLoad(DATA_DIR+'autobiographic_memory.txt')
	if GLOB['AUTOBIOGRAPHIC_MEMORY'] == {}: GLOB['AUTOBIOGRAPHIC_MEMORY'] = []


	return True
Пример #4
0
from random import *
import copy
from textblob import TextBlob
import sys
from fileIO import jsonLoad, jsonSave

from phraseModify import addAuxVerb, listize, removeStrange, wordSim, processResponse

sys.path.append("..")
from patterns_lib.patternMatching import matchFromList

from header import KTDIR
sys.path.insert(0, KTDIR)
import kt2 as k

W5 = jsonLoad('w5_4.txt')

DEBUG = False

def clearlyQuestion(inStr):

	inStr = inStr.strip()
	if inStr[len(inStr)-1] == '?':
		return True

	# check that the first word is not a 5W
	inStrWords = inStr.lower().split()

	for word in inStrWords:
		if word in ["who", "what", "where", "when", "why", "how", "whose"]:
			return True