gov.llnl.ontology.wordnet
Class BaseSynset

java.lang.Object
  extended by gov.llnl.ontology.wordnet.BaseSynset
All Implemented Interfaces:
Synset

public class BaseSynset
extends Object
implements Synset

The core Synset implementation when interfacing directly with the word net dictionary files. This implementation satisfies all of the requirements of a Synset and allows the Synset to be re-serialized in the proper word net form.

Author:
Keith Stevens

Nested Class Summary
 
Nested classes/interfaces inherited from interface gov.llnl.ontology.wordnet.Synset
Synset.PartsOfSpeech, Synset.Relation
 
Constructor Summary
BaseSynset(int offset, Synset.PartsOfSpeech pos)
          Creates a BaseSynset with a byte offset value.
BaseSynset(String synsetName)
          Creates a BaseSynset with a byte offset value.
BaseSynset(Synset.PartsOfSpeech pos)
          Creates an empty BaseSynset.
 
Method Summary
 void addDerivationallyRelatedForm(Synset related, RelatedForm form)
          Adds a RelatedForm to this Synset, signifiying that the two Synsets share a Lemma that are closely related.
 void addExample(String example)
          Adds an example sentence detailing how this lemmas for this Synset are used in everday speech.
 void addLemma(Lemma lemma)
          Adds a Lemma to this Synset.
 void addMorphyMapping(String original, String lemma)
          
 boolean addRelation(String relation, Synset synset)
          Returns true if a new relation is added between this and related by relation.
 boolean addRelation(Synset.Relation relation, Synset synset)
          Returns true if a new relation is added between this and related by relation.
 void addSenseKey(String senseKey)
          Sets the unique sense key string.
 Collection<Synset> allRelations()
          Returns the set of all Synsets that are connected to this Synset, regardless of the relation type.
 Set<String> attributeLabels()
          Returns the set of Attribute keys currently held by this Synset.
 Attribute getAttribute(String attributeName)
          Returns the Attribute associated with the label attributeName applied to this Synset, or null if there is no associated attribute.
 Set<Synset> getChildren()
          Returns the Synsets that are more specific concepts of this Synset.
 String getDefinition()
          Returns the dictionary definition of this Synset
 RelatedForm getDerivationallyRelatedForm(Synset synset)
          Returns a if the provided Synset has a Lemma which is a derivationally related form of a Lemma from this Synset, or null if there is no relation.
 List<String> getExamples()
          Returns the set of example sentences which explain how this Synset is used in regular text.
 int[] getFrameIds()
          Returns the frame indices for all known verb frames for this synset.
 String getGloss()
          Returns the complete gloss, i.e., all definitions and examples.
 int getId()
          Returns the integer identifier used to initially reference this synset within the WordNet dictionary files.
 Set<String> getKnownRelationTypes()
          Returns the set of relation keys that this Synset has with other Synsets.
 int[] getLemmaIds()
          Returns the lemma indices for all known verb frames for this synset.
 List<Lemma> getLemmas()
          Returns the list of Lemmas that correspond to this Synset.
 int getMaxDepth()
          Returns the maximum distance between this Synset and the root Synset.
 int getMinDepth()
          Returns the minimum distance between this Synset and the root Synset.
 String getName()
          Returns a unique string that identifies this Synset.
 int getNumRelations()
          Returns the total number of known relations for this synset.
 List<List<Synset>> getParentPaths()
          Returns a list of all paths from the current Synset to the root of the IS-A hierarchy.
 Set<Synset> getParents()
          Returns the Synsets that are generalized concepts of this Synset.
 Synset.PartsOfSpeech getPartOfSpeech()
          Returns the Synset.PartsOfSpeech attributed to this Synset
 Set<Synset> getRelations(String relation)
          Returns the set of Synsets that are connected to this Synset through the specified relation string.
 Set<Synset> getRelations(Synset.Relation relation)
          Returns the set of Synsets that are connected to this Synset through the specified Synset.Relation.
 String getSenseKey()
          Returns the first unique string that identifies this Synset based on it's part of speech, lexicographer file assignment and index in the lexicographer's file.
 String getSenseKey(String base)
          Returns a unique string that identifies this Synset based on it's part of speech, the base query term, the lexicographer file assignment and index in the lexicographer's file.
 List<String> getSenseKeys()
          Returns all sense keys associated with this Synset.
 int getSenseNumber()
          Returns the sense number for this Synset.
 void merge(Synset synset)
          Merges this Synset with the provided Synset.
 boolean removeRelation(String relation, Synset synset)
          Returns true if a relation between this and related by the link relation was removed.
 boolean removeRelation(Synset.Relation relation, Synset synset)
          Returns true if a relation between this and related by the link relation was removed.
 void setAttribute(String attributeName, Attribute attribute)
          Sets attribute as an object that described this Synset with more detail.
 void setDefinition(String definition)
          Sets dictionary definition for this Synset.
 void setFrameInfo(int[] frameIds, int[] lemmaIds)
          Sets the indices for frames and lemmas for this synset.
 void setId(int newOffset)
          Sets the id for a given Synset.
 void setSenseNumber(int senseNumber)
          Sets the sense number for this Synset.
 String toString()
          Returns this Synsets name and gloss.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseSynset

