TexaiEnglishWordForm.java from Texai at Krugle
Show TexaiEnglishWordForm.java syntax highlighted
/*
* TexaiEnglishWordForm.java
*
* Created on February 22, 2007, 10:52 AM
*
* Description: Provides a word form 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.cmudict.domainEntity.ARPABETPronunciation;
import org.texai.cmudict.domainEntity.CMUDictionaryEnglishWordForm;
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.WiktionaryEnglishWordForm;
import org.texai.wordnet.domain.entity.WordNetCasedEnglishWord;
/** Provides a word form entity.
*
* @author reed
*/
@RDFEntity(
namespaces={
@RDFNamespace(prefix="texai", namespaceURI=Constants.TEXAI_NAMESPACE),
@RDFNamespace(prefix="cyc", namespaceURI=Constants.CYC_NAMESPACE)},
subject="texai:org.texai.lexicon.domainEntity.TexaiEnglishWordForm", type="cyc:LinguisticObjectType", subClassOf="cyc:EnglishWord", context="texai:TexaiEnglishLexiconContext")
@NotThreadSafe // but effectively immutable
public class TexaiEnglishWordForm {
/** the id assigned by the persistence framework */
@Id
private URI id; // NOPMD
/** the word form (wordForm and wordFormInflection uniquely identify each instance) */
@RDFProperty(predicate="texai:texaiWordForm")
private String wordForm; // NOPMD
/** the word form inflection speech part */
@RDFProperty(predicate="texai:texaiWordFormInflection", subPropertyOf="isa")
private URI wordFormInflection;
/** the set of pronunciations */
@RDFProperty(predicate="texai:texaiARPABETPronounciation", range="texai:org.texai.cmudict.domainEntity.ARPABETPronounciation")
private Set<ARPABETPronunciation> arpabetPronunciations;
/** the non-inflected word for which this is a word form */
@RDFProperty(predicate="texai:texaiEnglishWordFormForWord")
private TexaiEnglishWord texaiEnglishWord;
/** the corresponding Wiktionary word form, or null if not present */
@RDFProperty(predicate="texai:texaiWiktionaryEnglishWordForm")
private WiktionaryEnglishWordForm wiktionaryEnglishWordForm;
/** the corresponding CMU Pronouncing Dictionary word form, or null if not present */
@RDFProperty(predicate="texai:texaiCMUDictionaryEnglishWordForm")
private CMUDictionaryEnglishWordForm cmuDictionaryEnglishWordForm;
/** the WordNet cased word form, or null if not present */
@RDFProperty(predicate="texai:texaiWordNetCasedEnglishWord")
private WordNetCasedEnglishWord wordNetCasedEnglishWord;
/** the indicator whether this is an OpenCyc pretty string */
@RDFProperty(trueClass="texai:TexaiEnglishWordForm-IsOpenCycPrettyString", falseClass="texai: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 URI 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 id that identifies this instance.
*
* @return the id that identifies this instance
*/
public URI getId() {
return id;
}
/** 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 URI getWordFormInflection() {
return wordFormInflection;
}
/** Sets the word form inflection.
*
* @param wordFormInflection the word form inflection
*/
public void setWordFormInflection(final URI 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.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 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