1   /*
2    *  Synset.java
3    *
4    *  Copyright (c) 1998-2002, The University of Sheffield.
5    *
6    *  This file is part of GATE (see http://gate.ac.uk/), and is free
7    *  software, licenced under the GNU Library General Public License,
8    *  Version 2, June 1991 (in the distribution as file licence.html,
9    *  and also available at http://gate.ac.uk/gate/licence.html).
10   *
11   *  Marin Dimitrov, 16/May/2002
12   *
13   *  $Id: RelationImpl.java,v 1.5 2002/05/30 09:54:17 marin Exp $
14   */
15  
16  package gate.wordnet;
17  
18  import gate.util.*;
19  
20  class RelationImpl implements Relation {
21  
22    private int type;
23  
24    /** never use directly - instantiate one of the ancestors only */
25    protected RelationImpl(int _type) {
26      this.type = _type;
27    }
28  
29  
30    /** returns the type of the relation - one of REL_XXX*/
31    public int getType() {
32      return this.type;
33    }
34  
35  
36    /** returns a symbol for the relation, e.g. "@" */
37    public String getSymbol() {
38      return WNHelper.int2PointerType(this.type).getKey();
39    }
40  
41  
42    /** returns a label for the relation, e.g. "HYPERNYM" */
43    public String getLabel() {
44      return WNHelper.int2PointerType(this.type).getLabel();
45    }
46  
47  
48    /** returns the inverse relation (Hyponym  <-> Hypernym, etc)*/
49    public int getInverseType() {
50  
51      switch(this.type) {
52  
53        case Relation.REL_ANTONYM:
54          return Relation.REL_ANTONYM;
55  
56        case Relation.REL_HYPONYM:
57          return Relation.REL_HYPERNYM;
58  
59        case Relation.REL_HYPERNYM:
60          return Relation.REL_HYPONYM;
61  
62        case Relation.REL_MEMBER_HOLONYM:
63          return Relation.REL_MEMBER_MERONYM;
64  
65        case Relation.REL_MEMBER_MERONYM:
66          return Relation.REL_MEMBER_HOLONYM;
67  
68        case Relation.REL_SIMILAR_TO:
69          return Relation.REL_SIMILAR_TO;
70  
71        case Relation.REL_ATTRIBUTE:
72          return Relation.REL_ATTRIBUTE;
73  
74        case Relation.REL_VERB_GROUP:
75          return Relation.REL_VERB_GROUP;
76  
77        default:
78          return -1;
79      }
80    }
81  
82  
83    /** checks if the relation is applicab;le to specific POS - see REL_XXX comments */
84    public boolean isApplicableTo(int pos) {
85      return WNHelper.int2PointerType(this.type).appliesTo(WNHelper.int2POS(pos));
86    }
87  
88  }