public BaseSynset(String synsetName)
Creates a BaseSynset with a byte offset value.


BaseSynset

public BaseSynset(int offset,
                  Synset.PartsOfSpeech pos)
Creates a BaseSynset with a byte offset value.


BaseSynset

public BaseSynset(Synset.PartsOfSpeech pos)
Creates an empty BaseSynset.

Method Detail

addMorphyMapping

public void addMorphyMapping(String original,
                             String lemma)

Specified by:
addMorphyMapping in interface Synset

getSenseNumber

public int getSenseNumber()
Returns the sense number for this Synset. Sense numbers may be modified whenever a Synset is added, removed, or merged.

Specified by:
getSenseNumber in interface Synset

setSenseNumber

public void setSenseNumber(int senseNumber)
Sets the sense number for this Synset. Sense numbers may be modified whenever a Synset is added, removed, or merged.

Specified by:
setSenseNumber in interface Synset

getName

public String getName()
Returns a unique string that identifies this Synset. This name should be based on one of the Synset's lemmas, the part of speech, and the sense number for this Synset. For example, "cat.n.01" signifies that the Synset is a noun and corresponds to the first sense of the "cat" Lemma.

Specified by:
getName in interface Synset

getSenseKey

public String getSenseKey()
Returns the first unique string that identifies this Synset based on it's part of speech, lexicographer file assignment and index in the lexicographer's file. This is often the same as the lemma key of the Synset's first Lemma.

Specified by:
getSenseKey in interface Synset

getSenseKey

public String getSenseKey(String base)
Returns a unique string that identifies this Synset based on it's part of speech, the base query term, the lexicographer file assignment and index in the lexicographer's file. This is often the same as the lemma key of the Synset's first Lemma.

Specified by:
getSenseKey in interface Synset

getSenseKeys

public List<String> getSenseKeys()
Returns all sense keys associated with this Synset.

Specified by:
getSenseKeys in interface Synset

addSenseKey

public void addSenseKey(String senseKey)
Sets the unique sense key string.

Specified by:
addSenseKey in interface Synset

getDefinition

public String getDefinition()
Returns the dictionary definition of this Synset

Specified by:
getDefinition in interface Synset

getPartOfSpeech

public Synset.PartsOfSpeech getPartOfSpeech()
Returns the Synset.PartsOfSpeech attributed to this Synset

Specified by:
getPartOfSpeech in interface Synset

getLemmas

public List<Lemma> getLemmas()
Returns the list of Lemmas that correspond to this Synset.

Specified by:
getLemmas in interface Synset

getExamples

public List<String> getExamples()
Returns the set of example sentences which explain how this Synset is used in regular text.

Specified by:
getExamples in interface Synset

getDerivationallyRelatedForm

public RelatedForm getDerivationallyRelatedForm(Synset synset)
Returns a if the provided Synset has a Lemma which is a derivationally related form of a Lemma from this Synset, or null if there is no relation.

Specified by:
getDerivationallyRelatedForm in interface Synset

getKnownRelationTypes

public Set<String> getKnownRelationTypes()
Returns the set of relation keys that this Synset has with other Synsets. In general these keys will be string versions of Synset.Relations.

Specified by:
getKnownRelationTypes in interface Synset

allRelations

public Collection<Synset> allRelations()
Returns the set of all Synsets that are connected to this Synset, regardless of the relation type.

Specified by:
allRelations in interface Synset

getRelations

public Set<Synset> getRelations(String relation)
Returns the set of Synsets that are connected to this Synset through the specified relation string.

Specified by:
getRelations in interface Synset

getRelations

public Set<Synset> getRelations(Synset.Relation relation)
Returns the set of Synsets that are connected to this Synset through the specified Synset.Relation.

Specified by:
getRelations in interface Synset

getNumRelations

public int getNumRelations()
Returns the total number of known relations for this synset.

Specified by:
getNumRelations in interface Synset

