Jump to content

Recommended Posts

Posted

Hey all, I didn't want to hijack the news thread so I decided to make a new one. I worked on data integration today and I thought that making a chatbot would suffice for the moment because I don't have the infrastructure available to me yet to start scraping more data. I thought you guys might like to see this, it's probably very close to the cleverbot algorithm. It's going to need a lot of data to get to something useful though, so I threw in some machine learning. I'm giving it to you guys where time is an empty dictionary, so you're going to want to talk to it for a little while to get it to respond, and on top of talking to it for a little while, it's going to be best if you restart the algorithm a few times because it is dispositionally and context sensitive. It won't have much to say the first few times around, but it will learn and it does work. It's not where I want it to be yet, but I could probably have a better model by the end of the day. Anyways, here ya go have fun.

time = {}

def FunTime():
	while 1:
		m = 0
		while 2:
			poi = raw_input('>')
			try:
				npoi.append(poi)
				if len(npoi) == 3:
					npoi = npoi[1:]
			except:
				npoi = []
				npoi.append(poi)
			m += 1
			if poi not in time:
				time[poi] = ['']
				location = time[poi];
				location.append(m)
				time[poi] = location
				emerge = time[poi];
			if poi in time:
				location = time[poi];
				location.append(poi)
				location.append(m)
				emerge = time[poi];
				try:
					local = emerge.index(m-1)
				except:
					pass
				try:
					print emerge[local-1]
					location.append(emerge[local-1])
					try:
						location.append(npoi[1])
					except:
						pass
					location.append(m+1)
				except:
					pass
				time[poi] = location

#Now just type FunTime() and it will start working for ya. Ctrl-C will end the process
#Written in Python 2.7.6 64-bit
Posted

 

Hey all, I didn't want to hijack the news thread so I decided to make a new one. I worked on data integration today and I thought that making a chatbot would suffice for the moment because I don't have the infrastructure available to me yet to start scraping more data. I thought you guys might like to see this, it's probably very close to the cleverbot algorithm. It's going to need a lot of data to get to something useful though, so I threw in some machine learning. I'm giving it to you guys where time is an empty dictionary, so you're going to want to talk to it for a little while to get it to respond, and on top of talking to it for a little while, it's going to be best if you restart the algorithm a few times because it is dispositionally and context sensitive. It won't have much to say the first few times around, but it will learn and it does work. It's not where I want it to be yet, but I could probably have a better model by the end of the day. Anyways, here ya go have fun.

time = {}

def FunTime():
	while 1:
		m = 0
		while 2:
			poi = raw_input('>')
			try:
				npoi.append(poi)
				if len(npoi) == 3:
					npoi = npoi[1:]
			except:
				npoi = []
				npoi.append(poi)
			m += 1
			if poi not in time:
				time[poi] = ['']
				location = time[poi];
				location.append(m)
				time[poi] = location
				emerge = time[poi];
			if poi in time:
				location = time[poi];
				location.append(poi)
				location.append(m)
				emerge = time[poi];
				try:
					local = emerge.index(m-1)
				except:
					pass
				try:
					print emerge[local-1]
					location.append(emerge[local-1])
					try:
						location.append(npoi[1])
					except:
						pass
					location.append(m+1)
				except:
					pass
				time[poi] = location

#Now just type FunTime() and it will start working for ya. Ctrl-C will end the process
#Written in Python 2.7.6 64-bit

What exactly is this program supposed to do? I ran it and it didn't do anything.

Posted

Here is the minor fix that I made-

def FunTime():
	while 1:
		m = 0
		while 2:
			poi = raw_input('>')
			try:
				npoi.append(poi)
				if len(npoi) == 3:
					npoi = npoi[1:]
			except:
				npoi = []
				npoi.append(poi)
			m += 1
			if poi not in time:
				time[poi] = ['']
				location = time[poi];
				location.append(m)
				time[poi] = location
				emerge = time[poi];
			if poi in time:
				location = time[poi];
				location.append(poi)
				location.append(m)
				emerge = time[poi];
				try:
					local = emerge.index(m-1)
				except:
					pass
				try:
					if type(emerge[local-1]) is str:
						print emerge[local-1]
						location.append(emerge[local-1])
						try:
							location.append(npoi[1])
						except:
							pass
					location.append(m+1)
				except:
					pass
				time[poi] = location

It's probably not that fun but go ahead and play with it for a few minutes lol if anything, the code may help for other purposes

Posted

Here is the minor fix that I made-

def FunTime():
	while 1:
		m = 0
		while 2:
			poi = raw_input('>')
			try:
				npoi.append(poi)
				if len(npoi) == 3:
					npoi = npoi[1:]
			except:
				npoi = []
				npoi.append(poi)
			m += 1
			if poi not in time:
				time[poi] = ['']
				location = time[poi];
				location.append(m)
				time[poi] = location
				emerge = time[poi];
			if poi in time:
				location = time[poi];
				location.append(poi)
				location.append(m)
				emerge = time[poi];
				try:
					local = emerge.index(m-1)
				except:
					pass
				try:
					if type(emerge[local-1]) is str:
						print emerge[local-1]
						location.append(emerge[local-1])
						try:
							location.append(npoi[1])
						except:
							pass
					location.append(m+1)
				except:
					pass
				time[poi] = location

It's probably not that fun but go ahead and play with it for a few minutes lol if anything, the code may help for other purposes

It still isn't working. Can you send a screenshot of it working? At least if it works on your computer then I know it is a problem with my version of Python.

Posted

It might be the way you're talking to it. If that's the case and you're being prompted for input then don't be afraid of repeating something you've already said.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.