⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 featureprocessors.java

📁 这是java 开发的的免费语音播放插件,很值得学习参考!!!!!!!!!!!!111
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	 *	 * @return the position of the phoneme in the syllable	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    int count = -1;	    for (Item p = item.getItemAs(Relation.SYLLABLE_STRUCTURE); 		      p != null; p = p.getPrevious() )  {		count++;	    }	    return Integer.toString(rail(count));	}    }    /**     * Classifies the the syllable as single, initial, mid or final.     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PositionType implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 *	 * @return classifies the syllable as "single", "final",	 * "initial" or "mid"	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    String type;	    Item s = item.getItemAs(Relation.SYLLABLE_STRUCTURE); 	    if (s == null) {		type = "single";	    } else if (s.getNext() == null) {		if (s.getPrevious() == null) {		    type = "single";		} else {		    type = "final";		}	    } else if (s.getPrevious() == null) {		type = "initial";	    } else {		type = "mid";	    }	    return type;	}    }    /**     * Counts the number of stressed syllables since the last major break.     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class SylIn implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 * 	 * @return the number of stressed syllables since the last	 * major break	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    int count = 0;	    Item ss = item.getItemAs(Relation.SYLLABLE);	    Item firstSyllable  = FIRST_SYLLABLE_PATH.findItem(item);	    for (Item p = ss; p != null; p = p.getPrevious(), count++ )  {		if (p.equalsShared(firstSyllable)) {		    break;		}	    }	    return Integer.toString(rail(count));	}    }    /**     * Counts the number of stressed syllables since the last major break.     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class SylOut implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 *	 * @return the number of stressed syllables since the last	 * major break	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    int count = 0;	    Item ss = item.getItemAs(Relation.SYLLABLE);	    Item firstSyllable  = LAST_LAST_SYLLABLE_PATH.findItem(item);	    for (Item p = ss; p != null; p = p.getNext() )  {		if (p.equalsShared(firstSyllable)) {		    break;		}		count++;	    }	    return Integer.toString(rail(count));	}    }    /**     * Determines the break level after this syllable     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class SylBreak implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  syl  the item to process	 *	 * @return the break level after this syllable	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item syl) throws ProcessException {	    Item ss = syl.getItemAs(Relation.SYLLABLE_STRUCTURE);	    if (ss == null) {		return "1";	    } else if (ss.getNext() != null) {		return "0";	    } else if (ss.getParent() == null) {		return "1";	    } else {		return wordBreak(ss.getParent());	    }	}    }    /**     * Determines the word break.     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class WordBreak implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  word  the item to process	 *	 * @return the break level for this word	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item word) throws ProcessException {	    return wordBreak(word);	}    }    /**     * Determines the word punctuation.     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class WordPunc implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  word  the item to process	 *	 * @return the punctuation for this word	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item word) throws ProcessException {	    return wordPunc(word);	}    }    /**     * Return consonant cplace      *   l-labial a-alveolar p-palatal b-labio_dental d-dental v-velar     *     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PH_CPlace implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 *	 * @return consonant cplace	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    return getPhoneFeature(item, "cplace");	}    }    /**     * Return consonant type      *   s-stop f-fricative a-affricative n-nasal * l-liquid     *     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PH_CType implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 *	 * @return consonant type	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    return getPhoneFeature(item, "ctype");	}    }    /**     * Return consonant voicing      *   +=on -=off     *     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PH_CVox implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 * 	 * @return consonant voicing	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    return getPhoneFeature(item, "cvox");	}    }    /**     * Return vowel or consonant     *   +=on -=off     *     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PH_VC implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 *	 * @return vowel or consonant	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    return getPhoneFeature(item, "vc");	}    }    /**     * Return vowel frontness     *  1-front  2-mid 3-back     *     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PH_VFront implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 *	 * @return vowel frontness	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    return getPhoneFeature(item, "vfront");	}    }    /**     * Return vowel height     *   1-high 2-mid 3-low     *     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PH_VHeight implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 * 	 * @return vowel height	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    return getPhoneFeature(item, "vheight");	}    }    /**     * Return vowel length     *   s-short l-long d-dipthong a-schwa     *     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PH_VLength implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 *	 * @return vowel length	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    return getPhoneFeature(item, "vlng");	}    }    /**     * Return vowel rnd (lip rounding)     *   lip rounding  +=on -=off     *     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class PH_VRnd implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  item  the item to process	 *	 * @return volwel rnd	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item item) throws ProcessException {	    return getPhoneFeature(item, "vrnd");	}    }    /**     * Determines the onset size of this syllable     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class SylOnsetSize implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  syl  the item to process	 *	 * @return onset size of this syllable	 *	 * @throws ProcessException if an exception occurred during the	 * processing	 */	public String process(Item syl) throws ProcessException {	    int count = 0;	    Item daughter = syl.getItemAs(                Relation.SYLLABLE_STRUCTURE).getDaughter();	    while (daughter != null) {		if ("+".equals(getPhoneFeature(daughter, "vc"))) {		    break;		}		count++;		daughter = daughter.getNext();	    }	    return Integer.toString(rail(count));	}    }    /**     * Determines the coda size     * This is a feature processor. A feature processor takes an item,     * performs some sort of processing on the item and returns an object.     */    public static class SylCodaSize implements FeatureProcessor {	/**	 * Performs some processing on the given item.	 *	 * @param  syl  the item to process	 *	 * @return coda size	 *	 * @throws ProcessException if an exception occurred during the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -