Code Search for Developers
 
 
  

WordNetWordSense.java from Texai at Krugle


Show WordNetWordSense.java syntax highlighted

/*
 * WordNetWordSense.java
 *
 * Created on November 10, 2006, 2:51 PM
 *
 * Description: WordNet word sense RDF entity.
 *
 * Copyright (C) 2006 Stephen L. Reed.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package org.texai.wordnet.domain.entity;

import java.util.Set;
import javax.persistence.Id;
import net.jcip.annotations.NotThreadSafe;
import org.openrdf.model.URI;
import org.texai.kb.Constants;
import org.texai.kb.persistence.RDFProperty;
import org.texai.kb.persistence.RDFEntity;
import org.texai.kb.persistence.RDFNamespace;

/** WordNet word sense RDF entity.  This class is not technically thread safe, but client applications should
 * treat it as immutable once loaded.  The field setter methods should not be used nor should the field
 * contents be modified.
 *
 * @author reed
 */
@RDFEntity(
namespaces={
  @RDFNamespace(prefix="texai", namespaceURI=Constants.TEXAI_NAMESPACE),
  @RDFNamespace(prefix="cyc", namespaceURI=Constants.CYC_NAMESPACE)},
subject="cyc:WordNetWordSense",context=Constants.TERM_WORDNET21_DOMAIN_CONTEXT)
@NotThreadSafe  // but effectively immutable
public class WordNetWordSense {                      // NOPMD
  
  /** the range designation WordNetSynset */
  private static final String WORD_NET_SYNSET = "cyc:WordNetSynset";
  
  /** the id assigned by the persistence framework */
  @Id
  private URI id;                                          // NOPMD
  
  /** the object representing the set of synonymous word senses */
  @RDFProperty(predicate="texai:wnWordSenseSynset", range=WORD_NET_SYNSET)
  private WordNetSynset wnWordSenseSynset;    
  
  /** the position of this word sense object within the list of synonymous word senses */
  @RDFProperty(predicate="texai:wnWordSenseSynsetPosition")
  private int wnWordSenseSynsetPosition;     
  
  /** the word for which this object is a meaning sense */
  @RDFProperty(predicate="texai:wnWordSenseWord", range="WordNetEnglishWord")
  private WordNetEnglishWord wnWordSenseWord; 

  /** the cased word for which this object is a meaning sense, or null if not present */
  @RDFProperty(predicate="texai:wnWordSenseCasedWord")
  private WordNetCasedEnglishWord wnWordSenseCasedWord;

  /** the rank of the word sense among all senses for the associated word, with the value one assigned to the most frequent 
   word sense */
  @RDFProperty(predicate="texai:wnWordSenseFrequencyOfUsageRank")
  private int wnWordSenseFrequencyOfUsageRank; 

  /** the one digit hexadecimal integer that, when appended onto the associated lemma, uniquely identifies a sense 
   * within a lexicographer file */
  @RDFProperty(predicate="texai:wnWordSenseLexicographerId")
  private String wnWordSenseLexicographerId; 

  /** the number of times the sense is tagged in various semantic concordance texts */
  @RDFProperty(predicate="texai:wnWordSenseTagCount")
  private int wnWordSenseTagCount;
  
  /** the possibly empty set of verb frames in case this is a verb word sense */
  @RDFProperty(predicate="texai:wnWordSenseVerbFrame")
  private Set<URI> wnWordSenseVerbFrames;   
  
  /** the possibly empty set of sentence patterns */
  @RDFProperty(predicate="texai:wnSentencePattern")
  private Set<WordNetSentencePattern> wnSentencePatterns;  
  
