Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: Binder News on November 05, 2011, 10:17:17 pm

Title: Natural Language Processing
Post by: Binder News on November 05, 2011, 10:17:17 pm
So, I've been wondering for a while now, how would I go about something like Natural Language Processing? Preferably, I would want to write the code in C/C++, but I don't really care that much. So, any ideas anyone?

-Bindernews
Title: Re: Natural Language Processing
Post by: Geekboy1011 on November 05, 2011, 11:33:58 pm
you mean as in like a interactive fiction parser or something else?
Title: Re: Natural Language Processing
Post by: nemo on November 05, 2011, 11:37:03 pm
what's your end goal? to be able to ask your program a question and have it come up with a logical answer, or have it be able to break down the parts of a sentence i.e. sentences into clauses & phrases, clauses & phrases into individual parts of speech?
Title: Re: Natural Language Processing
Post by: AngelFish on November 06, 2011, 12:00:44 am
The important questions are really how much information needs to be extracted and what the application is.

/me checks his personal library

Aww, all I have on the subject are a few papers on Natural Language Generation, which is basically the opposite problem.

Title: Re: Natural Language Processing
Post by: shmibs on November 06, 2011, 12:23:25 am
everyone else said it, but i have to repeat: to what end?
if you're making a game that uses text as input, searching for a few keywords and phrases can be enough, but other things are more difficult.
Title: Re: Natural Language Processing
Post by: Binder News on November 06, 2011, 12:24:42 am
The goal would be to be able to take a semi-natural language, make an Abstract Syntax Tree, and generate code in C/C++, Java, etc.
What I mean by semi-natural language is that there can be rules, so: "set the variable MyInt to the value of 5." should be the same as "let the variable MyInt equal 5." However, I don't mind if there are sever limits on what is can process.

Title: Re: Natural Language Processing
Post by: shmibs on November 06, 2011, 12:34:59 am
that sounds like a situation that could be handled through keywords as well. for example, your parser could take things like "let" or "set" as tip off words that the following is an equals statement, have "variable" indicate that the next word is a varname, etcetera.

the hardest part of something like this would probably be words that can be interpreted to mean different things according to context. for example, "and" could be used to separate different lines of code:
set variable MyName to 5 and increment it. (incidentally, dealing with pronouns could be tough as well)
or
increment variable MyName while it is less than 4 and greater than 1

the only way i can think of for dealing with something like that is to have while make whatever is next be interpreted as a boolean value, up until the next punctuation.
Title: Re: Natural Language Processing
Post by: Binder News on November 06, 2011, 12:39:15 am
Humm. You're right, that would be a problem. The good thing is, if there is too much ambiguity, I can just throw an error.
And pronouns wouldn't be too hard to deal with. At least I don't think so. The real problem for me is determining meaning using context.
Title: Re: Natural Language Processing
Post by: AngelFish on November 06, 2011, 12:51:20 am
What is the scope of this project? Is it to make a full language or just to make certain programming routines easier?
Title: Re: Natural Language Processing
Post by: Binder News on November 06, 2011, 01:35:51 am
I'm not sure. Right now, it's really just an experiment to determine the limits of the idea, and to play around with it a little.
Right now, I just want it to be able to process the text. If I ever get that working, I might make it into something. The real goal is just to see if it's doable.
Title: Re: Natural Language Processing
Post by: JL235 on November 06, 2011, 10:36:46 am
One of the problems with a natural language program is that lots of fiddly stuff, like the maths controlling how a sprite moves on a screen, can't easily be expressed.

But you might want to take a look at logic based programming languages such as Prolog, as they are pretty much used exclusively for this type of work. They make it easier to build the relationships needed between words, to allow you to better work out context.

Looking on Wikipedia I also found this (http://supernova.sourceforge.net/) natural programming language, which looks pretty cool. It's hello world program is:
Code: [Select]
I want window and the window title is Hello World.
Title: Re: Natural Language Processing
Post by: Binder News on November 06, 2011, 11:08:10 am
Yes. That's very close to what I'm trying to achieve. However, I hate how it looks like baby talk.
Thanks a ton. But please, continue to discuss.
Title: Re: Natural Language Processing
Post by: ExtendeD on November 06, 2011, 12:20:07 pm
Try third party libraries such as OpenNLP (unfortunately in Java). It may do the whole parsing job but it should really help you with the initial language parsing.
Title: Re: Natural Language Processing
Post by: Binder News on November 06, 2011, 12:48:24 pm
Awesome, thanks. for the tip. I'll be sure to look into it.