-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecision-list.pl
59 lines (38 loc) · 2.87 KB
/
decision-list.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
=comment
Programming Assignment 4: Decision Lists
Evan Oman
11/10/2014
Usage:
perl decision-list.pl **Training Data**.txt **Test Data**.txt **Decision List**.txt > **Answers**.txt
Description of Problem:
The goal of this lab is to create a decision list for word sense disambiguation. We are focusing on the specific ambiguity:
WordNet Case 15: telephone line, phone line, telephone circuit, subscriber line, line--- (a telephone connection)
/
line =>
\
WordNet Case 22: line, product line, line of products, line of merchandise, business line, line of business -- (a particular kind of product or merchandise; "a nice line of shoes")
The method used to disambiguate these cases is outlined in David Yarowsky's paper: "DECISION LISTS FOR LEXICAL AMBIGUITY RESOLUTION: Application to Accent Restoration in Spanish and French." There the author uses decision lists in order to properly apply accents in Spanish and French texts but many of the methods outlined are directly applicable to our problem.
We begin by analyzing the given training data using several collocational factors to determine how context correlates to word sense. Once we have recorded counts of how many times a certain factor is associated with each word sense, we sort all of the factors by their log-likelihood defined below:
P(Sense_1 | Collocation_i)
log likelihood = Abs(Log( --------------------------))
P(Sense_2 | Collocation_i)
This equation essentially tells us how correlated some Collocation_i is to one of the two word senses. For example, if there is no correlation, then the P(Accent_Pattern_1 | Collocation_i) and P(Accent_Pattern_2 | Collocation_i) should be pretty close to .5, thus we are taking the log of 1 which is 0. However if some Collocation_i is almost always associated with Accent_Pattern_1, then the log likelihood would be very large.
Once we have this list of collocational factors sorted by their correlation with one of the two senses we can label word senses in some testing data set. For each testing sentence, we iterate through the decision list continuing until some collocational factor applies to the testing sentence and then apply the corresponding word sense to the testing sentence.
=cut
use DecisionList;
main();
sub main
{
chdir "line-data"; #Moves us to the correct directory
local $/; #Enables localized slurp mode
#Grabs the input params
my $trainFile = $ARGV[0];
my $testFile = $ARGV[1];
my $outputFile = $ARGV[2];
#Employs our decision list class which learns from the given data and generates a decision list
$decisionList = new DecisionList($trainFile);
#Here we apply the decision list generated above to the specified test data set
$decisionList->classifyTestData($testFile);
#Prints the decision list for humans to read
$decisionList->printDecisionTree($outputFile);
}