def translateCelebration(self):        
     #handle multiple optionals
     celeb=""
     if isinstance(self.descr, list):
         for i,string in enumerate(self.descr):
             if i!=0:
                 celeb += Translation.translate('or_other')+" "
             celeb+=Translation.translate(string)
             if isinstance(self.saintrank, list) and self.saintrank[i]:
                 celeb+=", " + Translation.translate(str(self.saintrank[i]))
     else:
         celeb+=Translation.translate(self.descr)
         if self.saintrank:
             celeb+=", " + Translation.translate(str(self.saintrank))
     return celeb
Exemple #2
0
    def __init__(self, track=lk_track.TrackLK):
        super(Position, self).__init__(track)
        self.rotation = Rotation.Rotation(track)
        self.translation = Translation.Translation(self.rotation.GetRad(),
                                                   track)

        self.rotationSum = 0
        self.pathLen = 0
        self.location = [0, 0]
        self.loc = []
        self.trackP = track
        self.heading = 0
        self.trans = 0.059

        self.flag = 1
        self.timer = QtCore.QTimer(QtCore.QThread())
Exemple #3
0
def get_translated_ontology(engpath: str) -> str:
    """ Wrapper function for the main translation function. Main purpose is to add a return value.

    Takes the path to an English ontology and returns the path to the translated Romanian ontology.
    The Romanian ontology will be deposited in the same folder as the original ontology but will have '_ro'
    appended at the end of its name('ont_1.owl' will become 'ont_1_ro.owl').

    Args:
            engpath (str):  The path to the ontology to be translated.

    Return:
            str:            The path to the translated ontology.
    """
    ropath = f'{os.path.splitext(engpath)[0]}_ro{os.path.splitext(engpath)[1]}'
    engpath = f'file://{engpath}'
    Translation.Translate(engpath, ropath)
    return ropath
 def printAll_TR(self,locale):
     """Prints a csv-formatted string containing all informations pertaining to the day, translated in given locale"""
     if Translation.getLocale() != locale:
         try:
             Translation.setLocale(locale)
         except Exception as e:
             print e
             Translation.setLocale("en-EN")
         
     retStr=str(self.date.date())+";"+str(self.season)+";"+Translation.translate(self.printColor())+";"+Translation.translate(self.printRank())+";"+self.translateCelebration()
     
     if self.saintrank:
         retStr+=";"+self.printSaint()
     else:
         retStr+=";"
     if(self.ommitted != None):
         retStr+=";"+"[ "+Translation.translate("ommited")+" " + self.ommitted.translateCelebration() +" ("+Translation.translate(self.ommitted.printRank())+") ]"
     if self.originalDate:
         retStr+=";"+"( "+Translation.translate("mov_from")+" "+str(self.originalDate.date())+")"
     return retStr;
Exemple #5
0
    def test(self):

        for i, word in enumerate(self.result):
            self.assertEqual(Translation.translate(self.input1[i]), word)

        self.assertEqual(Translation.translate(input1), output)
