TexaiEnglishWord.java from Texai at Krugle
Show TexaiEnglishWord.java syntax highlighted
/*
* TexaiEnglishWord.java
*
* Created on February 22, 2007, 10:48 AM
*
* Description: Provides domain entities that contain words.
*
* 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.List;
import java.util.Set;
import javax.persistence.Id;
import javax.persistence.OrderBy;
import org.texai.kb.Constants;
import org.texai.kb.ejb.entity.AtomicTerm;
import org.texai.kb.persistence.DomainEntity;
import org.texai.kb.persistence.DomainProperty;
import org.texai.wiktionary.domainEntity.WiktionaryEnglishWord;
import org.texai.wordnet.domain.entity.WordNetEnglishWord;
/**
*
* @author reed
*/
@DomainEntity(typeOf="LinguisticObjectType", subClassOf="EnglishWord")
public class TexaiEnglishWord {
@Id
/** the term id inserted by the container */
private Long termId; // NOPMD
/** the lemma, which is the non-inflected word */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_LEMMA, range="CharacterString", identifier=true)
private String lemma; // NOPMD
/** the set of inflected word forms */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_ENGLISH_WORD_FORM_FOR_WORD,
range="org.texai.lexicon.domainEntity.TexaiEnglishWordForm", inverse=true)
private Set<TexaiEnglishWordForm> texaiEnglishWordForms;
/** the list of word senses */
@OrderBy("position")
@DomainProperty(name=Constants.TERM_NAME_TEXAI_ENGLISH_WORD_SENSE_FOR_WORD,
range="org.texai.lexicon.domainEntity.TexaiEnglishWordSense", inverse=true)
private List<TexaiEnglishWordSense> texaiEnglishWordSenses;
/** for nouns, the set whose possible elements are the terms CountNoun and MassNoun */
@DomainProperty(name="texaiNounType", subPropertyOf="isa", range="SpeechPart")
private Set<AtomicTerm> nounTypes;
/** the corresponding WordNet word, or null if not present */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_WORD_NET_ENGLISH_WORD)
private WordNetEnglishWord wordNetEnglishWord;
/** the corresponding Wiktionary word, or null if not present */
@DomainProperty(name="texaiWiktionaryEnglishWord")
private WiktionaryEnglishWord wiktionaryEnglishWord;
/** the indicator whether this is an OpenCyc pretty string */
@DomainProperty(trueClass="TexaiEnglishWord-IsOpenCycPrettyString", falseClass="TexaiEnglishWord-IsNotOpenCycPrettyString")
private boolean isOpenCycWord;
/** Creates a new instance of TexaiEnglishWord. */
public TexaiEnglishWord() {
super();
}
/** Creates a new instance of TexaiEnglishWord.
*
* @param lemma the lemma, which is the non-inflected word
* @param texaiEnglishWordForms the set of inflected word forms
* @param texaiEnglishWordSenses the list of word senses
* @param nounTypes for nouns, the set whose possible elements are the terms CountNoun and MassNoun
* @param wordNetEnglishWord the corresponding WordNet word, or null if not present
* @param wiktionaryEnglishWord the corresponding Wiktionary word, or null if not present
* @param isOpenCycWord the indicator whether this is an OpenCyc pretty string
*/
public TexaiEnglishWord(
final String lemma,
final Set<TexaiEnglishWordForm> texaiEnglishWordForms,
final List<TexaiEnglishWordSense> texaiEnglishWordSenses,
final Set<AtomicTerm> nounTypes,
final WordNetEnglishWord wordNetEnglishWord,
final WiktionaryEnglishWord wiktionaryEnglishWord,
final boolean isOpenCycWord) {
super();
//Preconditions
assert lemma != null : "lemma must not be null";
assert !lemma.isEmpty() : "lemma must not be an empty string";
assert texaiEnglishWordForms != null : "texaiEnglishWordForms must not be null";
assert texaiEnglishWordSenses != null : "texaiEnglishWordSenses must not be null";
assert nounTypes != null : "nounTypes must not be null";
this.lemma = lemma;
this.texaiEnglishWordForms = texaiEnglishWordForms;
this.texaiEnglishWordSenses = texaiEnglishWordSenses;
this.nounTypes = nounTypes;
this.wordNetEnglishWord = wordNetEnglishWord;
this.wiktionaryEnglishWord = wiktionaryEnglishWord;
this.isOpenCycWord = isOpenCycWord;
}
/** Gets the term id inserted by the container.
*
* @return the term id inserted by the container
*/
public Long getTermId() {
return termId;
}
/** Gets the lemma, which is the non-inflected word.
*
* @return the lemma, which is the non-inflected word
*/
public String getLemma() {
return lemma;
}
/** Sets the lemma, which is the non-inflected word.
*
* @param lemma the lemma, which is the non-inflected word
*/
public void setLemma(final String lemma) {
//Preconditions
assert lemma != null : "lemma must not be null";
assert !lemma.isEmpty() : "lemma must not be an empty string";
this.lemma = lemma;
}
/** Gets the set of inflected word forms.
*
* @return the set of inflected word forms
*/
public Set<TexaiEnglishWordForm> getTexaiEnglishWordForms() {
return texaiEnglishWordForms;
}
/** Gets the list of word senses.
*
* @return the list of word senses
*/
public List<TexaiEnglishWordSense> getTexaiEnglishWordSenses() {
return texaiEnglishWordSenses;
}
/** Gets for nouns, the set whose possible elements are the terms CountNoun and MassNoun.
*
* @return for nouns, the set whose possible elements are the terms CountNoun and MassNoun
*/
public Set<AtomicTerm> getNounTypes() {
return nounTypes;
}
/** Sets the set whose possible elements are the terms CountNoun and MassNoun.
*
* @param nounTypes the set whose possible elements are the terms CountNoun and MassNoun
*/
public void setNounTypes(final Set<AtomicTerm> nounTypes) {
//Preconditions
assert nounTypes != null : "nounTypes must not be null";
this.nounTypes = nounTypes;
}
/** Gets the corresponding WordNet word, or null if not present.
*
* @return the corresponding WordNet word, or null if not present
*/
public WordNetEnglishWord getWordNetEnglishWord() {
return wordNetEnglishWord;
}
/** Sets the corresponding WordNet word, or null if not present
*
* @param wordNetEnglishWord the corresponding WordNet word, or null if not present
*/
public void setWordNetEnglishWord(final WordNetEnglishWord wordNetEnglishWord) {
//Preconditions
assert wordNetEnglishWord != null : "wordNetEnglishWord must not be null";
this.wordNetEnglishWord = wordNetEnglishWord;
}
/** Gets the corresponding Wiktionary word, or null if not present.
*
* @return the corresponding Wiktionary word, or null if not present
*/
public WiktionaryEnglishWord getWiktionaryEnglishWord() {
return wiktionaryEnglishWord;
}
/** Sets the corresponding Wiktionary word, or null if not present
*
* @param wiktionaryEnglishWord the corresponding Wiktionary word, or null if not present
*/
public void setWiktionaryEnglishWord(final WiktionaryEnglishWord wiktionaryEnglishWord) {
//Preconditions
assert wiktionaryEnglishWord != null : "wiktionaryEnglishWord must not be null";
this.wiktionaryEnglishWord = wiktionaryEnglishWord;
}
/** Gets the indicator whether this is an OpenCyc pretty string.
*
* @return the indicator whether this is an OpenCyc pretty string
*/
public boolean getIsOpenCycWord() {
return isOpenCycWord;
}
/** Sets the the indicator whether this is an OpenCyc pretty string.
*
* @param isOpenCycWord the indicator whether this is an OpenCyc pretty string
*/
public void setIsOpenCycWord(final boolean isOpenCycWord) {
this.isOpenCycWord = isOpenCycWord;
}
/** 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 TexaiEnglishWord) {
final TexaiEnglishWord that = (TexaiEnglishWord) 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 string representation of this object.
*
* @return a string representation of this object
*/
@Override
public String toString() {
if (lemma == null) {
return super.toString();
} else {
return "[WORD " + lemma + "]";
}
}
}
See more files for this project here