TexaiEnglishWordForm.java from Texai at Krugle
Show TexaiEnglishWordForm.java syntax highlighted
/*
* TexaiEnglishWordForm.java
*
* Created on February 22, 2007, 10:52 AM
*
* Description: Provides domain entities that contain word forms.
*
* 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.cmudict.domainEntity.ARPABETPronunciation;
import org.texai.cmudict.domainEntity.CMUDictionaryEnglishWordForm;
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.WiktionaryEnglishWordForm;
import org.texai.wordnet.domain.entity.WordNetCasedEnglishWord;
/**
*
* @author reed
*/
@DomainEntity(typeOf="LinguisticObjectType", subClassOf="EnglishWord")
public class TexaiEnglishWordForm {
@Id
/** the term id inserted by the container */
private Long termId; // NOPMD
/** the word form (wordForm and wordFormInflection uniquely identify each instance) */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_WORD_FORM, range=Constants.TERM_NAME_CHARACTER_STRING)
private String wordForm; // NOPMD
/** the word form inflection speech part */
@DomainProperty(name="texaiWordFormInflection", subPropertyOf="isa")
private AtomicTerm wordFormInflection;
/** the set of pronunciations */
@DomainProperty(name="texaiARPABETPronounciation", range="org.texai.cmudict.domainEntity.ARPABETPronounciation")
private Set<ARPABETPronunciation> arpabetPronunciations;
/** the non-inflected word for which this is a word form */
@DomainProperty(name=Constants.TERM_NAME_TEXAI_ENGLISH_WORD_FORM_FOR_WORD)
private TexaiEnglishWord texaiEnglishWord;
/** the corresponding Wiktionary word form, or null if not present */
@DomainProperty(name="texaiWiktionaryEnglishWordForm")
private WiktionaryEnglishWordForm wiktionaryEnglishWordForm;
/** the corresponding CMU Pronouncing Dictionary word form, or null if not present */
@DomainProperty(name="texaiCMUDictionaryEnglishWordForm")
private CMUDictionaryEnglishWordForm cmuDictionaryEnglishWordForm;
/** the WordNet cased word form, or null if not present */
@DomainProperty(name="texaiWordNetCasedEnglishWord")
private WordNetCasedEnglishWord wordNetCasedEnglishWord;
/** the indicator whether this is an OpenCyc pretty string */
@DomainProperty(trueClass="TexaiEnglishWordForm-IsOpenCycPrettyString", falseClass="TexaiEnglishWordForm-IsNotOpenCycPrettyString")
private boolean isOpenCycWordForm;
/** Creates a new instance of TexaiEnglishWordForm. */
public TexaiEnglishWordForm() {
super();
}
/** Creates a new instance of TexaiEnglishWordForm.
*
* @param wordForm the word form
* @param wordFormInflectionthe word form inflection
* @param arpabetPronunciations the set of pronunciations
* @param texaiEnglishWord the non-inflected word for which this is a word form
* @param wiktionaryEnglishWordForm the corresponding Wiktionary word form, or null if not present
* @param cmuDictionaryEnglishWordForm the corresponding CMU Pronouncing Dictionary word form, or null if not present
* @param wordNetCasedEnglishWord the WordNet cased word form, or null if not present
* @param isOpenCycWordForm the indicator whether this is an OpenCyc pretty string
*/
public TexaiEnglishWordForm(
final String wordForm,
final AtomicTerm wordFormInflection,
final Set<ARPABETPronunciation> arpabetPronunciations,
final TexaiEnglishWord texaiEnglishWord,
final WiktionaryEnglishWordForm wiktionaryEnglishWordForm,
final CMUDictionaryEnglishWordForm cmuDictionaryEnglishWordForm,
final WordNetCasedEnglishWord wordNetCasedEnglishWord,
final boolean isOpenCycWordForm) {
super();
//Preconditions
assert wordForm != null : "wordForm must not be null";
assert !wordForm.isEmpty() : "wordForm must not be an empty string";
assert wordFormInflection != null : "wordFormInflection must not be null";
assert arpabetPronunciations != null : "arpabetPronunciations must not be null";
assert texaiEnglishWord != null : "texaiEnglishWord must not be null";
this.wordForm = wordForm;
this.wordFormInflection = wordFormInflection;
this.arpabetPronunciations = arpabetPronunciations;
this.texaiEnglishWord = texaiEnglishWord;
this.wiktionaryEnglishWordForm = wiktionaryEnglishWordForm;
this.cmuDictionaryEnglishWordForm = cmuDictionaryEnglishWordForm;
this.wordNetCasedEnglishWord = wordNetCasedEnglishWord;
this.isOpenCycWordForm = isOpenCycWordForm;
}
/** Gets the term id inserted by the container.
*
* @return the term id inserted by the container
*/
public Long getTermId() {
return termId;
}
/** Gets the word form.
*
* @return the word form
*/
public String getWordForm() {
return wordForm;
}
/** Sets the word form.
*
* @param wordForm the word form
*/
public void setWordForm(final String wordForm) {
//Preconditions
assert wordForm != null : "wordForm must not be null";
assert !wordForm.isEmpty() : "wordForm must not be an empty string";
this.wordForm = wordForm;
}
/** Gets the word form inflection.
*
* @return the word form inflection
*/
public AtomicTerm getWordFormInflection() {
return wordFormInflection;
}
/** Sets the word form inflection.
*
* @param wordFormInflection the word form inflection
*/
public void setWordFormInflection(final AtomicTerm wordFormInflection) {
//Preconditions
assert wordFormInflection != null : "wordFormInflection must not be null";
this.wordFormInflection = wordFormInflection;
}
/** Gets the set of pronunciations.
*
* @return the set of pronunciations
*/
public Set<ARPABETPronunciation> getARPABETPronunciations() {
return arpabetPronunciations;
}
/** Gets the non-inflected Texai word for which this is a word form.
*
* @return the non-inflected Texai word for which this is a word form
*/
public TexaiEnglishWord getTexaiEnglishWord() {
return texaiEnglishWord;
}
/** Gets the corresponding Wiktionary word form, or null if not present.
*
* @return the corresponding Wiktionary word form, or null if not present
*/
public WiktionaryEnglishWordForm getWiktionaryEnglishWordForm() {
return wiktionaryEnglishWordForm;
}
/** Sets the corresponding CMU Pronouncing Dictionary word form.
*
* @param cmuDictionaryEnglishWordForm the corresponding CMU Pronouncing Dictionary word form, or null if not present
*/
public void setCMUDictionaryEnglishWordForm(final CMUDictionaryEnglishWordForm cmuDictionaryEnglishWordForm) {
this.cmuDictionaryEnglishWordForm = cmuDictionaryEnglishWordForm;
}
/** Gets the corresponding CMU Pronouncing Dictionary word form, or null if not present.
*
* @return the corresponding CMU Pronouncing Dictionary word form, or null if not present
*/
public CMUDictionaryEnglishWordForm getCMUDictionaryEnglishWordForm() {
return cmuDictionaryEnglishWordForm;
}
/** Gets the WordNet cased word form, or null if not present.
*
* @return the WordNet cased word form, or null if not present
*/
public WordNetCasedEnglishWord getWordNetCasedEnglishWord() {
return wordNetCasedEnglishWord;
}
/** Gets the indicator whether this is an OpenCyc pretty string.
*
* @return the indicator whether this is an OpenCyc pretty string
*/
public boolean getIsOpenCycWordForm() {
return isOpenCycWordForm;
}
/** 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 TexaiEnglishWordForm) {
final TexaiEnglishWordForm that = (TexaiEnglishWordForm) 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 (wordForm == null) {
return super.toString();
} else {
return "[WORD FORM " + wordFormInflection + ": " + wordForm + "]";
}
}
}
See more files for this project here