#NEWLINE# def get_grammar( self ) : #NEWLINE# #INDENT# '\n        Returns the grammar of the UAI file.\n        ' #NEWLINE# network_name = Word ( alphas ) . setResultsName ( 'network_name' ) #NEWLINE# no_variables = Word ( nums ) . setResultsName ( 'no_variables' ) #NEWLINE# grammar = ( network_name + no_variables ) #NEWLINE# self . no_variables = int ( grammar . parseString ( self . network ) [ 'no_variables' ] ) #NEWLINE# domain_variables = ( Word ( nums ) * self . no_variables ) . setResultsName ( 'domain_variables' ) #NEWLINE# grammar += domain_variables #NEWLINE# no_functions = Word ( nums ) . setResultsName ( 'no_functions' ) #NEWLINE# grammar += grammar #NEWLINE# self . no_functions = int ( grammar . parseString ( self . network ) [ 'no_functions' ] ) #NEWLINE# integer = Word ( nums ) . setParseAction ( ( lambda t : int ( t [ 0 ] ) ) ) #NEWLINE# for function in range ( 0 , self . no_functions ) : #NEWLINE# #INDENT# scope_grammar = Word ( nums ) . setResultsName ( ( 'fun_scope_' + str ( function ) ) ) #NEWLINE# grammar += scope_grammar #NEWLINE# function_scope = grammar . parseString ( self . network ) [ ( 'fun_scope_' + str ( function ) ) ] #NEWLINE# function_grammar = ( integer * int ( function_scope ) ) . setResultsName ( ( 'fun_' + str ( function ) ) ) #NEWLINE# grammar += function_grammar #NEWLINE# #UNINDENT# floatnumber = Combine ( ( Word ( nums ) + Optional ( ( Literal ( '.' ) + Optional ( Word ( nums ) ) ) ) ) ) #NEWLINE# for function in range ( 0 , self . no_functions ) : #NEWLINE# #INDENT# no_values_grammar = Word ( nums ) . setResultsName ( ( 'fun_no_values_' + str ( function ) ) ) #NEWLINE# grammar += no_values_grammar #NEWLINE# no_values = grammar . parseString ( self . network ) [ ( 'fun_no_values_' + str ( function ) ) ] #NEWLINE# values_grammar = ( floatnumber * int ( no_values ) ) . setResultsName ( ( 'fun_values_' + str ( function ) ) ) #NEWLINE# grammar += values_grammar #NEWLINE# #UNINDENT# return grammar