def sqrt(self,input,start):
        '''Translates roots into speech.
        returns touple.'''
        
        if self.sqrt_with_two_args.match(input):
            first_arg =latex_access.get_optional_arg(input, start)
            second_arg=get_arg(input, first_arg[1])
            
            if first_arg[0] =="2":
                translation =u" square "
            elif first_arg[0] =="3":
                translation =u" cube "
            elif first_arg[0].lower() =="n":
                translation =u"enth "
            elif first_arg[0].lower() =="x":
                translation =u"exth "
            elif first_arg[0] =="":
                translation =u""
            else:
                translation =first_arg[0] +u"th "
                
            if len(second_arg[0]) ==1:
                translation +=u"root " +self.correct(self.translate(second_arg[0]))
            else:
                translation +=u"root of " +self.correct(self.translate(second_arg[0]))
                translation +=u" end root "
            return (translation,second_arg[1])

        arg=get_arg(input,start)
        if arg[0].isdigit() or len(arg[0])==1:
            translation =u" root " +arg[0] +u" "
        else:
            translation =u" root of " +self.correct(self.translate(arg[0])) +u" end root "
        return (translation,arg[1])
 def newcommand(self, input, start):
     command = latex_access.get_arg(input, start)
     args = latex_access.get_optional_arg(input, command[1])
     if args:
         start = args[1]
         args = int(args[0])
     else:
         args = 0
         start = command[1]
     translation = latex_access.get_arg(input, start)
     self.preprocessor.add_from_string(command[0], args, translation[0])
     return ("", translation[1])
Beispiel #3
0
    def sqrt(self,input,start,rting=()):
        '''Translatesroots in latex.

        Returns a touple as above.'''
        arg=get_optional_arg(input,start)
        if arg:
            translation=";;%9"+self.translate(arg[0])
            arg=get_arg(input,arg[1])
            translation+=self.translate(arg[0])+"+"
        else:
            arg=get_arg(input,start)
            if rting != ():
                translation="%"+self.translate(arg[0],(rting[0]+arg[2],rting[1]+1))+"+"
            else:
                translation="%"+self.translate(arg[0])+"+"
        return (translation,arg[1])
Beispiel #4
0
 def sqrt(self,input,start):
     '''Translates squareroots into speech.
     
     returns touple.'''
     opt_arg=latex_access.get_optional_arg(input, start)
     if opt_arg:
         arg=get_arg(input,opt_arg[1])
         if opt_arg[0]=="2": opt="square"
         elif opt_arg[0]=="3": opt="cube"
         elif opt_arg[0]=="": opt=""
         else: opt=opt_arg[0]+"th"
     else:
         arg=get_arg(input,start)
         opt=""
     if arg[0].isdigit() or len(arg[0])==1:
         translation="%s root %s" %(opt,arg[0])
     else:
         translation=" begin %s root %s end root" % (opt,self.translate(arg[0]))
     return (translation,arg[1])
Beispiel #5
0
	def sqrt(self,input,start):
		'''Translates roots into speech.

		returns touple.'''
		if sqrt_with_two_args.match(input):
			first_arg =latex_access.get_optional_arg(input, start)
			second_arg=get_arg(input, first_arg[1])
			
			if self.abbrev_first_root_arg ==True:
				if first_arg[0].isdigit() or len(first_arg[0]) ==1:
					translation =denominators[int(first_arg[0])] +" "
				elif first_arg[0] in ["x", "n"] and len(first_arg[0]) ==1:
					translation =first_arg[0] +u"-ed "
				elif first_arg[0] =="3":
					translation =u" köb "
				else:
					translation =self.correct(self.translate(first_arg[0])) +u". "

			else:
				if first_arg[0] =="3":
					translation =u" köb "
				elif first_arg[0].lower() =="n":
					translation =u"n-edik "
				elif first_arg[0] =="x":
					translation ="x-edik "
				else:
					translation =self.correct(self.translate(first_arg[0])) +u". "
					
			if len(second_arg[0]) ==1:
				translation +=u" gyök " +self.correct(self.translate(second_arg[0]))
			else:
				translation +=u" gyök alatt, "+self.correct(self.translate(second_arg[0])) +u", gyök zár "
			return (translation, second_arg[1])
		
		arg=get_arg(input, start)
		if arg[0].isdigit() or len(arg[0])==1:
			translation=u" gyök " +arg[0]
		else:
			translation=u" gyök alatt, " +self.correct(self.translate(arg[0])) +u", gyök zár"
		return (translation,arg[1])