Despite the rise of statistical models in NLP, rule based grammars still have various use cases. In this lecture, we explore a bit more about how these systems are used.
As we've seen, rule based systems are complicated and difficult to develop. Just adding the ability to inflect adjectives in Spanish presented many challenges to overcome, and that's just a small part of only a single natural language.
So why are rule based systems and grammars still being studied? They excel in reliability for domain specific tasks.
Say you wanted to cook something special, but the recipe was in a different language and you can't find one in your own. Google Translate may be able to help! So, you copy and paste the recipe into that handy service and out pops a recipe you can understand… but none of it makes any sense. This YouTube trend perfectly shows how far General NLP systems like Google Translate have to go before they can really handle any task.
In reality, there are only so many cooking techniques and possible ingredients, most of which will have direct translations in many other languages. This is an example of a "domain" in NLP.
Broadly, domains are segments of a language that have little internal ambiguity and definable boundaries for what can be considered in or out of the domain.
For example, turkey in a cooking domain will always be the bird, while in an international affairs domain it will always be the country. There is no ambiguity for the word Turkey when constrained to either of those domains. However if the topic of the domain is unrelated to either meaning of turkey, the word would be considered outside that domain.
Let's take a second to think about our cooking domain. What kinds of ideas, vocabulary, etc. would belong to that domain, and where would the boundary logically be?
If a domain is well defined, a system that implements that domain will always outperform statistical models on the same tasks. Given enough time and resources, it would be well within the realm of possibility to write a recipe translator in GF so that whatever recipe you write is guaranteed to be understandable in any target language.
Consider the sentence "Bake turkey at 375F for 3 hours"
Parsing this out, we can see that the action bake
has three "parameters" associated with it: what is being baked, what temperature it's being baked at, and how long it's being baked. As such, our abstract syntax tree could look something like
bake ( food (turkey), temperature (375F), duration (3 hours))
As we saw last week, this can very easily be translated into any number of languages as long as you define linearization rules for all of these words.
A quick search for "rule based NLP" on Google Scholar yields quite a few results, most of which are descriptions of certain scientific domains where rule based systems are used for various purposes. In 2022 alone, there are papers describing uses such as information extracton, part-of-speech tagging, named entity recognition, and other forms of linguistical analysis. Each of these topics could be a course unto itself and are fantastic options for final projects, so feel free to explore at your leisure :)
Perhaps the purest form of rule base NLP comes in the form of Controlled Natural Languages (CNLs), that attempt to pare down real world languages into simpler forms that are directly parsable by a computer. There many CNLs out ther with varying degrees of human readability, machine readability, what can be expressed, etc. A fairly comprehensive review of CNLs from 2013 is available here.
Because there are so many, there's not enough time to discuss all of them, but two that are particularly interesting are "CLEF Query Language" and "Attempto Controlled English".
Databases are hugely important in modern software, so easy querying and managing through a readable interface is vital. This isn't much of an issue for developers, as we can easily learn SQL, MongoDB, Neo4j, etc. But there are many cases in which non-specialists need flexible access to databases. This is where a language like CLEF QL comes in. Proposed in Hallett et.al 2007, CLEF QL provides a natural language interface that is translated directly into SQL. The system outline looks something like this:
An example query would is "How many of the explorers who climbed Kilimanjaro but not Everest between 1960 and 1995 did so more than three times during that period?" If you're familiar with SQL, you may realize that a query like this would be fairly complex, well beyond someone who has no experience in programming.
Whereas some CNLs are meant to access data, others are ment to be the data itself. Such is the case for Attempto Controlled English (ACE). It was first proposed in Fuchs et.al 1996 by researchers at the university of Zurich as a language in which to easily store domain specific data in a format that is both human readable and machine parsable.
The research team at Zurich has developed a few very cool tools that make use of the capabilities of ACE. One of which is a wiki service that runs automatic logic checks on its corpus to make sure every statement is logically consistent.
They have also implemented a large subset of ACE using GF, see eg ACE.gf for a concrete example of part of the grammar. Using both the ACE wiki technology and the capabilities of GF, they expanded the wiki to automatically translate pages into various languages!
ACE is defined such that no ambiguity exists even when the same sentence written in normal English could have multiple interpretations.
For example, in the sentence "A customer inserts a card that is valid and opens an account." it isn't clear if the customer or the card opens the account. But in ACE, the parser will assume the main subject of the sentence carries on to each predicate, so the customer is understood to open the account.
To write a similar sentence while making sure the card is understood to open the account, you would say "A customer inserts a card that is valid and that opens an account."
For more information on ACE, check out their homepage!
Do some self exploration in the world of rule based NLP and report back to the slack channel. A starting point could be Google Scholar.[1] Of particular interest are projects that have a git repository with code that can be run.
When you've found something worth sharing, write a short paragraph on what you found and post it in the class Slack. Just make sure to provide links to the resources you use to get your information!
You have free reign over all things Rule Based. You could share a cool use for Rule Based systems, talk about a domain that you find interesting, look deeper into any of the CNLs from Kuhn's survey paper, or anything else you can find!
If you come across something particularly interesting, it could lead you to a topic for the final project!
Please make sure to send your message to the slack before 10:00 AM on Tuesday 2/22 so there is time to read everyone's responses by next class!
If you find a paper that interests you, you can find later work citing this paper by clicking on "cited by". Earlier work is cited in the paper itself. This way it is easy to search back and forward in time and to map out the landscape of topic fairly quickly. ↩︎