![]() |
|
#1
|
|||
|
|||
Extracting Keywords from user inputI currently trying to make a text based game, and yes it is for school, while planning out how i was going to code this program I realized that I was going to have to search for any and all variations of what i want the user to do.
take the example of: Take Pillow (this is what i would like the user to type) the user may type out Take the pillow, or take the pillow off of the table, or many other variations, but all I am interested in is the Take and Pillow. I'm asking if there is an easier way to define keywords and just search the user's text for these keywords, and if so how i would go about doing so. Thanks in advance for your time, and if there are any questions about my explanation please ask. ~Wuzzin~ |
|||
|
#2
|
||||
|
||||
Re: Extracting Keywords from user inputQuote:
You'll want a container of verbs and another of nouns. Then, for each "location," in your game, you'll want to have a verb:noun relationship defined such that your text processor can make suitable matches or inform the user of any issues it has with processing user input. If you haven't played Zork, you may want to give it a look. http://www.csd.uwo.ca/Infocom/ MxB |
|
#3
|
||||
|
||||
Re: Extracting Keywords from user inputThe original game of this type can be found at http://www.rickadams.org/adventure/e_downloads.html. Even Zork has Adventure as a parent.
Quote:
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#4
|
|||
|
|||
Re: Extracting Keywords from user inputi'm going to try to extract the data as a string and search the string for certain words by using wildcards such as *take*, now just have to figure out what the wildcard characters are in Visual C++
|
|
#5
|
|||
|
|||
Re: Extracting Keywords from user inputif (txtInput->Text == "take pillow")
(txtInfo->Text +="Pillow taken."); lblPillow->Visible = true; if (txtInput->Text == "drop pillow") (txtInfo->Text +=("Pillow dropped.")); lblPillow->Visible = false; |
|
#6
|
|||
|
|||
Re: Extracting Keywords from user inputtxtInput is my textbox for the user's input
txtInfo is the main window with all the data that the user needs to read the Labels (lblPillow) is how i will show inventory items by setting them visible all i am doing is having the program look at the text in the txtInput (much easier than my first plan to pull the text out into strings). i am fine with this setup i am no longer looking to do wildcard searches, but now i'm having trouble getting my labels to go visible and invisible, thanks for your help : ) ~Wuzzin~ |
|
#7
|
|||
|
|||
Re: Extracting Keywords from user inputOk, ive gotten every little glitch in my program worked out, except one.
i am returning the preset responses to the user inputs by using += text to the textboxes such as this: else if ((txtInput->Text == "north") || (txtInput->Text == "south") || (txtInput->Text == "west")){ (txtInfo->Text +="\r\nYou walk into the wall, and as expected, it doesn't budge."); these are displaying in a multiline textbox, but the textbox resets to the top so that you have to scroll down after every input. I am looking for a way to have the program automatically scroll to the bottom of the multiline textbox so you can see what was just displayed. Thanks again for you help GID, ~Wuzzin~ |
|
#8
|
||||
|
||||
Re: Extracting Keywords from user inputYou really have to think through the input/parse/comparison mechanism much more thoroughly. What happens if the user types
Code:
The way Adventure handled it, there were many verbs defined, something like 1 take get keep so each of the words is translated into the number 1. And verb 1 has a specific definition. Then there's a list of objects, also turned into numbers. So you really need to carefully define how the input works, write that section, and get it working well. Then you simply call it from main() and process the values returned. __________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#9
|
|||
|
|||
Re: Extracting Keywords from user inputI am just going to have a strict syntax message in the beginning, it is just for our final exam in Computer Programming 2. ive already cleared how my inputs are going. I'm just trying to get my textbox to show the bottom instead of resetting to the top every time new text gets put in it.
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Separating a letter and number from user input | slyslick | C++ Forum | 2 | 25-Feb-2009 01:04 |
| Scanning dilemma (fscanf and fgets) | aijazbaig1 | C Programming Language | 10 | 29-Mar-2008 05:58 |
| Creating Variables based on user input | oddsprite | C++ Forum | 9 | 01-Nov-2007 05:31 |
| Need help with validating user input. | Emmy | C++ Forum | 4 | 19-Aug-2007 12:07 |
| Need Help on checking user input | hihellochao | C Programming Language | 5 | 27-Feb-2004 14:30 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The