Pages

Tuesday, March 9, 2010

What is the rule

Every Natural language processing application is evolved from rule based system, weather it is machine translation system, parsing, classification or any other field. Later some of the rule based applications are replaced by statistical applications, but still rule based system is more appreciated for the languages which are suffering from low resources. So for understanding rule based application, we should understand first what is the rule.
Rule is binary class condition which has three 3 Cs Constraints, Class and Consequences. you can also called consequences as actions or reactions. Rules can be integrated in rule based application in two forms.

1) Embedded or hard-coded Rules:- Rules can be embedded as "if..else if..else" statements in programs. Where each if and "else if" conditions are the constraints of rules, you can add class and consequences inside "if.. else if.." statement. The else statement is default rule. But now a days "if..else.." branch looks very odd. So it is better to use rule in form of dictionary or hash where the key of dictionary is the class and values are constraints.
for example
if cat1 ='A1' and cat2='A2':
return class1
elif cat1='B1' and cat2='B2':
return class2
------------------------------
-----------------------------
else:
return classDefualt

the rule in piece of code is really weird and loses readability. Instead of that you can make rule code separately and call the rules whenever needed.

#rules
rule= class1: {rcat1:'A1', rcat2:'A2'......}, class2:{rcat1:'B1',rcat2:'B2'..}.....
#calling rule
for each in rule:
if cat1==rule[each][rcat1] and cat2==rule[each][rcat2]... :
return each

This piece of code maintain readability and it provides independence as user can modify the rules independently.
2)Rule file:- Second way of integrating rules with system is by having separate rule file. This provides flexibility to the linguists to write the rules and computer scientists to integrate it. But before that linguists and computer scientists should come up with common definite template of rule.

Rules in different scenarios:- Rules or grammar can be used in different applications. I will discuss some of them in this section.
1) Classification:- This is the primary function of rule based system. In this type of problem the consequences or action part of rule is missing. The rules only contain Constraints and Class. One rule is used for binary classification(True or False) for a given class. You can use different rules together so that it can perform multi-class classifications. You can also order the rules so that one rule can trigger another rule. In other words one rule acts as constraint for another rule.
2) Extraction:- Pattern based rules can be used for extraction. Remember that every rule has constraints, class and consequences. These types of rules uses patterns as constraints. One rule has one or more than class associated with it. Different classes present different types of entities. Each class can be part of pattern or each pattern is classified under different class. For example take a NER rule, PERSON_NAME Public School=> ORGANIZATION_NAME. In this rule PERSON_NAME is present inside the pattern but whole extracted pattern is classified as ORGANIZATION_NAME.
3)Parsing:- Rules, now a days, are used in natural language parsing. There are the two variations for parsing 1)Phrase structure Parse and 2)Dependency Structure Parse. Phrase Structure is more popular for fixed word order language and uses context free grammar or tree adjoining grammar. The example of context free grammar is
VP=>V NP
where left hand side (VP) can be treated as class of rule, Right hand side ( V NP ) is treated as constraint of rule, and parsing is treated as action or consequences. The dependency structure parsing is another variation of parsing. One can convert dependency structure tree from phrase structure tree. One can also includes all different linguistics cues inside the rules for dependency parsing. One of the example of such system is LDM (Linguistics Discourse Model) which is used in discourse parsing.
4)Machine Translation:- Rules based system is also used in machine translation for language pair which don't have enough resource. The rules which are used in such system are known as transfer grammar.
For example, for English-Hindi language pair, simple transfer grammar is given by
NP VP NP=> NP NP VP
as English is SVO(subject verb object) language and Hindi is SOV(Subject Object Verb) language. So in above transfer grammar, SVO structure is converted to SOV structure.
So in transfer grammar, left hand side (NP VP NP) is constraint and Right hand side(NP NP VP) represents as re-ordering of phrases. This act as action or consequence of transfer grammar. The class can be present or absent.

I will talk about the advantage and disadvantage of rule based system.
1)Advantage:- It does not require much resources. You can have different class of rule such as robust rules. Robust rules are the rules which has high precision and low recall. The confidence level of robust rule is high and you can use them to improve statistical system.
2)Disadvantage:- Every application has different type of rules. There is no master rule which can be fit in all applications. For example you can use same machine learning algorithm across different domains but this is hard for rule based system. You can have some misunderstanding between the linguists team and computer scientists in rule based system. Sometime linguists don't understand the applications and frame too much general or specific rule. Sometime computer Scientists don't trust the linguists.

No comments:

Post a Comment