1   /*
2    *  Synset.java
3    *
4    *  Copyright (c) 1998-2005, 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.8 2005/01/11 13:51:38 ian Exp $
14   */
15  
16  package gate.wordnet;
17  
18  
19  class RelationImpl implements Relation {
20  
21    private int type;
22  
23    /** never use directly - instantiate one of the ancestors only */
24    protected RelationImpl(int _type) {
25      this.type = _type;
26    }
27  
28  
29    /** returns the type of the relation - one of REL_XXX*/
30    public int getType() {
31      return this.type;
32    }
33  
34  
35    /** returns a symbol for the relation, e.g. "@" */
36    public String getSymbol() {
37      return WNHelper.int2PointerType(this.type).getKey();
38    }
39  
40  
41    /** returns a label for the relation, e.g. "HYPERNYM" */
42    public String getLabel() {
43      return WNHelper.int2PointerType(this.type).getLabel();
44    }
45  
46  
47    /** returns the inverse relation (Hyponym  <-> Hypernym, etc)*/
48    public int getInverseType() {
49  
50      switch(this.type) {
51  
52        case Relation.REL_ANTONYM:
53          return Relation.REL_ANTONYM;
54  
55        case Relation.REL_HYPONYM:
56          return Relation.REL_HYPERNYM;
57  
58        case Relation.REL_HYPERNYM:
59          return Relation.REL_HYPONYM;
60  
61        case Relation.REL_MEMBER_HOLONYM:
62          return Relation.REL_MEMBER_MERONYM;
63  
64        case Relation.REL_MEMBER_MERONYM:
65          return Relation.REL_MEMBER_HOLONYM;
66  
67        case Relation.REL_SIMILAR_TO:
68          return Relation.REL_SIMILAR_TO;
69  
70        case Relation.REL_ATTRIBUTE:
71          return Relation.REL_ATTRIBUTE;
72  
73        case Relation.REL_VERB_GROUP:
74          return Relation.REL_VERB_GROUP;
75  
76        default:
77          return -1;
78      }
79    }
80  
81  
82    /** checks if the relation is applicab;le to specific POS - see REL_XXX comments */
83    public boolean isApplicableTo(int pos) {
84      return WNHelper.int2PointerType(this.type).appliesTo(WNHelper.int2POS(pos));
85    }
86  
87  }