# Logic in sentence : tree representation

I have sentences telling me to who a shop is opened to:

• "cats, dogs or birds" (1)
• "young dogs with collar" (2)
• "old cats or yellow birds" (3) etc...

I would like to design an algorithm that will change this sentences to a tree representation of the logic in it:

• (1) = (cat) or ((dog) or (bird))
• (2) = (young) and (dog) and (collar)
• (3) = ((cat) and (old)) or ((bird) and (yellow))

What do you think will work the best? LSTM maybe? How can I have this representation as a result?

Use Tree LSTM, if you need a vector embedding for the whole sentence. For use cases like classification, sentiment analysis. It works and there is a good probability that the vector could have all the information but you may not be certain and thats why its still a black box. But, if your use case is a clear representation of tree structure and logic among the terms (which you wanted), better go with parsers like Syntaxnet and try rule-based models for the use case mentioned.