getParentPaths

public List<List<Synset>> getParentPaths()
Returns a list of all paths from the current Synset to the root of the IS-A hierarchy. Since every Synset can have multiple parents, there may be multiple paths that have several commond Synsets. The parent paths will begin a the Synset that is furthest from this Synset and end with this Synset.

Specified by:
getParentPaths in interface Synset

getParents

public Set<Synset> getParents()
Returns the Synsets that are generalized concepts of this Synset. This is equivalent to calling getRelations() with Relation:HYPERNYM.

Specified by:
getParents in interface Synset

getChildren

public Set<Synset> getChildren()
Returns the Synsets that are more specific concepts of this Synset. This is equivalent to calling getRelations() with Relation:HYPONYM.

Specified by:
getChildren in interface Synset

getId

public int getId()
Returns the integer identifier used to initially reference this synset within the WordNet dictionary files. Any Synsets that are added to the dictionary during runtime may return an id of 0. Note that this value is only needed for corpus readers.

Specified by:
getId in interface Synset

getFrameIds

public int[] getFrameIds()
Returns the frame indices for all known verb frames for this synset.

Specified by:
getFrameIds in interface Synset

getLemmaIds

public int[] getLemmaIds()
Returns the lemma indices for all known verb frames for this synset.

Specified by:
getLemmaIds in interface Synset

setFrameInfo

public void setFrameInfo(int[] frameIds,
                         int[] lemmaIds)
Sets the indices for frames and lemmas for this synset.

Specified by:
setFrameInfo in interface Synset

setId

public void setId(int newOffset)
Sets the id for a given Synset. Only corpus readers need to set this value.

Specified by:
setId in interface Synset

setDefinition

public void setDefinition(String definition)
Sets dictionary definition for this Synset.

Specified by:
setDefinition in interface Synset

addLemma

public void addLemma(Lemma lemma)
Adds a Lemma to this Synset. Lemmas may be added in order according to their precedence for the Synset.

Specified by:
addLemma in interface Synset

addExample

public void addExample(String example)
Adds an example sentence detailing how this lemmas for this Synset are used in everday speech.

Specified by:
addExample in interface Synset

addDerivationallyRelatedForm

public void addDerivationallyRelatedForm(Synset related,
                                         RelatedForm form)
Adds a RelatedForm to this Synset, signifiying that the two Synsets share a Lemma that are closely related.

Specified by:
addDerivationallyRelatedForm in interface Synset

addRelation

public boolean addRelation(Synset.Relation relation,
                           Synset synset)
Returns true if a new relation is added between this and related by relation. Returning false signifies that the relation already exists.

Specified by:
addRelation in interface Synset

addRelation

public boolean addRelation(String relation,
                           Synset synset)
Returns true if a new relation is added between this and related by relation. Returning false signifies that the relation already exists.

Specified by:
addRelation in interface Synset

removeRelation

public boolean removeRelation(Synset.Relation relation,
                              Synset synset)
Returns true if a relation between this and related by the link relation was removed. Returning false signifies that there was no link to remove.

Specified by:
removeRelation in interface Synset

removeRelation

public boolean removeRelation(String relation,
                              Synset synset)
Returns true if a relation between this and related by the link relation was removed. Returning false signifies that there was no link to remove.

Specified by:
removeRelation in interface Synset

getGloss

public String getGloss()
Returns the complete gloss, i.e., all definitions and examples.

Specified by:
getGloss in interface Synset

getMaxDepth

public int getMaxDepth()
Returns the maximum distance between this Synset and the root Synset.

Specified by:
getMaxDepth in interface Synset

getMinDepth

public int getMinDepth()
Returns the minimum distance between this Synset and the root Synset.

Specified by:
getMinDepth in interface Synset

setAttribute

public void setAttribute(String attributeName,
                         Attribute attribute)
Sets attribute as an object that described this Synset with more detail. attributeName is a label for the provided attribute.

Specified by:
setAttribute in interface Synset

getAttribute

public Attribute getAttribute(String attributeName)
Returns the Attribute associated with the label attributeName applied to this Synset, or null if there is no associated attribute.

Specified by:
getAttribute in interface Synset

attributeLabels

public Set<String> attributeLabels()
Returns the set of Attribute keys currently held by this Synset.

Specified by:
attributeLabels in interface Synset

merge

public void merge(Synset synset)
Merges this Synset with the provided Synset.

Specified by:
merge in interface Synset

toString

public String toString()
Returns this Synsets name and gloss.

Overrides:
toString in class Object


Copyright © 2010-2011. All Rights Reserved.