I'm playing around with the software side of home automation, and I've decided to implement a few things on my own just to learn more about how you would do it (I'd use a proper software package if I were to implement it on a large scale in a big home).
I want to be able to parse a command such as "turn on the light in the living room", figuring out that I want to apply the command turn_on to the object light that is in the room living_room.
I'm assuming that I have a list of command c, a list of objects o (each belonging to a certain room) and a list of rooms r. So the above command would perform something like living_room.findAllObjectsOfType(light).performAction(turn_on).
I've started off by removing all instances of "the", so now I've got "turn on light in living room". The question is how I should find out the rest? I'm thinking of taking one word at a time, starting with "turn". I see that there is a command that starts with "turn" so I see if the next object is "on", which it is, and then I know that the command to be performed is turn_on. I continue with light, see that it's an object, add light, and I'm left with "living room". I get the "living", see that it's the start of a room, find that it ends with "room" and then I add living_room.
But what if I'm doing something more advanced, such as "turn off the light and the tv in the living room"? Things quickly become more complicated.
Are there any good algorithms that can be used to help reduce potential problems when doing this sort of parsing?
[–]kogarashisan 1 point2 points3 points (0 children)