1
16
17
25
26 package hepple.postag;
27
28 import java.util.*;
29
30 public abstract class Rule {
31
32 protected String from;
33 protected String to;
34 protected String ruleId;
35 protected String[] context;
36
37 public void initialise(List ruleParts) {
38 from = (String)ruleParts.get(0);
39 to = (String)ruleParts.get(1);
40 ruleId = (String)ruleParts.get(2);
41 int contextSize = ruleParts.size() - 3;
42 context = new String[contextSize];
43 for (int i=0 ; i<contextSize ; i++) context[i] = (String)ruleParts.get(i+3);
44 }
45
46 abstract public boolean checkContext(POSTagger tagger);
47
48 public boolean hasToTag(POSTagger tagger) {
49 for (int i=0 ; i<tagger.lexBuff[3].length ; i++)
50 if (to.equals(tagger.lexBuff[3][i])) return true;
51 return false;
52 }
54 public boolean apply(POSTagger tagger) {
55 if (hasToTag(tagger) && checkContext(tagger)) {
56 tagger.tagBuff[3] = to;
57 return true;
58 }else return false;
59 }
61 }