TexaiEnglishWord.java from Texai at Krugle
Show TexaiEnglishWord.java syntax highlighted
/*
* TexaiEnglishWord.java
*
* Created on February 22, 2007, 10:48 AM
*
* Description: Provides an English word 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.List;
import java.util.Set;
import javax.persistence.Id;
import javax.persistence.OrderBy;
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.WiktionaryEnglishWord;
import org.texai.wordnet.domain.entity.WordNetEnglishWord;
/** Provides an English word entity.
*
* @author reed
*/
@RDFEntity(
namespaces={
@RDFNamespace(prefix="rdf", namespaceURI=Constants.RDF_NAMESPACE),
@RDFNamespace(prefix="texai", namespaceURI=Constants.TEXAI_NAMESPACE),
@RDFNamespace(prefix="cyc", namespaceURI=Constants.CYC_NAMESPACE)},
subject="texai:org.texai.lexicon.domainEntity.TexaiEnglishWord", type="cyc:LinguisticObjectType", subClassOf="cyc:EnglishWord", context="texai:TexaiEnglishLexiconContext")
@NotThreadSafe // but effectively immutable
public class TexaiEnglishWord {
/** the id assigned by the persistence framework */
@Id
private URI id; // NOPMD
/** the lemma, which is the non-inflected word */
@RDFProperty(predicate="texai:texaiLemma")
private String lemma; // NOPMD
/** the set of inflected word forms */
@RDFProperty(predicate="texai:texaiEnglishWordFormForWord", range="texai:org.texai.lexicon.domainEntity.TexaiEnglishWordForm", inverse=true)
private Set<TexaiEnglishWordForm> texaiEnglishWordForms;
/** the list of word senses */
@OrderBy("position")
@RDFProperty(predicate="texai:texaiEnglishWordSenseForWord", range="texai:org.texai.lexicon.domainEntity.TexaiEnglishWordSense", inverse=true)
private List<TexaiEnglishWordSense> texaiEnglishWordSenses;
/** for nouns, the set whose possible elements are the terms CountNoun and MassNoun */
@RDFProperty(predicate="texai:texaiNounType", subPropertyOf="rdf:type")
private Set<URI> nounTypes;
/** the corresponding WordNet word, or null if not present */
@RDFProperty(predicate="texai:texaiWordNetEnglishWord")
private WordNetEnglishWord wordNetEnglishWord;
/** the corresponding Wiktionary word, or null if not present */
@RDFProperty(predicate="texai:texaiWiktionaryEnglishWord")
private WiktionaryEnglishWord wiktionaryEnglishWord;
/** the indicator whether this is an OpenCyc pretty string */
@RDFProperty(trueClass="texai:TexaiEnglishWord-IsOpenCycPrettyString", falseClass="texai: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<URI> 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 id that identifies this instance.
*
* @return the id that identifies this instance
*/
public URI getId() {
return id;
}
/** 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<URI> 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<URI> 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.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 (lemma == null) {
return super.toString();
} else {
return "[WORD " + lemma + "]";
}
}
}
See more files for this project here