TexaiEnglishWordSense.java from Texai at Krugle
Show TexaiEnglishWordSense.java syntax highlighted
/*
* TexaiEnglishWordSense.java
*
* Created on February 28, 2007, 8:47 PM
*
* Description: Provides a word sense entity.
*
* 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 net.jcip.annotations.NotThreadSafe;
import org.openrdf.model.URI;
import org.texai.kb.Constants;
import org.texai.kb.persistence.RDFEntity;
import org.texai.kb.persistence.RDFNamespace;
import org.texai.kb.persistence.RDFProperty;
import org.texai.wiktionary.domainEntity.WiktionaryEnglishWordSense;
import org.texai.wordnet.domain.entity.WordNetCategory;
import org.texai.wordnet.domain.entity.WordNetSynset;
/** Provides a word sense entity.
*
* @author reed
*/
@RDFEntity(
namespaces={
@RDFNamespace(prefix="rdfs", namespaceURI=Constants.RDFS_NAMESPACE),
@RDFNamespace(prefix="texai", namespaceURI=Constants.TEXAI_NAMESPACE),
@RDFNamespace(prefix="cyc", namespaceURI=Constants.CYC_NAMESPACE),
@RDFNamespace(prefix="xsd", namespaceURI=Constants.XSD_NAMESPACE)},
subject="texai:org.texai.lexicon.domainEntity.TexaiEnglishWordSense", type="cyc:LinguisticObjectType", subClassOf="cyc:WordSense", context="texai:TexaiEnglishLexiconContext")
@NotThreadSafe // but effectively immutable
public class TexaiEnglishWordSense {
/** the id assigned by the persistence framework */
@Id
private URI id; // NOPMD
/** the word sense position in the list of word senses for the word */
@RDFProperty(predicate="texai:texaiWordSensePosition")
private int position; // NOPMD
/** the part of speech */
@RDFProperty(predicate="texai:texaiWordSenseSpeechPart")
private URI speechPart;
/** the basic part of speech for open class words, one of Noun, Verb, Adjective or Adverb, or null if not applicable */
@RDFProperty(predicate="texai:texaiWordSenseBasicSpeechPart")
private URI basicSpeechPart;
/** the sense number */
@RDFProperty(predicate="texai:texaiWordSenseNumber")
private int wordSenseNbr; // NOPMD
/** the word sense definitions */
@RDFProperty(predicate="texai:texaiWordSenseGloss", range="xsd:string")
private Set<String> glosses;
/** the set of sample phrases */
@RDFProperty(predicate="texai:texaiWordSenseSamplePhrase", range="texai:org.texai.lexicon.domainEntity.TexaiSamplePhrase")
private Set<TexaiSamplePhrase> texaiSamplePhrases;
/** the English word for which this is a word sense */
@RDFProperty(predicate="texai:texaiEnglishWordSenseForWord")
private TexaiEnglishWord texaiEnglishWord;
/** the mapped term or null if not present */
@RDFProperty(predicate="texai:texaiWordSenseMappedTerm")
private URI texaiMappedTerm;
/** the set of Wiktionary category names */
@RDFProperty(predicate="texai:texaiWordSenseCategoryName", range="xsd:string")
private Set<String> categoryNames;
/** the WordNet category or null if not present */
@RDFProperty(predicate="texai:wordNetCategory", subPropertyOf="rdfs:subClassOf")
private WordNetCategory wordNetCategory;
/** the WordNet synset or null if not present */
@RDFProperty(predicate="texai:texaiWordSenseWordNetSynset")
private WordNetSynset wordNetSynset;
/** the Wiktionary word sense or null if not present */
@RDFProperty(predicate="texai:texaiWiktionaryWordSense")
private WiktionaryEnglishWordSense wiktionaryEnglishWordSense;
/** the indicator whether this is an OpenCyc word sense */
@RDFProperty(trueClass="texai:TexaiEnglishWordSense-IsOpenCyc", falseClass="texai: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 URI speechPart,
final URI basicSpeechPart,
final int wordSenseNbr,
final Set<String> glosses,
final Set<TexaiSamplePhrase> texaiSamplePhrases,
final TexaiEnglishWord texaiEnglishWord,
final URI 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 id that identifies this instance.
*
* @return the id that identifies this instance
*/
public URI getId() {
return id;
}
/** 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 URI getSpeechPart() {
return speechPart;
}
/** Sets the part of speech.
*
* @param speechPart the part of speech
*/
public void setSpeechPart(URI 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 URI 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 URI 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 URI 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(URI 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.getId().equals(that.getId());
} else {
return false;
}
}
/** Returns a hash code for this object.
*
* @return a hash code for this object
*/
@Override
public int hashCode() {
if (getId() == null) {
return super.hashCode();
} else {
return getId().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