de.tuebingen.uni.sfs.germanet.api
Class Synset

java.lang.Object
  extended by de.tuebingen.uni.sfs.germanet.api.Synset
All Implemented Interfaces:
java.lang.Comparable

public class Synset
extends java.lang.Object
implements java.lang.Comparable

A Synset belongs to a WordCategory (WordCategory.adj, WordCategory.nomen, WordCategory.verben) and consists of a paraphrase (Strings) and a list of LexUnits. The List of LexUnits is never empty.
A Synset also has the conceptual relations (ConRel), of which hypernymy, hyponymy, meronymy, and holonymy are transitive:

ConRel.has_hypernym, ConRel.has_hyponym,
ConRel.has_component_meronym, ConRel.has_component_holonym,
ConRel.has_member_meronym, ConRel.has_member_holonym,
ConRel.has_substance_meronym, ConRel.has_substance_holonym,
ConRel.has_portion_meronym, ConRel.has_portion_holonym,
ConRel.entails, ConRel.is_entailed_by,
ConRel.is_related_to,
ConRel.causes

Methods are provided to get the WordCategory, paraphrase, and the LexUnits.

Conceptual relations can be retrieved:
   List<Synset> hypernyms = aSynset.getRelatedLexUnits(ConRel.has_hypernym);

Transitive relations can be retrieved:
   List<List<Synset>> meronyms = aSynset.getTransRelatedSynsets(ConRel.meronymy);
which returns a List of Lists, each representing the Synsets found at a depth.

Neighbors (all Synsets that are related to this one) can be retrieved:
   List<Synset> neighbors = aSynset.getRelatedLexUnits();

Unless otherwise stated, methods will return an empty List rather than null to indicate that no objects exist for the given request.


Constructor Summary
protected Synset(int id, WordCategory wordCategory, WordClass wordClass)
          Constructs a Synset with the specified attributes.
 
Method Summary
protected  void addLexUnit(LexUnit lexUnit)
          Adds a LexUnit to this Synset.
protected  void addRelation(ConRel type, Synset target)
          Add a relation of the specified type to target Synset.
 int compareTo(java.lang.Object otherSynset)
          Return 1 if this Synset has a larger id than another Synset, -1 if it has a smaller one.
 boolean equals(Synset other)
          Return true if this Synset is equal to another Synset.
 java.util.List<java.lang.String> getAllOrthForms()
          Returns a List of all (old) orthographic forms and variants contained in all LexUnits of this Synset.
 int getId()
          Return the unique identifier for this Synset.
 java.util.List<IliRecord> getIliRecords()
          Returns a List of all of the IliRecords that this Synset is associated with.
 java.util.List<LexUnit> getLexUnits()
          Returns a List of this Synset's LexUnits.
 java.lang.String getParaphrase()
          Returns this Synset's paraphrase (can be empty).
 java.util.List<java.lang.String> getParaphrases()
          Returns this Synset's paraphrases (can be empty).
 java.util.List<Synset> getRelatedSynsets()
          Returns a List of all of the Synsets that this Synset has any relation to.
 java.util.List<Synset> getRelatedSynsets(ConRel type)
          Returns a List of this Synset's relations of type type.
 java.util.List<java.util.List<Synset>> getTransRelatedSynsets(ConRel type)
          Returns the transitive closure of all relations of type type to this Synset.
 WordCategory getWordCategory()
          Returns the WordCategory that this Synset belongs to.
 WordClass getWordClass()
          Returns the WordClass that this Synset belongs to.
 boolean inWordCategory(WordCategory wordCategory)
          Return true if this Synset is in wordCategory.
 boolean inWordClass(WordClass wordClass)
          Return true if this Synset is in wordClass.
 int numLexUnits()
          Return the number of LexUnits in this Synset.
protected  void setParaphrase(java.lang.String paraphrase)
          Sets the paraphrase of this Synset.
protected  void setWordClass(WordClass wordClass)
          Sets the word class of this Synset.
 java.lang.String toString()
          Returns a String representation of this Synset.
protected  void trimAll()
          Trims all ArrayLists to conserve memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Synset

protected Synset(int id,
                 WordCategory wordCategory,
                 WordClass wordClass)
Constructs a Synset with the specified attributes.

Parameters:
id - unique identifier
wordCategory - the WordCategory of this Synset
wordClass - the WordClass of this Synset
Method Detail

getWordCategory

public WordCategory getWordCategory()
Returns the WordCategory that this Synset belongs to.

Returns:
the WordCategory that this Synset belongs to

