Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Natural Language Processing for Smart Homes

Tags:

algorithm

nlp

I'm writing up a Smart Home software for my bachelor's degree, that will only simulate the actual house, but I'm stuck at the NLP part of the project. The idea is to have the client listen to voice inputs (already done), transform it into text (done) and send it to the server, which does all the heavy lifting / decision making.

So all my inputs will be fairly short (like "please turn on the porch light"). Based on this, I want to take the decision on which object to act, and how to act. So I came up with a few things to do, in order to write up something somewhat efficient.

  1. Get rid of unnecessary words (in the previous example "please" and "the" are words that don't change the meaning of what needs to be done; but if I say "turn off my lights", "my" does have a fairly important meaning).
  2. Deal with synonyms ("turn on lights" should do the same as "enable lights" -- I know it's a stupid example). I'm guessing the only option is to have some kind of a dictionary (XML maybe), and just have a list of possible words for one particular object in the house.
  3. Detecting the verb and subject. "turn on" is the verb, and "lights" is the subject. I need a good way to detect this.
  4. General implementation. How are these things usually developed in terms of algorithms? I only managed to find one article about NLP in Smart Homes, which was very vague (and had bad English). Any links welcome.

I hope the question is unique enough (I've seen NLP questions on SO, none really helped), that it won't get closed.

like image 461
Eduard Luca Avatar asked Sep 09 '13 21:09

Eduard Luca


3 Answers

If you don't have a lot of time to spend with the NLP problem, you may use the Wit API (http://wit.ai) which maps natural language sentences to JSON:

enter image description here

It's based on machine learning, so you need to provide examples of sentences + JSON output to configure it to your needs. It should be much more robust than grammar-based approaches, especially because the voice-to-speech engine might make mistakes that will break your grammar (but the machine learning module can still get the meaning of the sentence).

like image 80
Blacksad Avatar answered Nov 10 '22 13:11

Blacksad


I am no way a pioneer in NLP(I love it though) but let me try my hand on this one. For your project I would suggest you to go through Stanford Parser

  1. From your problem definition I guess you don't need anything other then verbs and nouns. SP generates POS(Part of speech tags) That you can use to prune the words that you don't require.

  2. For this I can't think of any better option then what you have in mind right now.

  3. For this again you can use grammatical dependency structure from SP and I am pretty much sure that it is good enough to tackle this problem.

  4. This is where your research part lies. I guess you can find enough patterns using GD and POS tags to come up with an algorithm for your problem. I hardly doubt that any algorithm would be efficient enough to handle every set of input sentence(Structured+unstructured) but something that is more that 85% accurate should be good enough for you.

like image 39
Prateek Avatar answered Nov 10 '22 12:11

Prateek


First, I would construct a list of all possible commands (not every possible way to say a command, just the actual function itself: "kitchen light on" and "turn on the light in the kitchen" are the same command) based on the actual functionality the smart house has available. I assume there is a discrete number of these in the order of no more than hundreds. Assign each some sort of identifier code.

Your job then becomes to map an input of:

  • a sentence of english text
  • location of speaker
  • time of day, day of week
  • any other input data

to an output of a confidence level (0.0 to 1.0) for each command.

The system will then execute the best match command if the confidence is over some tunable threshold (say over 0.70).

From here it becomes a machine learning application. There are a number of different approaches (and furthermore, approaches can be combined together by having them compete based on features of the input).

To start with I would work through the NLP book from Jurafsky/Manning from Stanford. It is a good survey of current NLP algorithms.

From there you will get some ideas about how the mapping can be machine learned. More importantly how natural language can be broken down into a mathematical structure for machine learning.

Once the text is semantically analyzed, the simplest ML algorithm to try first would be of the supervised ones. To generate training data have a normal GUI, speak your command, then press the corresponding command manually. This forms a single supervised training case. Make some large number of these. Set some aside for testing. It is also unskilled work so other people can help. You can then use these as your training set for your ML algorithm.

like image 3
Andrew Tomazos Avatar answered Nov 10 '22 13:11

Andrew Tomazos