  /** the antonyms */
  @RDFProperty(predicate="cyc:wnAntonym", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnAntonyms; 
  
  /** the also-sees */
  @RDFProperty(predicate="cyc:wnAlsoSee", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnAlsoSees;
  
  /** the participles */
  @RDFProperty(predicate="cyc:wnParticipleOfVerb", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnParticipleOfVerbs;
  
  /** the pertainyms */
  @RDFProperty(predicate="cyc:wnPertainym", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnPertainyms;
  
  /** the derivations */
  @RDFProperty(predicate="cyc:wnDerivedFromAdjective", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnDerivedFromAdjectives;
  
  /** the domain categories */
  @RDFProperty(predicate="cyc:wnCategoryDomain", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnCategoryDomains;
  
  /** the domain member categories */
  @RDFProperty(predicate="texai:wnCategoryDomainMember", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnCategoryDomainMembers; 
  
  /** the domain regions */
  @RDFProperty(predicate="cyc:wnRegionDomain", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnRegionDomains; 
  
  /** the domain member regions */
  @RDFProperty(predicate="texai:wnRegionDomainMember", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnRegionDomainMembers;
  
  /** the domain usages */
  @RDFProperty(predicate="cyc:wnUsageDomain", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnUsageDomains;   
  
  /** the domain member usages */
  @RDFProperty(predicate="texai:wnUsageDomainMember", range=WORD_NET_SYNSET)
  private Set<WordNetWordSense> wnUsageDomainMembers; 
  
  /** Creates a new instance of WordNetWordSense */
  public WordNetWordSense() {
    super();
  }

  /** Creates a new instance of WordNetWordSense.
   *
   * @param wnWordSenseSynset the object representing the set of synonymous word senses
   * @param wnWordSenseSynsetPosition the position of this word sense object within the list of synonymous word senses
   * @param wnWordSenseWord the word for which this object is a meaning sense
   * @param wnWordSenseCasedWord the rank of the word sense among all senses for the associated word, with the value one assigned 
   * to the most frequent word sense
   * @param wnWordSenseFrequencyOfUsageRank the one digit hexadecimal integer that, when appended onto lemma , uniquely identifies 
   * a sense within a lexicographer file
   * @param wnWordSenseLexicographerId the one digit hexadecimal integer that, when appended onto lemma , uniquely identifies a sense
   * within a lexicographer file
   * @param wnWordSenseTagCount the number of times the sense is tagged in various semantic concordance texts
   * @param wnWordSenseVerbFrames the possibly empty set of verb frames in case this is a verb word sense
   * @param wnSentencePatterns the possibly empty set of sentence patterns
   */
  public WordNetWordSense(
          final WordNetSynset wnWordSenseSynset,
          final int wnWordSenseSynsetPosition,
          final WordNetEnglishWord wnWordSenseWord,
          final WordNetCasedEnglishWord wnWordSenseCasedWord,
          final int wnWordSenseFrequencyOfUsageRank,
          final String wnWordSenseLexicographerId,
          final int wnWordSenseTagCount,
          final Set<URI> wnWordSenseVerbFrames,
          final Set<WordNetSentencePattern> wnSentencePatterns) {
    super();
    //Preconditions
    assert wnWordSenseSynset != null : "wnWordSenseSynset must not be null";
    assert wnWordSenseWord != null : "wnWordSenseWord must not be null";
    assert wnWordSenseLexicographerId != null : "wnWordSenseLexicographerId must not be null";
    assert wnWordSenseVerbFrames != null : "wnWordSenseVerbFrames must not be null";
    assert wnSentencePatterns != null : "wnSentencePatterns must not be null";
    
    this.wnWordSenseSynset = wnWordSenseSynset;
    this.wnWordSenseSynsetPosition = wnWordSenseSynsetPosition;
    this.wnWordSenseWord = wnWordSenseWord;
    this.wnWordSenseCasedWord = wnWordSenseCasedWord;
    this.wnWordSenseFrequencyOfUsageRank = wnWordSenseFrequencyOfUsageRank;
    this.wnWordSenseLexicographerId = wnWordSenseLexicographerId;
    this.wnWordSenseTagCount = wnWordSenseTagCount;
    this.wnWordSenseVerbFrames = wnWordSenseVerbFrames;
    this.wnSentencePatterns = wnSentencePatterns;
  }

  /** Returns a hash code value for the object.
   *
   * @return a hash code value for this object.
   */
  @Override
  public int hashCode() {
    return getId().hashCode();
  }

  /** Determines whether another object is equal to this WordNetSynset.
   * 
   * @param object the reference object with which to compare
   * @return <code>true</code> if this object is the same as the argument;
   * <code>false</code> otherwise.
   */
  @Override
  public boolean equals(final Object object) {
    if (!(object instanceof WordNetWordSense)) {
      return false;
    }
    final WordNetWordSense that = (WordNetWordSense) object;
    return this.getId().equals(that.getId());
  }

  /** Gets the id.
   *
   * @return the id
   */
  public URI getId() {
    return id;
  }
  
  /** Gets the object representing the set of synonymous word senses.
   *
   * @return the object representing the set of synonymous word senses
   */
  public WordNetSynset getWordNetSynset() {
    return wnWordSenseSynset;
  }

  /** Gets the position of this word sense object within the list of synonymous word senses.
   *
   * @return the position of this word sense object within the list of synonymous word senses
   */
  public int getWNWordSenseSynsetPosition() {
    return wnWordSenseSynsetPosition;
  }

  /** Gets the word for which this object is a meaning sense.
   *
   * @return the word for which this object is a meaning sense
   */
  public WordNetEnglishWord getWordNetEnglishWord() {
    return wnWordSenseWord;
  }

  /** Gets the cased word for which this object is a meaning sense, or null if not present.
   *
   * @return the cased word for which this object is a meaning sense, or null if not present
   */
  public WordNetCasedEnglishWord getWordNetCasedEnglishWord() {
    return wnWordSenseCasedWord;
  }

  /** Gets the rank of the word sense among all senses for the associated word, with the value one assigned to the most frequent 
   word sense.
   *
   * @return the rank of the word sense among all senses for the associated word, with the value one assigned to the most frequent 
   word sense
   */
  public int getWNWordSenseFrequencyOfUsageRank() {
    return wnWordSenseFrequencyOfUsageRank;
  }

  /** Gets the one digit hexadecimal integer that, when appended onto lemma , uniquely identifies a sense within a lexicographer file.
   *
   * @return the one digit hexadecimal integer that, when appended onto lemma , uniquely identifies a sense within a lexicographer file
   */
  public String getWNWordSenseLexicographerId() {
    return wnWordSenseLexicographerId;
  }

  /** Gets the number of times the sense is tagged in various semantic concordance texts, or null if not present.
   *
   * @return the number of times the sense is tagged in various semantic concordance texts
   */
  public int getWNWordSenseTagCount() {
    return wnWordSenseTagCount;
  }
  
  /** Gets the possibly empty set of verb frames in case this is a verb word sense.
   *
   * @return the possibly empty set of verb frames in case this is a verb word sense
   */
  public Set<URI> getWNWordSenseVerbFrames() {
    return wnWordSenseVerbFrames;
  }

  /** Gets the possibly empty set of sentence patterns.
   *
   * @return the possibly empty set of sentence patterns
   */
  public Set<WordNetSentencePattern> getWNSentencePatterns() {
    return wnSentencePatterns;
  }
  
  /** Gets the antonyms.
   *
   * @return the antonyms
   */
  public Set<WordNetWordSense> getWNAntonyms() {
    return wnAntonyms;
  }

  /** Sets the antonyms.
   *
   * @param wnAntonyms the antonyms
   */
  public void setWNAntonyms(final Set<WordNetWordSense> wnAntonyms) {
    this.wnAntonyms = wnAntonyms;
  }

  /** Gets the also-sees.
   *
   * @return the also-sees
   */
  public Set<WordNetWordSense> getWNAlsoSees() {
    return wnAlsoSees;
  }

  /** Sets the also-sees.
   *
   * @param wnAlsoSees the also-sees
   */
  public void setWNAlsoSees(final Set<WordNetWordSense> wnAlsoSees) {
    this.wnAlsoSees = wnAlsoSees;
  }

  /** Gets the participles.
   *
   * @return the participles
   */
  public Set<WordNetWordSense> getWNParticipleOfVerbs() {
    return wnParticipleOfVerbs;
  }

  /** Sets the participles.
   *
   * @param wnParticipleOfVerbs the participles
   */
  public void setWNParticipleOfVerbs(final Set<WordNetWordSense> wnParticipleOfVerbs) {
    this.wnParticipleOfVerbs = wnParticipleOfVerbs;
  }

  /** Gets the pertainyms.
   *
   * @return the pertainyms
   */
  public Set<WordNetWordSense> getWNPertainyms() {
    return wnPertainyms;
  }

  /** Sets the pertainyms.
   *
   * @param wnPertainyms the pertainyms
   */
  public void setWNPertainyms(final Set<WordNetWordSense> wnPertainyms) {
    this.wnPertainyms = wnPertainyms;
  }

  /** Gets the derivations.
   *
   * @return the derivations
   */
  public Set<WordNetWordSense> getWNDerivedFromAdjectives() {
    return wnDerivedFromAdjectives;
  }

  /** Sets the derivations.
   *
   * @param wnDerivedFromAdjectives the derivations
   */
  public void setWNDerivedFromAdjectives(final Set<WordNetWordSense> wnDerivedFromAdjectives) {
    this.wnDerivedFromAdjectives = wnDerivedFromAdjectives;
  }

  /** Gets the domain categories.
   *
   * @return the domain categories
   */
  public Set<WordNetWordSense> getWNCategoryDomains() {
    return wnCategoryDomains;
  }

  /** Sets domain categories.
   *
   * @param wnCategoryDomains domain categories
   */
  public void setWNCategoryDomains(final Set<WordNetWordSense> wnCategoryDomains) {
    //Preconditions
    assert wnCategoryDomains != null : "wnCategoryDomains must not be null";
    
    this.wnCategoryDomains = wnCategoryDomains;
  }

  /** Gets the domain member categories.
   *
   * @return the domain member categories
   */
  public Set<WordNetWordSense> getWNCategoryDomainMembers() {
    return wnCategoryDomainMembers;
  }

  /** Sets the domain member categories.
   *
   * @param wnCategoryDomainMembers the domain member categories
   */
  public void setWNCategoryDomainMembers(final Set<WordNetWordSense> wnCategoryDomainMembers) {
    //Preconditions
    assert wnCategoryDomainMembers != null : "wnCategoryDomainMembers must not be null";
    
    this.wnCategoryDomainMembers = wnCategoryDomainMembers;
  }

  /** Gets the domain regions.
   *
   * @return the domain regions
   */
  public Set<WordNetWordSense> getWNRegionDomains() {
    return wnRegionDomains;
  }

  /** Sets the domain regions.
   *
   * @param wnRegionDomains the domain regions
   */
  public void setWNRegionDomains(final Set<WordNetWordSense> wnRegionDomains) {
    //Preconditions
    assert wnRegionDomains != null : "wnRegionDomains must not be null";
    
    this.wnRegionDomains = wnRegionDomains;
  }

  /** Gets the domain member regions.
   *
   * @return the domain member regions
   */
  public Set<WordNetWordSense> getWNRegionDomainMembers() {
    return wnRegionDomainMembers;
  }

  /** Sets the domain member regions.
   *
   * @param wnRegionDomainMembers the domain member regions
   */
  public void setWNRegionDomainMembers(final Set<WordNetWordSense> wnRegionDomainMembers) {
    //Preconditions
    assert wnRegionDomainMembers != null : "wnRegionDomainMembers must not be null";
    
    this.wnRegionDomainMembers = wnRegionDomainMembers;
  }

  /** Gets the domain usages.
   *
   * @return the domain usages
   */
  public Set<WordNetWordSense> getWNUsageDomains() {
    return wnUsageDomains;
  }

  /** Sets the domain usages.
   *
   * @param wnUsageDomains the domain usages
   */
  public void setWNUsageDomains(final Set<WordNetWordSense> wnUsageDomains) {
    //Preconditions
    assert wnUsageDomains != null : "wnUsageDomains must not be null";
    
    this.wnUsageDomains = wnUsageDomains;
  }

  /** Gets the domain member usages.
   *
   * @return the domain member usages
   */
  public Set<WordNetWordSense> getWNUsageDomainMembers() {
    return wnUsageDomainMembers;
  }

  /** Sets the domain member usages.
   *
   * @param wnUsageDomainMembers the domain member usages
   */
  public void setWNUsageDomainMembers(final Set<WordNetWordSense> wnUsageDomainMembers) {
    //Preconditions
    assert wnUsageDomainMembers != null : "wnUsageDomainMembers must not be null";
    
    this.wnUsageDomainMembers = wnUsageDomainMembers;
  }

  /** Returns a description of this word sense.
   *
   * @return a description of this word sense
   */
  public String description() {
    final StringBuilder stringBuilder = new StringBuilder(Constants.STRING_BUILDER_SIZE);
    stringBuilder.append(wnWordSenseSynset.getWNSynsetSpeechPart().toString().toLowerCase());
    stringBuilder.append(':');
    stringBuilder.append(this.getWordNetEnglishWord().getWNLemma());
    return  stringBuilder.toString();
  }
  
}




See more files for this project here

Texai

Texai is an chatbot that intelligently seeks to acquire knowledge and friendly behaviors.

Project homepage: http://sourceforge.net/projects/texai
Programming language(s): Java,Shell Script,XML
License: other

  ValidateWordNetEntities.java
  WordNetCasedEnglishWord.java
  WordNetCategory.java
  WordNetEnglishWord.java
  WordNetEnglishWordMorph.java
  WordNetSamplePhraseItem.java
  WordNetSentencePattern.java
  WordNetSynset.java
  WordNetWordSense.java