Exemple #6
0
    def interpretParameters(self):
        params = self.params

        # CHECK IF THE CELL CONTAINS A LATTICE
        self.hasLAT = False
        if (params.has_key('LAT')):
            # a cell containing a LAT also needs to have a FILL parameter
            if (params.has_key('FILL') or params.has_key('*FILL')):
                self.hasLAT = True
                self.typeLAT = int(params['LAT'])

                if ((self.typeLAT == 1) or (self.typeLAT == 2)):
                    # the cell describes a rectangular (square) lattice comprised of hexehedra
                    ranges = re.match(
                        '[ ]*[-]?[\d]+[:]{1}[\d]+[ ]+[-]?[\d]+[:]{1}[\d]+[ ]+[-]?[\d]+[:]{1}[\d]+[ ]+',
                        params['FILL'][:100])
                    if (ranges):
                        # parse the fully specified boundaries of the lattice
                        rangesItems = re.findall('[-]?[\d]+', ranges.group(0))
                        if (len(rangesItems) == 6):
                            self.minI = int(rangesItems[0])
                            self.maxI = int(rangesItems[1])
                            self.minJ = int(rangesItems[2])
                            self.maxJ = int(rangesItems[3])
                            self.minK = int(rangesItems[4])
                            self.maxK = int(rangesItems[5])
                        else:
                            raise (Exception(
                                "ERROR (Parse Cell " + str(self.number) +
                                "): Problem reading fill boundary parameters, too little args in cell "
                                + str(self.number)))

                        # parse the universes of the lattice
                        latUniverses = re.split(
                            '[\s]+', params['FILL'][len(ranges.group(0)):])
                        container.Container.remove_values_from_list(
                            latUniverses, '')
                        # check for parameters in lattice universes
                        # for example 200 10R (repeat 200 ten times)
                        latUniversesNew = []
                        for i in range(0, len(latUniverses)):
                            if (
                                    latUniverses[i][len(latUniverses[i]) - 1]
                                    == 'R'
                                    or latUniverses[i][len(latUniverses[i]) -
                                                       1] == 'r'
                            ):  #re.match('R$',latUniverses[i], flags=re.IGNORECASE)):
                                previousElement = latUniversesNew[
                                    len(latUniversesNew) - 1]
                                elements = int(
                                    latUniverses[i][:len(latUniverses[i]) - 1])
                                for x in range(0, elements):
                                    latUniversesNew.append(previousElement)
                            else:
                                latUniversesNew.append(latUniverses[i])
                        self.latUniverses = latUniversesNew
                    else:
                        #print "ERROR (Cell " + str(self.number) + "): no fully specified fill found in cell " + str(self.number) + " [CellCard::interpretParameters]"
                        raise (Exception(
                            "ERROR (Parse Cell " + str(self.number) +
                            "): No fully specified fill found in cell " +
                            str(self.number)))
                else:
                    raise (Exception("ERROR (Parse Cell " + str(self.number) +
                                     "): Cell " + str(self.number) +
                                     " contains a LAT with unknown type " +
                                     str(self.typeLAT)))
            else:
                raise (Exception("ERROR (Parse Cell " + str(self.number) +
                                 "): Cell " + str(self.number) +
                                 " contains LAT, but no FILL"))
                print
                return 0
        elif (params.has_key('FILL') or params.has_key('*FILL')):
            if (not self.hasLAT):
                if params.has_key('FILL'):
                    fill = params['FILL']
                else:
                    fill = params['*FILL']

                # get all the items between the brackets (these are the transform parameters)
                transformParams = re.findall('(?<=\()[\d,\D,\s]+(?=\))', fill)
                self.fillUniverse = int(re.split('[\(,\[]+', fill)[0])

                # if there is a transformation, parse the transformation data and put it in a Transformation object
                if (len(transformParams) >= 1):
                    # split the transform parameters and remove empty items
                    transformParamsItems = re.split('[\s]+',
                                                    transformParams[0])
                    container.Container.remove_values_from_list(
                        transformParamsItems, '')

                    # check if there is a translation defined on the fill parameters
                    if (len(transformParamsItems) >= 3):
                        self.universeTranslation = Translation.Translation(
                            transformParamsItems[0], transformParamsItems[1],
                            transformParamsItems[2])

                    # check if there is a rotation defined on the fill parameters
                    if (len(transformParamsItems) >= 12):
                        if (params.has_key('*FILL')):
                            for i in range(3, len(transformParamsItems)):
                                transformParamsItems[i] = math.cos(
                                    float(transformParamsItems[i]) * math.pi /
                                    180.0)
                        self.universeRotation = Rotation.Rotation(
                            transformParamsItems[3], transformParamsItems[4],
                            transformParamsItems[5], transformParamsItems[6],
                            transformParamsItems[7], transformParamsItems[8],
                            transformParamsItems[9], transformParamsItems[10],
                            transformParamsItems[11])

        if (params.has_key('TRCL')):
            trcl = params['TRCL']
            transformParams = re.findall('(?<=\()[\d,\D,\s]+(?=\))', trcl)
            if (len(transformParams) >= 1):
                transformParamsItems = re.split('[\s]+', transformParams[0])

                # check if there is a translation defined on the fill parameters
                if (len(transformParamsItems) >= 3):
                    self.translation = Translation.Translation(
                        transformParamsItems[0], transformParamsItems[1],
                        transformParamsItems[2])

                # check if there is a rotation defined on the fill parameters
                if (len(transformParamsItems) >= 12):
                    self.rotation = Rotation.Rotation(
                        transformParamsItems[3], transformParamsItems[4],
                        transformParamsItems[5], transformParamsItems[6],
                        transformParamsItems[7], transformParamsItems[8],
                        transformParamsItems[9], transformParamsItems[10],
                        transformParamsItems[11])

        elif (params.has_key('*TRCL')):
            trcl = params['*TRCL']
            transformParams = re.findall('(?<=\()[\d,\D,\s]+(?=\))', trcl)
            if (len(transformParams) >= 1):
                transformParamsItems = re.split('[\s]+', transformParams[0])

                # check if there is a translation defined on the fill parameters
                if (len(transformParamsItems) >= 3):
                    self.translation = Translation.Translation(
                        transformParamsItems[0], transformParamsItems[1],
                        transformParamsItems[2])

                # check if there is a rotation defined on the fill parameters
                if (len(transformParamsItems) >= 12):
                    for i in range(3, len(transformParamsItems)):
                        transformParamsItems[i] = math.cos(
                            float(transformParamsItems[i]) * math.pi / 180.0)
                    self.rotation = Rotation.Rotation(
                        transformParamsItems[3], transformParamsItems[4],
                        transformParamsItems[5], transformParamsItems[6],
                        transformParamsItems[7], transformParamsItems[8],
                        transformParamsItems[9], transformParamsItems[10],
                        transformParamsItems[11])
        return 1
