MatchRule15.java
01 package gate.creole.orthomatcher;
02 
03 import gate.Annotation;
04 
05 /**
06  * RULE #14: if the last token of one name
07  * matches the second name
08  * e.g. "Hamish Cunningham" == "Cunningham"
09  * Condition(s): case-insensitive match
10  * Applied to: all person annotations
11  *
12  * Don't need to nicknames here
13  */
14 public class MatchRule15 implements OrthoMatcherRule {
15 
16   OrthoMatcher orthomatcher;
17   
18   public MatchRule15(OrthoMatcher orthmatcher){
19       this.orthomatcher=orthmatcher;
20   }
21   
22   public boolean value(String s1, String s2) {
23     
24     boolean result=false;
25     
26   //  if (s1.equalsIgnoreCase("chin") || s2.equalsIgnoreCase("chin"))
27   //  Out.prln("Rule 14 " + s1 + " and " + s2);
28       String s1_short = (String)
29       ((Annotationorthomatcher.tokensLongAnnot.get(
30           orthomatcher.tokensLongAnnot.size()-1)).getFeatures().get(orthomatcher.TOKEN_STRING_FEATURE_NAME);
31   //  Out.prln("Converted to " + s1_short);
32       if (orthomatcher.tokensLongAnnot.size()>&& OrthoMatcherHelper.straightCompare(s1_short, s2,orthomatcher.caseSensitive)) {
33        if (orthomatcher.log.isDebugEnabled()) {
34          orthomatcher.log.debug("rule 15 matched " + s1 + "(id: " + orthomatcher.longAnnot.getId() ") to "  + s2 
35                   "(id: " + orthomatcher.shortAnnot.getId() ")");
36        }
37         result = true;
38       }
39 
40       if (resultOrthoMatcherHelper.usedRule(15);
41       return result;
42   }
43   
44   public String getId(){
45     return "MatchRule15";
46   }
47 }