ARPABETPronunciation.java from Texai at Krugle
Show ARPABETPronunciation.java syntax highlighted
/*
* ARPABETPronounciation.java
*
* Created on February 23, 2007, 8:43 AM
*
* Description: Provides an ARPABET pronounciation for an English word.
*
* 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.cmudict.domainEntity;
import java.util.List;
import javax.persistence.Id;
import javax.persistence.OrderBy;
import org.texai.kb.Constants;
import org.texai.kb.persistence.DomainEntity;
import org.texai.kb.persistence.DomainProperty;
/**
*
* @author reed
*/
@DomainEntity(typeOf={Constants.TERM_NAME_LINGUISTIC_OBJECT_TYPE}, subClassOf={Constants.TERM_NAME_COMPUTER_DATA_STRUCTURE})
public class ARPABETPronunciation {
@Id
/** the term id inserted by the container */
private Long termId; // NOPMD
/** the ordered ARPABET phoneme adapters */
@OrderBy("phonemePosition")
@DomainProperty(name="cxgOrderedARPABETPhonemeAdapter")
private List<ARPABETPhonemeAdapter> orderedARPABETPhonemeAdapters;
/** the indicator whether this is the primary pronunciation */
@DomainProperty(trueClass="ARPABETPronounciation_Primary", falseClass="ARPABETPronounciation_Alternate")
private boolean isPrimaryPronunciation;
/** Creates a new instance of ARPABETPronunciation. */
public ARPABETPronunciation() {
super();
}
/** Creates a new instance of ARPABETPronunciation.
*
* @param orderedARPABETPhonemeAdapters the ordered ARPABET phoneme adapters
* @param isPrimaryPronunciation the indicator whether this is the primary pronunciation
*/
public ARPABETPronunciation(final List<ARPABETPhonemeAdapter> orderedARPABETPhonemeAdapters, final boolean isPrimaryPronunciation) {
super();
//Preconditions
assert orderedARPABETPhonemeAdapters != null : "orderedARPABETPhonemeAdapters must not be null";
this.orderedARPABETPhonemeAdapters = orderedARPABETPhonemeAdapters;
this.isPrimaryPronunciation = isPrimaryPronunciation;
}
/** Gets the term id.
*
* @return the term id
*/
public Long getTermId() {
return termId;
}
/** Gets the ordered ARPABET phoneme adapters.
*
* @return the ordered ARPABET phoneme adapters
*/
public List<ARPABETPhonemeAdapter> getOrderedARPABETPhonemeAdapters() {
return orderedARPABETPhonemeAdapters;
}
/** Returns whether this is the primary pronunciation.
*
* @return the indicator whether this is the primary pronunciation
*/
public boolean isPrimaryPronunciation() {
return isPrimaryPronunciation;
}
/** Returns the string of phoneme names for this pronounciation.
*
* @return the string of phoneme names for this pronounciation
*/
public String getPhonemeString() {
final StringBuilder stringBuilder = new StringBuilder(Constants.STRING_BUILDER_SIZE_SMALL);
for (final ARPABETPhonemeAdapter arpabetPhonemeAdapter : orderedARPABETPhonemeAdapters) {
if (stringBuilder.length() > 0) {
stringBuilder.append(' ');
}
stringBuilder.append(arpabetPhonemeAdapter.getPhoneme().getName());
}
return stringBuilder.toString();
}
}
See more files for this project here