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?


1 Answer 1


Syntaxnet parser could surely help you in parsing the sentences and in tree represenation.

If you plan on solving using RNNs, I believe Tree LSTM will be a better choice than LSTM, as it also preserves dependency information. Full paper.

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.

  • $\begingroup$ Thank you, I didn't know about Tree LSTM ! For my problem, Syntaxnet is a good approach indeed, I'll try it ! $\endgroup$
    – lrosique
    Aug 29, 2017 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.