# NLP how to go beyond simple intent finding--using context and targeting objects

I'm manually applying NLP rules to a chatbot.

Currently, I've a simple set of rules--actions that follow certain trigger words.
Ex: "Create the match on saturday."

This has been working for relatively simple phrases like the above example, where I would expect words like "create" and appoint it as an action word, expect "match" then appoint it as an object entity; "saturday" as a time, etc.

When I try to expand the scope of what the bot can handle, it becomes more complicated. Here's an example of something I'm trying to handle:

"Update the memo title of the match on saturday to 'Game Day'."

I'm not sure how to move forward.

I considered manually expanding(expecting) the entities, then trying a method where I still parse for action words, but if a certain threshold of varying objects is passed, then I execute a subset of that action.

For example: update will obviously signal an action, but the addition of "memo", "title", "'Game day'", signals a subset of the action as there's more to this than a simpler "create match". Then, checking the additional objects like "title" against a predetermined set of entities will narrow down the intent to update + title.

I see many holes in this logic, esp. as the complexity even slightly increases.

This led me to the field of dependency parsing.
But upon looking into dep. parsing, I wonder if this is something feasible in manual implementation.

I'll be using python code, it won't be deep learning based.

What do you think of the basic rule-based method I've outlined? Is it something that sounds workable for a domain-specific bot?

Should I be looking into using NLP libraries offered in Python such as NLTK or spaCy and use their features? My concern with using these features such as spaCy's dependency parser was that it was overkill, or too much added complexity for handling my domain specific tasks. Furthermore, and likely because I haven't yet seen effective use of it in another project, I guess I have doubts the practicality of dependency parsers outside of academia or research.

Edit: Apologies if this isn't the proper space for this kind of question. Would appreciate if you can please point me in the right direction

• The de jure solution to this problem is called attention, in the context of question answering neural networks; cf. e.g., A Context-aware Attention Network for Interactive Question Answering [pdf]. Welcome and good luck. – Emre Aug 23 '18 at 5:46
• Appreciate your response @Emre. This "attention" is different from the "attention" keyword used by Google engineers in their paper released last year, Attention Is All You Need, correct? Also, given that my bot is command->task-oriented, not machine-learning based, and not in the realm of question-answering, would you still recommend an attention based solution? – Casper Aug 23 '18 at 6:08
• It refers to the same concept, and while I realize that your problem is different, I think you still need attention to model determiners, as used in speech. To wit, Alexa is known to use attention. The action recognition is a simpler classification task. Why is it not machine learning based; because you have no data? If that is the case, use a commercial service to bootstrap your own. – Emre Aug 23 '18 at 6:56