TexaiEnglishWordSense.java from Texai at Krugle
Show TexaiEnglishWordSense.java syntax highlighted
/*
* TexaiEnglishWordSense.java
*
* Created on February 28, 2007, 8:47 PM
*
* Description: Provides domain entities that contain word senses.
*
* Copyright (C) 2007 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.lexicon.domainEntity;
import java.util.Set;
import javax.persistence.Id;
import org.texai.kb.Constants;
import org.texai.kb.ejb.entity.AbstractReifiedTerm;
import org.texai.kb.ejb.entity.AtomicTerm;
import org.texai.kb.persistence.DomainEntity;
import org.texai.kb.persistence.DomainProperty;
import org.texai.wiktionary.domainEntity.WiktionaryEnglishWordSense;
import org.texai.wordnet.domain.entity.WordNetCategory;
import org.texai.wordnet.domain.entity.WordNetSynset;
/**
*
* @author reed
*/
@DomainEntity(typeOf="LinguisticObjectType", subClassOf="WordSense")
public class TexaiEnglishWordSense {
/** the term id inserted by the container */
@Id
private Long termId; // NOPMD
/** the word sense position in the list of word senses for the word */
@DomainProperty(name="texaiWordSensePosition", range="PositiveInteger", functional=true)
private int position; // NOPMD
/** the part of speech */
@DomainProperty(name="texaiWordSenseSpeechPart", functional=true)
private AtomicTerm speechPart;
/** the basic part of speech for open class words, one of Noun, Verb, Adjective or Adverb, or null if not applicable */
@DomainProperty(name="texaiWordSenseBasicSpeechPart", functional=true)
private AtomicTerm basicSpeechPart;
/** the sense number */
@DomainProperty(name="texaiWordSenseNumber", range="PositiveInteger", functional=true)
private int wordSenseNbr; // NOPMD
/** the word sense definitions */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_WORD_SENSE_GLOSS, range="CharacterString")
private Set<String> glosses;
/** the set of sample phrases */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_WORD_SENSE_SAMPLE_PHRASE, range="org.texai.lexicon.domainEntity.TexaiSamplePhrase")
private Set<TexaiSamplePhrase> texaiSamplePhrases;
/** the English word for which this is a word sense */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_ENGLISH_WORD_SENSE_FOR_WORD, functional=true)
private TexaiEnglishWord texaiEnglishWord;
/** the mapped term or null if not present */
@DomainProperty(name="texaiWordSenseMappedTerm")
private AbstractReifiedTerm texaiMappedTerm;
/** the set of Wiktionary category names */
@DomainProperty(name="texaiWordSenseCategoryName", range="CharacterString")
private Set<String> categoryNames;
/** the WordNet category or null if not present */
@DomainProperty(subPropertyOf="genls")
private WordNetCategory wordNetCategory;
/** the WordNet synset or null if not present */
@DomainProperty(name="texaiWordSenseWordNetSynset")
private WordNetSynset wordNetSynset;
/** the Wiktionary word sense or null if not present */
@DomainProperty(name="texaiWiktionaryWordSense")
private WiktionaryEnglishWordSense wiktionaryEnglishWordSense;
/** the indicator whether this is an OpenCyc word sense */
@DomainProperty(trueClass="TexaiEnglishWordSense-IsOpenCyc", falseClass="TexaiEnglishWordSense-IsNotOpenCyc")
private boolean isOpenCycWordSense;
/** Creates a new instance of TexaiEnglishWordSense. */
public TexaiEnglishWordSense() {
super();
}
/** Creates a new instance of TexaiEnglishWordSense.
*
* @param position the word sense position in the list of word senses for the word
* @param speechPart the part of speech
* @param basicSpeechPart the basic part of speech for open class words, one of Noun, Verb, Adjective or Adverb, or null if not applicable
* @param wordSenseNbr the sense number within basic speech part
* @param glosses the word sense definitions
* @param texaiSamplePhrases the set of sample phrases
* @param texaiEnglishWord the English word for which this is a word sense
* @param texaiMappedTerm the mapped term or null if not present
* @param categoryNames the set of Wiktionary category names
* @param wordNetCategory the WordNet category or null if not present
* @param wordNetSynset the WordNet synset or null if not present
* @param wiktionaryWordSense the Wiktionary word sense or null if not present
* @param isOpenCycWordSense the indicator whether this is an OpenCyc word sense
*/
public TexaiEnglishWordSense(
final int position,
final AtomicTerm speechPart,
final AtomicTerm basicSpeechPart,
final int wordSenseNbr,
final Set<String> glosses,
final Set<TexaiSamplePhrase> texaiSamplePhrases,
final TexaiEnglishWord texaiEnglishWord,
final AbstractReifiedTerm texaiMappedTerm,
final Set<String> categoryNames,
final WordNetCategory wordNetCategory,
final WordNetSynset wordNetSynset,
final WiktionaryEnglishWordSense wiktionaryEnglishWordSense,
final boolean isOpenCycWordSense) {
super();
//Preconditions
assert position > 0 : "position must be positive";
assert speechPart != null : "speechPart must not be null";
assert wordSenseNbr > 0 : "wordSenseNbr must be positive";
assert glosses != null : "glosses must not be null";
assert texaiSamplePhrases != null : "texaiSamplePhrases must not be null";
assert texaiEnglishWord != null : "texaiEnglishWord must not be null";
assert categoryNames != null : "categoryNames must not be null";
this.position = position;
this.speechPart = speechPart;
this.basicSpeechPart = basicSpeechPart;
this.wordSenseNbr = wordSenseNbr;
this.glosses = glosses;
this.texaiSamplePhrases = texaiSamplePhrases;
this.texaiEnglishWord = texaiEnglishWord;
this.texaiMappedTerm = texaiMappedTerm;
this.categoryNames = categoryNames;
this.wordNetCategory = wordNetCategory;
this.wordNetSynset = wordNetSynset;
this.wiktionaryEnglishWordSense = wiktionaryEnglishWordSense;
this.isOpenCycWordSense = isOpenCycWordSense;
}
/** Gets the term id inserted by the container.
*
* @return the term id inserted by the container
*/
public Long getTermId() {
return termId;
}
/** Gets the word sense position in the list of word senses for the word.
*
* @return the word sense position in the list of word senses for the word
*/
public int getPosition() {
return position;
}
/** Sets the word sense position in the list of word senses for the word.
*
* @param position the word sense position in the list of word senses for the word
*/
public void setPosition(int position) {
//Preconditions
assert position > 0 : "position must be positive";
this.position = position;
}
/** Gets the part of speech.
*
* @return the part of speech
*/
public AtomicTerm getSpeechPart() {
return speechPart;
}
/** Sets the part of speech.
*
* @param speechPart the part of speech
*/
public void setSpeechPart(AtomicTerm speechPart) {
//Preconditions
assert speechPart != null : "speechPart must not be null";
this.speechPart = speechPart;
}
/** Sets the basic part of speech for open class words, one of Noun, Verb, Adjective or Adverb, or null if not applicable.
*
* @param basicSpeechPart the basic part of speech for open class words, one of Noun, Verb, Adjective or Adverb, or null if not applicable
*/
public void setBasicSpeechPart(final AtomicTerm basicSpeechPart) {
//Preconditions
assert basicSpeechPart != null : "basicSpeechPart must not be null";
this.basicSpeechPart = basicSpeechPart;
}
/** Gets the basic part of speech for open class words, one of Noun, Verb, Adjective or Adverb, or null if not applicable.
*
* @return the basic part of speech for open class words, one of Noun, Verb, Adjective or Adverb, or null if not applicable
*/
public AtomicTerm getBasicSpeechPart() {
return basicSpeechPart;
}
/** Gets the sense number.
*
* @return the sense number
*/
public int getWordSenseNbr() {
return wordSenseNbr;
}
/** Sets the sense number.
*
* @param wordSenseNbr the sense number
*/
public void setWordSenseNbr(int wordSenseNbr) {
//Preconditions
assert wordSenseNbr > 0 : "wordSenseNbr must be positive";
this.wordSenseNbr = wordSenseNbr;
}
/** Gets the word sense definitions.
*
* @return the word sense definitions
*/
public Set<String> getGlosses() {
return glosses;
}
/** Gets the set of sample phrases.
*
* @return the set of sample phrases
*/
public Set<TexaiSamplePhrase> getTexaiSamplePhrases() {
return texaiSamplePhrases;
}
/** Gets the English word for which this is a word sense.
*
* @return the English word for which this is a word sense
*/
public TexaiEnglishWord getTexaiEnglishWord() {
return texaiEnglishWord;
}
/** Sets the English word for which this is a word sense.
*
* @param texaiEnglishWord the English word for which this is a word sense
*/
public void setTexaiEnglishWord(TexaiEnglishWord texaiEnglishWord) {
//Preconditions
assert texaiEnglishWord != null : "texaiEnglishWord must not be null";
this.texaiEnglishWord = texaiEnglishWord;
}
/** Gets the mapped term or null if not present.
*
* @return the mapped term or null if not present
*/
public AbstractReifiedTerm getTexaiMappedTerm() {
return texaiMappedTerm;
}
/** Sets the mapped term or null if not present.
*
* @param texaiMappedTerm the mapped term or null if not present
*/
public void setTexaiMappedTerm(AbstractReifiedTerm texaiMappedTerm) {
//Preconditions
assert texaiMappedTerm != null : "texaiMappedTerm must not be null";
this.texaiMappedTerm = texaiMappedTerm;
}
/** Gets the set of Wiktionary category names.
*
* @return the set of Wiktionary category names
*/
public Set<String> getCategoryNames() {
return categoryNames;
}
/** Gets the WordNet category or null if not present.
*
* @return the WordNet category or null if not present
*/
public WordNetCategory getWordNetCategory() {
return wordNetCategory;
}
/** Sets the WordNet category or null if not present.
*
* @param wordNetCategory the WordNet category or null if not present
*/
public void setWordNetCategory(WordNetCategory wordNetCategory) {
//Preconditions
assert wordNetCategory != null : "wordNetCategory must not be null";
this.wordNetCategory = wordNetCategory;
}
/** Gets the WordNet synset or null if not present.
*
* @return the WordNet synset or null if not present
*/
public WordNetSynset getWordNetSynset() {
return wordNetSynset;
}
/** Sets the WordNet synset or null if not present.
*
* @param wordNetSynset the WordNet synset or null if not present
*/
public void setWordNetSynset(WordNetSynset wordNetSynset) {
//Preconditions
assert wordNetSynset != null : "wordNetSynset must not be null";
this.wordNetSynset = wordNetSynset;
}
/** Sets the Wiktionary word sense or null if not present.
*
* @param wiktionaryEnglishWordSense the Wiktionary word sense or null if not present
*/
public void setWiktionaryEnglishWordSense(final WiktionaryEnglishWordSense wiktionaryEnglishWordSense) {
//Preconditions
assert wiktionaryEnglishWordSense != null : "wiktionaryEnglishWordSense must not be null";
this.wiktionaryEnglishWordSense = wiktionaryEnglishWordSense;
}
/** Gets the Wiktionary word sense or null if not present.
*
* @return the Wiktionary word sense or null if not present
*/
public WiktionaryEnglishWordSense getWiktionaryEnglishWordSense() {
return wiktionaryEnglishWordSense;
}
/** Sets the indicator whether this is an OpenCyc word sense.
*
* @param isOpenCycWordSense the indicator whether this is an OpenCyc word sense
*/
public void setIsOpenCycWordSense(final boolean isOpenCycWordSense) {
this.isOpenCycWordSense = isOpenCycWordSense;
}
/** Gets the indicator whether this is an OpenCyc word sense.
*
* @return the indicator whether this is an OpenCyc word sense
*/
public boolean getIsOpenCycWordSense() {
return isOpenCycWordSense;
}
/** Returns whether the given object is equal to this object.
*
* @param obj the given object
* @return whether the given object is equal to this object
*/
@Override
public boolean equals(final Object obj) {
if (obj instanceof TexaiEnglishWordSense) {
final TexaiEnglishWordSense that = (TexaiEnglishWordSense) obj;
return this.getTermId().equals(that.getTermId());
} else {
return false;
}
}
/** Returns a hash code for this object.
*
* @return a hash code for this object
*/
@Override
public int hashCode() {
if (getTermId() == null) {
return super.hashCode();
} else {
return getTermId().hashCode();
}
}
/** Returns a description of this word sense.
*
* @return a description of this word sense
*/
@Override
public String toString() {
final StringBuilder stringBuilder = new StringBuilder(Constants.STRING_BUILDER_SIZE);
stringBuilder.append('[');
stringBuilder.append(speechPart.toString().toLowerCase());
stringBuilder.append('.');
stringBuilder.append(wordSenseNbr);
stringBuilder.append(' ');
stringBuilder.append(texaiEnglishWord.getLemma());
stringBuilder.append(']');
return stringBuilder.toString();
}
}
See more files for this project here