24 from global_parameters
import GlobalParams
26 from rapp_utilities
import RappUtilities
49 if configuration !=
None:
66 self.
_words = instance._words
74 RappUtilities.rapp_print(
"Reading preconfiguration: " + confName )
75 yamlStream = open( self._globalParams._sphinx_preconf,
'r' )
76 yamlFile = yaml.load(yamlStream)
77 if confName
not in yamlFile[
'configurations']:
78 RappUtilities.rapp_print(
'Wrong configuration name provided. Leaving ' + \
79 'default values',
'ERROR')
85 yamlLang = yamlFile[
'configurations'][confName][
'language']
87 tempConf._language = yamlLang.encode(
'utf-8')
89 RappUtilities.rapp_print(
'Configuration language not provided. ' + \
90 'Leaving default values',
'ERROR')
94 yamlWords = yamlFile[
'configurations'][confName][
'words']
96 tempConf._words = [word.encode(
'utf-8')
for word
in yamlWords]
98 RappUtilities.rapp_print(
'Configuration words not provided. ' + \
99 'Leaving default values',
'ERROR')
103 yamlSent = yamlFile[
'configurations'][confName][
'sentences']
105 tempConf._sentences = [sentence.encode(
'utf-8')
for sentence
in yamlSent]
107 RappUtilities.rapp_print(
'Configuration sentences not provided. ' + \
108 'Leaving default values',
'ERROR')
112 yamlGram = yamlFile[
'configurations'][confName][
'grammar']
114 tempConf._grammar = [grammar.encode(
'utf-8')
for grammar
in yamlGram]
116 tempConf._grammar = []
121 RappUtilities.rapp_print(
'Language: ' + str(self.
_language) )
122 RappUtilities.rapp_print(
'Words: ' + str(self.
_words) )
124 RappUtilities.rapp_print(
'word: ' + str(word) )
125 RappUtilities.rapp_print(
'Grammar: ' + str(self.
_grammar))
126 RappUtilities.rapp_print(
'Sentences: ' + str(self.
_sentences) )
135 if ( self.
_language == params.language
and \
136 self.
_words == params.words
and \
137 self.
_grammar == params.grammar
and \
153 hash_object = hashlib.sha1()
156 hash_object.update( word )
158 hash_object.update( gram )
160 hash_object.update( sent )
161 return hash_object.hexdigest()
def _readConfigurationYaml
Read the configuration from configuration yaml.
def getHash
Calculates the configuration's sha1 hash.
def equalsRequest
Checks if a SphinxConfigurationParams instance equals self.
_language
The language of the request.
def makeEqualToRequest
Change attributes to those specified by the request.
Contains the parameters required for the Sphinx configuration.
_grammar
Sphinx grammar attribute.
def __init__
Initializes an empty configuration (constructor)
_words
The words to be identified.
def makeEqualToInstance
Change attributes to those specified by the Class instance.
_globalParams
Contains global Sphinx parameters.
_sentences
Sphinx sentence attribute.