Exemple #7
0
import sys
import subprocess

print("-----------------------------------------")
file_name = input(
    "输入'/帮助',则进入SCPython的使用帮助\n输入'/自定义',则进入自定义模式\n输入SCPython代码文件地址则执行解释\n\n请输入:"
)

while file_name == "":

    file_name = input("您刚才未输入指令,请重新输入:")

if file_name == "/帮助":
    pass
elif file_name == "/自定义":
    pass
else:
    file = open(file_name, encoding='utf-8')
    file_text = file.read()

    List_Code = Pretreatment.Decomposition_Code(file_text)

    Text = Translation.Translation_Code(List_Code)

    file_new = open(os.environ["TMP"] + "\SCPYFile.py", "w", encoding='utf-8')
    file_new.write(Text)
    file_new.close()
    os.system('cls')

    os.system(os.environ["TMP"] + r'"\SCPYFile.py"')
Exemple #8
0
    def processContent(self):
        if self.filetype == "ON":
            # Kick the useless first entry
            for a in range(1,len(self.rawcontent)):
                # Kick useless empty lines
                if self.rawcontent[a] != "" and "#begin" not in self.rawcontent[a] and "#end" not in self.rawcontent[a]:
                    splitLine = self.rawcontent[a].split()
                    # Pick out the juicy bits
                    dummy_lemma = Lemma.Lemma(int(splitLine[1]), int(splitLine[2]), str(splitLine[3]).lower(), str(splitLine[4]), str(splitLine[6]).lower(), str(splitLine[8]))
                    self.procontent.append(dummy_lemma)
        if self.filetype == "IN":
            # Kick the useless first 29 entries
            for a in range(29,len(self.rawcontent)):
                # Kick useless empty lines
                if self.rawcontent[a] != "":
                    splitLine = self.rawcontent[a].split()
                    # Pick out the juicy bits
                    dummy_list_of_senses = []
                    # Check for multiple senses
                    for b in range(6,len(splitLine)):
                        if len(splitLine[b]) > 3:
                            dummy_list_of_senses.append(splitLine[b])
                    # Putting juicy bits together
                    dummy_translation = Translation.Translation(str(splitLine[0]), str(splitLine[1]), dummy_list_of_senses)
                    self.procontent.append(dummy_translation)
        if self.filetype == "FW":
            # Kick the useless first 25 entries
            for a in range(25,len(self.rawcontent)):
                # Kick useless empty lines
                if self.rawcontent[a] != "" and "//" not in self.rawcontent[a]:
                    # Check for multiple examples
                    splitLine = self.rawcontent[a].split(", ")
                    dummy_functionWords = []
                    # Take all examples
                    for b in range(len(splitLine)):
                        # Kick constructions of multiple words
                        if " " not in splitLine[b]:
                            self.procontent.append(splitLine[b])
        if self.filetype == "TL":
            dummy_senselists = []
            dummy_switch = False
            # Get the info from filename back
            dir = os.path.realpath(__file__)
            dummy_string = self.filename.replace("\\".join(dir.split("\\")[:-1])+"\\Translation\\","").replace(".xml","")
            dummy_word_and_type = dummy_string.split("-")

            for a in range(0,len(self.rawcontent)):
                # Look out for juicy bits
                #
                # The following part is NSFW
                #
                # This is a dummy in case the file just wanted to put info in a new line
                
                if dummy_switch == True:
                    
                    dummy_string = self.rawcontent[a]
                    # This is in case the file wanted to add an additional empty line
                    if dummy_string != "":
                        # Yes, there are files with additional info instead
                        if "<wn lemma" not in dummy_string and dummy_string != "-" and "<omega" not in dummy_string:
                            splitLine = dummy_string.split(" ")
                            dummy_list = []
                            for b in range(len(splitLine)):
                                try:
                                    dummy_list.append(int(splitLine[b]))
                                # It is 3am , now I stop to care and start to botch
                                except ValueError:
                                    dummy_splitLine = splitLine[0].split(",")
                                    dummy_list.append(int(dummy_splitLine[b]))
                            dummy_senselists.append(dummy_list)
                            #print dummy_senselists
                        elif dummy_string != "-":
                            dummy_senselists.append([0])
                            #print dummy_senselists
                        # This is not the normal format either    
                        else:
                            # Kick useless stuff
                            dummy_splitLine1 = dummy_string.split("version=\"3.0\">")
                            dummy_splitLine2 = dummy_splitLine1[-1].split("</wn>")
                            splitLine = dummy_splitLine2[0].split(",")
                            if splitLine[0] != "" and splitLine[0] != "-":
                                dummy_list = []
                                for b in range(len(splitLine)):
                                        dummy_list.append(int(splitLine[b]))
                                dummy_senselists.append(dummy_list)
                                #print dummy_senselists
                        ###    elif splitLine[0] == "-":
                        ###        dummy_senselists.append([0])
                            else: 
                                dummy_senselists.append([0])
                                #print dummy_senselists
                        dummy_switch = False
                # That is the normal format I would say. Not sure though.
                if "<wn version=\"3.0\">" in self.rawcontent[a]:
                    # Kick the useless stuff around juicy bit
                    dummy_string = self.rawcontent[a].replace("<wn version=\"3.0\">","").replace("</wn>","").replace("<omega/>","")
                    splitLine = dummy_string.split(",")
                    if splitLine[0] != "" and splitLine[0] != "NM":
                        dummy_list = []
                        for b in range(len(splitLine)):
                            if "." in splitLine[b]:
                                dummy_list.append(int(splitLine[b].split(".")[0]))
                            else:
                                dummy_list.append(int(splitLine[b]))
                        dummy_senselists.append(dummy_list)
                        #print dummy_senselists
                    elif splitLine[0] == "NM":
                        dummy_senselists.append([0])
                        #print dummy_senselists
                    else:
                        dummy_switch = True
                if "<wn version=\"1.7\">" in self.rawcontent[a]:
                    # Blub
                    dummy_string = self.rawcontent[a].replace("<wn version=\"1.7\">","").replace("</wn>","").replace("<omega/>","")
                    splitLine = dummy_string.split(",")
                    if splitLine[0] != "" and splitLine[0] != "NM" and splitLine[0] != "?":
                        dummy_list = []
                        for b in range(len(splitLine)):
                            if "." in splitLine[b]:
                                dummy_list.append(int(splitLine[b].split(".")[0]))
                            else:
                                dummy_list.append(int(splitLine[b]))
                        dummy_senselists.append(dummy_list)
                        #print dummy_senselists
                    elif splitLine[0] == "NM" or splitLine[0] == "?" or splitLine[0] == "-":
                        dummy_senselists.append([0])
                        #print dummy_senselists
                    else:
                        dummy_switch = True
                # By now, anything could happen in these lines
                if "<wn version=\"2.0\">" in self.rawcontent[a] and "</wn>" in self.rawcontent[a]:
                    dummy_list = []
                    dummy_string = self.rawcontent[a]
                    dummy_splitLine1 = dummy_string.split("version=\"2.0\">")
                    dummy_splitLine2 = dummy_splitLine1[-1].split("</wn>")
                    dummy_splitLine3 = dummy_splitLine2[0].split(",")
                    splitLine = dummy_splitLine3[0].split(" ")
                    if splitLine[0] != "" and splitLine[0] != "-" and splitLine[0] != "Placeholder":
                        dummy_list = []
                        for b in range(len(splitLine)):
                            try:
                                dummy_list.append(int(splitLine[b]))
                            except ValueError:
                                print self.rawcontent[a]
                                print self.filename
                        dummy_senselists.append(dummy_list)
                        #print dummy_senselists
                    else: 
                        dummy_senselists.append([0])
                        #print dummy_senselists
                if "<wn version=\"2.0\">" in self.rawcontent[a] and "</wn>" not in self.rawcontent[a]:
                    dummy_switch = True
            dummy_translator = Translator.Translator(dummy_word_and_type[0],dummy_word_and_type[1],dummy_senselists)
            self.procontent.append(dummy_translator)
