Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Learning Aids/Tools 2 years ago
Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I made a chat bot, that, as you talk to it, it learns to respond. But the way it speaks is strange, so if you have any ideas on how to make its response any more human, then please say so.
Anyway, you have to start a new chat bot. You'll notice that when you start his responses will be incredibly stupid. Once you talk to him enough, he gets more human, but not by much.
I am not asking for you to review features in the code, I am asking for the code and overall style to be reviewed.
import random, pickle, os import os.path startmes = """Machine Learning Conversational Program by Jake Speiran, 2015. ver 1.0 Hello! In a moment you will begin chatting with Machine Learning Conversational Program, or MLCP. Everything you say he will learn, and every response you make he will remember. The goal is that he will someday be able to talk. Type "#help" to learn more. To quit the program, type "#quit" into the command prompt. """ helpmes = """This is the help message for MLCP. In order to communicate with the bot, simply type what you want to say into the input space. When typing please use only lower case characters and no special characters. So this: "You're a real star!" Becomes this: "youre a real star" The reason for this is that otherwise you would have many entries that are copies of the same word, ie Hey, hey, hey! and Hey all mean the same thing but would be entered differently. Sometimes what the bot says can be hard to interpret, but keep trying and use your imagination. """ class bot(): def __init__(self, autosave, deldups, autocount, maxwords, maxresp): self.autosave = autosave self.autocount = autocount self.deldups = deldups self.maxwords = maxwords self.maxresp = maxresp self.known = {} self.wordcount = 0 self.sescount = 0 os.system("cls") print(startmes) if os.path.isfile("known.data"): self.known = pickle.load(open('known.data', "rb")) print("Save file loaded!") else: print("No save file found.") print() for key, value in self.known.items(): self.wordcount += 1 def question(self, x): self.wordcount += 1 a = "w" + str(self.wordcount) d = {"name": x, "resp": [x], "uses": 0} self.known[a] = d def talk(self): talking = True prevres = "" while talking: if self.autosave: self.sescount += 1 if self.sescount >= self.autocount: self.sescount = 0 pickle.dump(self.known, open('known.data', 'wb' REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
bot
startmes
helpmes
os.system("cls")
os.system("clear")
os.system("cls" if os.name == "nt" else "clear")
maxwords
wordcount
max_words
word_count
snake_case
PascalCase
UPPERCASE_SNAKE_CASE
()
class bot
class MyClass:
object
class Enemy(Character):
You mention in the helpmes variable, that the user shouldn't enter punctuation of any kind. This is sort of a hacky way to get user input, so I'd recommend using str.replace(item_to_replace, replace_with) to remove punctuation. Here's an example that removes periods, commas, and apostrophes.
str.replace(item_to_replace, replace_with)
user_input = raw_input("> ") .replace(".", "") .replace(",", "") .replace("'", "")
Finally if you ever implement a more advanced command system than just #help or #quit, I'd recommend using a dictionary, rather than chaining if/elif/else statements.
#help
#quit
if
elif
else
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.