WordNetSamplePhraseItem.java from Texai at Krugle
Show WordNetSamplePhraseItem.java syntax highlighted
/*
* WordNetSamplePhraseItem.java
*
* Created on November 14, 2006, 11:25 PM
*
* Description: Contains a WordNet sample sentence for a particular synset.
*
* Copyright (C) 2006 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.wordnet.domain.entity;
import javax.persistence.Id;
import net.jcip.annotations.NotThreadSafe;
import org.openrdf.model.URI;
import org.texai.kb.Constants;
import org.texai.kb.persistence.RDFProperty;
import org.texai.kb.persistence.RDFEntity;
import org.texai.kb.persistence.RDFNamespace;
/** Contains a WordNet sample sentence for a particular synset. This class is not technically thread safe, but client applications should
* treat it as immutable once loaded. The field setter methods should not be used nor should the field
* contents be modified.
*
* @author reed
*/
@RDFEntity(
namespaces={
@RDFNamespace(prefix="texai", namespaceURI=Constants.TEXAI_NAMESPACE),
@RDFNamespace(prefix="cyc", namespaceURI=Constants.CYC_NAMESPACE)},
subject="texai:org.texai.wordnet.domain.entity.WordNetSamplePhraseItem", type="cyc:LinguisticObjectType", subClassOf="cyc:AbstractInformationStructure", context=Constants.TERM_WORDNET21_DOMAIN_CONTEXT)
@NotThreadSafe // but effectively immutable
public class WordNetSamplePhraseItem {
/** the id assigned by the persistence framework */
@Id
private URI id; // NOPMD
/** the object representing the set of synonymous word senses */
@RDFProperty(predicate="texai:wnSamplePhraseItemSynset")
private WordNetSynset wnSamplePhraseItemSynset;
/** the sample phrase id */
@RDFProperty(predicate="texai:wnWordNetSamplePhraseId")
private int wnWordNetSamplePhraseId; // NOPMD
/** the sample phrase */
@RDFProperty(predicate="texai:wnSamplePhrase")
private String wnSamplePhrase; // NOPMD
/**
* Creates a new instance of WordNetSamplePhraseItem
*/
public WordNetSamplePhraseItem() {
super();
}
/** Creates a new instance of WordNetSamplePhraseItem. */
public WordNetSamplePhraseItem(
final WordNetSynset wnSamplePhraseItemSynset,
final int wnWordNetSamplePhraseId,
final String wnSamplePhrase) {
super();
//Preconditions
assert wnSamplePhraseItemSynset != null : "wnSamplePhraseItemSynset must not be null";
assert wnWordNetSamplePhraseId > 0 : "wnWordNetSamplePhraseId must be positive";
assert wnSamplePhrase != null : "wnSamplePhrase must not be null";
assert wnSamplePhrase.length() > 0 : "wnSamplePhrase must not be an empty string";
this.wnSamplePhraseItemSynset = wnSamplePhraseItemSynset;
this.wnWordNetSamplePhraseId = wnWordNetSamplePhraseId;
this.wnSamplePhrase = wnSamplePhrase;
}
/** Returns a hash code value for the object.
*
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
return getId().hashCode();
}
/** Determines whether another object is equal to this WordNetSynset.
*
* @param object the reference object with which to compare
* @return <code>true</code> if this object is the same as the argument;
* <code>false</code> otherwise.
*/
@Override
public boolean equals(final Object object) {
if (!(object instanceof WordNetSamplePhraseItem)) {
return false;
}
final WordNetSamplePhraseItem that = (WordNetSamplePhraseItem) object;
return this.getId().equals(that.getId());
}
/** Gets the id.
*
* @return the id
*/
public URI getId() {
return id;
}
/** Gets the object representing the set of synonymous word senses.
*
* @return the object representing the set of synonymous word senses
*/
public WordNetSynset getWnSamplePhraseItemSynset() {
return wnSamplePhraseItemSynset;
}
/** Gets the sample phrase id.
*
* @return the sample phrase id
*/
public int getWnWordNetSamplePhraseId() {
return wnWordNetSamplePhraseId;
}
/** Gets the sample phrase.
*
* @return the sample phrase
*/
public String getWnSamplePhrase() {
return wnSamplePhrase;
}
/** Returns a string representation of this object.
*
* @return a string representation of this object
*/
@Override
public String toString() {
return "[" + wnSamplePhrase + "]";
}
}
See more files for this project here