Exemple #9
0
def translate(message):
    args = message.text.replace("/translate", "")
    text = Translation.google_translate(args)
    bot.send_message(message.chat.id, 'Translation: ' + text)
    return text
Exemple #10
0
from Hamilton import *
from Rotation import *
from Translation import *

H = Hamilton()
R = Rotation()
T = Translation()


class Desired:
    @staticmethod
    def quaternion(p, o, a):
        z = np.array([1, 0, 0, 0, 0, 0.5 * p[0], 0.5 * p[1], 0.5 * p[2]])
        if a == 'X' or a == 'x' or a == 88 or a == 120:
            z = H.left(z).dot(R.x(o))
        elif a == 'Y' or a == 'y' or a == 89 or a == 121:
            z = H.left(z).dot(R.y(o))
        elif a == 'Z' or a == 'z' or a == 90 or a == 122:
            z = H.left(z).dot(R.z(o))
        return z
Exemple #11
0
		print " -alndir dir with alignment files"
		print ""
		sys.exit(0)

#
# Function call
#


if __name__ == '__main__':

	util          = aln_util()
	tree_util     = TreeUtility.tree_utility()
	file_util     = FileUtility.file_util()
	fasta_manager = FastaManager.fasta_manager()
	trans         = Translation.translate()
	draw_block    = DrawBlocks.draw_blocks()
	function = pep = nt = pairs = group = gdom = clade = pick = aln_profile = ""
	keep = window  = justka = bootstrap = isdir = x4 = debug = 0
	step = mode = sp = 1
	clustal =""
	prog    ="paml"
	paml    ="paml"
	wdir    ="./"
	ks      ="full"
	phydir = ""
	alndir = ""
	
	for i in range(1,len(sys.argv),2):
		if sys.argv[i] == "-f":
			function   = sys.argv[i+1]