marytts.language.tib
Class Phonemiser

java.lang.Object
  extended by marytts.modules.InternalModule
      extended by marytts.language.tib.Phonemiser
All Implemented Interfaces:
MaryModule

public class Phonemiser
extends InternalModule

The Tibetan Phonemiser First checks, if the tokens are defined in the lexicon (lexicon_tib.txt) If not, letter-to-sound rules (defined in syllableRules.xml) are applied Created on 24.05.2005

Author:
Anna Hunecke

Field Summary
 
Fields inherited from class marytts.modules.InternalModule
logger, state
 
Fields inherited from interface marytts.modules.MaryModule
MODULE_OFFLINE, MODULE_RUNNING
 
Constructor Summary
Phonemiser()
          Constructor
 
Method Summary
 java.lang.String act(org.w3c.dom.Element action, org.w3c.dom.Element syllable)
          Carry out the action specified in an action-node
 java.lang.String applyRules(org.w3c.dom.Element e, org.w3c.dom.Element syllable, org.w3c.dom.Element nextSyl, org.w3c.dom.Element prevSyl, int sylpos, int maxsyl)
          Find the first rule that matches and apply it
 void buildDefinitions()
          Read in the general definitions of wylie-symbols, sampa-symbols and conditions
 void buildLexicon()
          Build the lexicon
 boolean checkAttributes(org.w3c.dom.Element attributes, org.w3c.dom.Element syllable)
          Look at an attributes-node and determine if its specifications match to the syllable
 boolean checkCondition(org.w3c.dom.Element condition, org.w3c.dom.Element syllable, int sylpos, int maxsyl)
          Determine if the conditions in a condition-node are fulfilled by a syllable
 void checkSampaDef(java.lang.String num, java.lang.String sampa, java.util.HashSet atts)
          Check a sampa definition of an action node
 java.lang.String[] lookUp(java.lang.String text)
          Look up a token in the lexicon
 MaryData process(MaryData d)
          Process the data
 void processToken(org.w3c.dom.Element token)
          process a token of the data
 void startup()
          Read in the data of the xml file; test if list, maps and rules are correct; build the lexicon
 void testFailAction(org.w3c.dom.Element act, java.lang.String num, java.util.HashSet atts)
          Test, if an action node is correct
 java.util.HashSet testFailAttributes(org.w3c.dom.Element att, java.lang.String num)
          Test, if the attributes node is correct Is also used for nextattributes and prevattributes
 void testFailCondition(org.w3c.dom.Element cond, java.lang.String num)
          Test, if a condition node is correct
 void testFailDefinitions()
          Test, if the lists and maps in the definitions-section are correct
 void testFailRules(org.w3c.dom.NodeList rules)
          Test, if the rules in the NodeList are correct
 
Methods inherited from class marytts.modules.InternalModule
getLocale, getState, inputType, name, outputType, powerOnSelfTest, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Phonemiser

public Phonemiser()
Constructor

Method Detail

startup

public void startup()
             throws java.lang.Exception
Read in the data of the xml file; test if list, maps and rules are correct; build the lexicon

Specified by:
startup in interface MaryModule
Overrides:
startup in class InternalModule
Throws:
an - Exception, if there are Errors in the xml file
java.lang.Exception

buildDefinitions

public void buildDefinitions()
Read in the general definitions of wylie-symbols, sampa-symbols and conditions


testFailDefinitions

public void testFailDefinitions()
Test, if the lists and maps in the definitions-section are correct

Throws:
IllegalArgumentException, - if the definitions are not correct

testFailRules

public void testFailRules(org.w3c.dom.NodeList rules)
Test, if the rules in the NodeList are correct

Parameters:
rules - the NodeList of rules
Throws:
IllegalArgumentException, - if there is a rule without a number

testFailAttributes

public java.util.HashSet testFailAttributes(org.w3c.dom.Element att,
                                            java.lang.String num)
Test, if the attributes node is correct Is also used for nextattributes and prevattributes

Parameters:
att - the attributes node
num - the number of the rule
Returns:
a set of the attributes
Throws:
IllegalArgumentException, - if the attributes node is not correct

testFailCondition

public void testFailCondition(org.w3c.dom.Element cond,
                              java.lang.String num)
Test, if a condition node is correct

Parameters:
cond - the condition node
num - the number of the rule
Throws:
IllegalArgumentException, - if the condition node is not correct

testFailAction

public void testFailAction(org.w3c.dom.Element act,
                           java.lang.String num,
                           java.util.HashSet atts)
Test, if an action node is correct

Parameters:
act - the action node
num - the number of the rule
atts - the attributes of the attributes node of the rule
Throws:
IllegalArgumentException, - if the action node is not correct

checkSampaDef

public void checkSampaDef(java.lang.String num,
                          java.lang.String sampa,
                          java.util.HashSet atts)
                   throws java.lang.IllegalArgumentException
Check a sampa definition of an action node

Parameters:
num - the name of the current rule
sampa - the sampa definition
atts - the attributes of the rule (from attribute node)
Throws:
java.lang.IllegalArgumentException - if definition not correct

buildLexicon

public void buildLexicon()
                  throws java.lang.Exception
Build the lexicon

Throws:
java.lang.Exception - if there are problems reading the file

process

public MaryData process(MaryData d)
                 throws java.lang.Exception
Process the data

Specified by:
process in interface MaryModule
Overrides:
process in class InternalModule
Parameters:
d - the data to be processed
Returns:
the result of the processing
Throws:
java.lang.Exception

processToken

public void processToken(org.w3c.dom.Element token)
process a token of the data

Parameters:
token - the syllable to be processed

lookUp

public java.lang.String[] lookUp(java.lang.String text)
Look up a token in the lexicon

Parameters:
text - the text of the token
Returns:
a string array of the entry, or null, if text is not in lexicon

applyRules

public java.lang.String applyRules(org.w3c.dom.Element e,
                                   org.w3c.dom.Element syllable,
                                   org.w3c.dom.Element nextSyl,
                                   org.w3c.dom.Element prevSyl,
                                   int sylpos,
                                   int maxsyl)
Find the first rule that matches and apply it

Parameters:
e - the element that contains the rules
syllable - the syllable to be processed
sylpos - the position of the syllable in the word (0 to maxsyl)
maxsyl - the number of syllables in the word (starting with 0)
Returns:
the sampa string found in the rules

checkAttributes

public boolean checkAttributes(org.w3c.dom.Element attributes,
                               org.w3c.dom.Element syllable)
Look at an attributes-node and determine if its specifications match to the syllable

Parameters:
attributes - the attributes-node
syllable - the syllable to be matched
Returns:
true, if the attributes-node matches

checkCondition

public boolean checkCondition(org.w3c.dom.Element condition,
                              org.w3c.dom.Element syllable,
                              int sylpos,
                              int maxsyl)
Determine if the conditions in a condition-node are fulfilled by a syllable

Parameters:
condition - the condition-node
syllable - the syllable
sylpos - the position of the syllable in the word (0 to maxsyl)
maxsyl - the number of syllables in the word (starting with 0)
Returns:
true, if the conditions are satisfied

act

public java.lang.String act(org.w3c.dom.Element action,
                            org.w3c.dom.Element syllable)
Carry out the action specified in an action-node

Parameters:
action - the action-node
syllable - the syllable
Returns:
the result of the action