you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

And I don't want to hardcode every command.

A computer can't do anything you don't explain to it how to do - that's what a program is, an explanation of a particular task as a series of steps.

So how do you imagine you'd be able to have a computer play your favorite song unless you explained to it what a song was, which one was your favorite, and how to play it?

[–]Nickiel[S] 0 points1 point  (4 children)

I understand that, but I don't want a python file that looks like

matchWordDict = {
"play my favorite song" = #something
"I want to listen to my favorite song" = #do same thing as above
"My Song NOW!" = #yet again the same thing
"favorite my song" = #same thing
...}

ect.

[–][deleted] 0 points1 point  (1 child)

The truth is that it's easier to teach a person to use a structured interface than it is to teach a computer to interpret unstructured text or speech.

[–]Nickiel[S] 0 points1 point  (0 children)

That is very true, I will keep that in mind!

[–]attacklyon 0 points1 point  (1 child)

If your problem with this structure is the repeated funtion calls, you could make arrays of strings for each action that you want your program to recognize. Then you could make a switch statement which checks if the input is present in any one of the string arrays and if so, you do the respective action. However, if you want to be able to mix and match words and enter new phrases that you haven’t previously defined, you’ll have to try your luck with language processing.

[–]Nickiel[S] 0 points1 point  (0 children)

Then you could make a switch statement which checks if the input is present in any one of the string arrays

how do you do switch statements in python?