Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use the .prp file  RSS feed

sushant prabhu
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have created a program which is something lik this. there is a server program which accepts questions from the client program and provides with answers corresponding to that question back to the client. for this i am loading a .prp file on the serverside where there is the question to answer mapping. the program works fine when the question are one word question but the moment i have a 2 word question say a space between the 2 words my program fails.

say my .prp file is something lik this
what I dont know
here what is the question the client program will have to send in order to mak the program function properly.
say if i have
what is I dont know
my program stops giving me the right answer
Michael Ernest
High Plains Drifter
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sushant -
I was curious about your use of a .prp file, as I was unfamiliar with this format. I looked up a couple of things on the web, and from those I concluded that you're simply building a property. .prp seems to be at least two companies' idea of their proprietary extension.
I think the solution for what you're doing could be easier. If each question maps to a unique answer, what you could do is handle the question as a key, and its answer as a value. Key-value pairs correspond directly to properties in a file, so it's an efficient match.
In this context, a key can be any String. In practice, to avoid misinterpreting extra whitespace as a different question, you'd probably be better off replacing whitespace with some other delimiter, like underscores.
Then you can build a mapping like:
what_is_I_dont_know="what I don't know"
You might also want to consider bleaching out punctuation and capitalization from the user input if it's going to be entered by hand, or restrict the user to choosing questions from a Choice list. That will save you a substantial amount of validation code.
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!