This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Creator's profile picture

How does a natural language parser work?

Started by Creator, 01 April 2015 - 07:29 PM
Creator #1
Posted 01 April 2015 - 09:29 PM
Hi guys,

for my app Aware, I have decided that it would be best if I used a natural langauge parser. How do these work? And how would I implement in in CC. It does not have to be complicated, and it is OK if it only supports correct gramar.

Tanks in advance,

Creator

PS: Aware is like Siri, but a little less advanced.
Edited on 01 April 2015 - 07:29 PM
SquidDev #2
Posted 01 April 2015 - 09:32 PM
You might want to have a look at NLTK. Its written in python but I've used it in the past for some things. Basically it is driven by a load of data. I mean a LOT of data. I'd have a look through some of the code, it shouldn't be too complicated to port the key bits to Lua.
Creator #3
Posted 01 April 2015 - 10:16 PM
Yeah, but is there not a simplified algorithm for this, like several thuosand line, but no more. The data could be stored in github, so that should not be a problem. What I want to know is how it works.
SquidDev #4
Posted 02 April 2015 - 08:09 AM
Read the source Luke. Its pretty well documented and it comes with an online book which guides you through everything from the basics to pretty complicated stuff. You'd be surprised how much you can learn just by reading other people's code.
Creator #5
Posted 02 April 2015 - 08:36 AM
Read the source Luke. Its pretty well documented and it comes with an online book which guides you through everything from the basics to pretty complicated stuff. You'd be surprised how much you can learn just by reading other people's code.

Thank you, I'll do that when I get some time.
The Lone Wolfling #6
Posted 02 April 2015 - 01:44 PM
It may be best to offload the actual NLP part to an online NLP parser. For example.
Creator #7
Posted 02 April 2015 - 01:55 PM
It may be best to offload the actual NLP part to an online NLP parser. For example.

Is what you mean that the app should send the string to the online parser and then get the result online, so there is no actual parsing done by Aware?
The Lone Wolfling #8
Posted 02 April 2015 - 04:42 PM
Well, the online parser won't do anything beyond "tree"-ifying the sentence. You'll still have to do the rest.

Here's a simple proof-of-concept I threw together using the JSON API and the HTTP API, and the aforementioned online NLP parser:

pastebin get DvkeHmUd nlp