in reply to Really Long if/elsif/else blocks
Case in point. My code performs natural language processing. There's a routine driveBase. It takes a token (essentially, an English word or some other delimited string.) Given a token it doesn't recognize, it recursively snips off prefixes and suffixes, looking for a recognized token. Once it's found one, it deduces the part-of-speech of the original token. It records this – plus some other bookkeeping taken from the base token.1) This sounds very much like a search task for which a language like Prolog would work well. I'm not saying you need to write it in Prolog, but pondering how you might do it in a logic programming language might be helpful.
2) I think the ultimate way to do this is to just look up the answer (from a database.) Of course, you still have to first generate (or locate an existing) database, and this code can help to build it. I doubt, however, that you'll ever be able to come up with a complete set of rules, and eventually you'll need to "manually specify" what the answer is for certain input words.
3) Do you know about Wordnet? It's a lexical database of English which is advertised as being useful for natural language processing.
|
|---|