getWordClass

public WordClass getWordClass()
Returns the WordClass that this Synset belongs to.

Returns:
the WordClass that this Synset belongs to

inWordCategory

public boolean inWordCategory(WordCategory wordCategory)
Return true if this Synset is in wordCategory.

Parameters:
wordCategory - the WordCategory (eg. nomen, verben, adj)
Returns:
true if this Synset is in wordCategory

inWordClass

public boolean inWordClass(WordClass wordClass)
Return true if this Synset is in wordClass.

Parameters:
wordClass - the WordClass
Returns:
true if this Synset is in wordClass

numLexUnits

public int numLexUnits()
Return the number of LexUnits in this Synset.

Returns:
the number of LexUnits in this Synset

getId

public int getId()
Return the unique identifier for this Synset.

Returns:
the unique identifier for this Synset as it appears in the data files.

addLexUnit

protected void addLexUnit(LexUnit lexUnit)
Adds a LexUnit to this Synset.

Parameters:
lexUnit - the LexUnit to add.

setParaphrase

protected void setParaphrase(java.lang.String paraphrase)
Sets the paraphrase of this Synset.

Parameters:
paraphrase - the paraphrase to set for this Synset

setWordClass

protected void setWordClass(WordClass wordClass)
Sets the word class of this Synset.

Parameters:
wordClass - the word class to set for this Synset

trimAll

protected void trimAll()
Trims all ArrayLists to conserve memory.


getLexUnits

public java.util.List<LexUnit> getLexUnits()
Returns a List of this Synset's LexUnits. This List is never empty.

Returns:
a List of this Synset's LexUnits

getAllOrthForms

public java.util.List<java.lang.String> getAllOrthForms()
Returns a List of all (old) orthographic forms and variants contained in all LexUnits of this Synset. This List is never empty as the List of LexUnits is never empty.

Returns:
a List of all orthographic forms contained in all LexUnits of this Synset

getParaphrase

public java.lang.String getParaphrase()
Returns this Synset's paraphrase (can be empty). This is the paraphrase that was manually added to GermaNet.

Returns:
this Synset's paraphrase

getParaphrases

public java.util.List<java.lang.String> getParaphrases()
Returns this Synset's paraphrases (can be empty). This list contains all paraphrases that were harvested from Wiktionary (this requires a call of GermaNet.loadWiktionaryParaphrases before) as well as GermaNet's manually added paraphrase.

Returns:
this Synset's paraphrases

addRelation

protected void addRelation(ConRel type,
                           Synset target)
Add a relation of the specified type to target Synset.

Parameters:
type - the type of relation (eg. ConRel.has_hypernym)
target - the target Synset

getRelatedSynsets

public java.util.List<Synset> getRelatedSynsets(ConRel type)
Returns a List of this Synset's relations of type type.

Parameters:
type - type of relations to retrieve
Returns:
a List of this Synset's relations of type type For example, hypernyms of this Synset can be retrieved with the type ConRel.has_hypernym

getTransRelatedSynsets

public java.util.List<java.util.List<Synset>> getTransRelatedSynsets(ConRel type)
Returns the transitive closure of all relations of type type to this Synset. A List of Lists of Synsets is returned, where the List at position 0 contains this Synset, the List at position 1 contains the relations at depth 1, the List at position 2 contains the relations at depth 2, and so on up to the maximum depth. The size of the List returned indicates the maximum depth.
Returns an empty List if type is not transitive.

Parameters:
type - the type of relation (e.g. ConRel.has_hypernym).
Returns:
the transitive closure of all relations of type type - a List of Lists of Synsets

getRelatedSynsets

public java.util.List<Synset> getRelatedSynsets()
Returns a List of all of the Synsets that this Synset has any relation to.

Returns:
a List of all of the Synsets that this Synset has any relation to

toString

public java.lang.String toString()
Returns a String representation of this Synset.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this Synset

getIliRecords

public java.util.List<IliRecord> getIliRecords()
Returns a List of all of the IliRecords that this Synset is associated with.

Returns:
a List of all of the IliRecords that this Synset is associated with

equals

public boolean equals(Synset other)
Return true if this Synset is equal to another Synset.

Parameters:
other - the Synset to compare to
Returns:
true if this Synset is equal to another Synset

compareTo

public int compareTo(java.lang.Object otherSynset)
Return 1 if this Synset has a larger id than another Synset, -1 if it has a smaller one.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
otherSynset - the Synset to compare to
Returns:
true if this Synset is equal to another Synset