Beispiel #1
0
  def end_td(self):
    #print "end of a table data"
    #print "-" ,self.td_data , "-"
    #print myParser.clearWord(self,self.td_data)

    self.td_data = myParser.clearWord(self,self.td_data)

    #matching on the second column (german) and getting the translation from 2 column's on the left
    if self.td_data.lower() == self.word.lower(): #found word
      #print self.td_data
      self.keyword_found = True
      if self.from_lang == "de": #then get the one that is two td_data behind (using the stack)
        #print "Translation: ", self.td_data_stack[0]
        Parley.addTranslation(self.word,self.from_lang,self.to_lang,self.td_data_stack[0].strip())

    #matching on the first column (not german) and getting the translation from 2 column's on the right
    if self.in_translation_td: #found translation
      if self.from_lang != "de":
        #print "Translation: ", self.td_data
        Parley.addTranslation(self.word,self.from_lang,self.to_lang,self.td_data.strip())
      self.in_translation_td = False
      self.td_after = 0
      self.keyword_found = False

    #append td_data on the stack that keeps the last two ones
    self.td_data_stack.append(self.td_data)
    
    #make it keep only the last 2 td_data (works since we append only one item at a time)
    if len(self.td_data_stack) > 2:
      self.td_data_stack.pop(0)

    self.td_data = ""
    
    self.in_small = False
Beispiel #2
0
 def handle_data(self,data):
   if data == "Web definitions": self.stop = True #to make it stop after the web definitions
   if len(self.tags_stack) > 0 and self.tags_stack[len(self.tags_stack)-1] == "<!translation!>":
       #print "data: ", data
       self.words.append(data.strip())
       #print self.word, self.from_lang, self.to_lang
       if self.stop == False:
         w = self.clearWord(data)
         Parley.addTranslation(self.word,self.from_lang,self.to_lang,w)
Beispiel #3
0
    def end_td(self):
        #print "end of a table data"
        #print "-" ,self.td_data , "-"
        #print myParser.clearWord(self,self.td_data)

        self.td_data = myParser.clearWord(self, self.td_data)

        #matching on the second column (german) and getting the translation from 2 column's on the left
        if self.td_data.lower() == self.word.lower():  #found word
            #print self.td_data
            self.keyword_found = True
            if self.from_lang == "de":  #then get the one that is two td_data behind (using the stack)
                #print "Translation: ", self.td_data_stack[0]
                Parley.addTranslation(self.word, self.from_lang, self.to_lang,
                                      self.td_data_stack[0].strip())

        #matching on the first column (not german) and getting the translation from 2 column's on the right
        if self.in_translation_td:  #found translation
            if self.from_lang != "de":
                #print "Translation: ", self.td_data
                Parley.addTranslation(self.word, self.from_lang, self.to_lang,
                                      self.td_data.strip())
            self.in_translation_td = False
            self.td_after = 0
            self.keyword_found = False

        #append td_data on the stack that keeps the last two ones
        self.td_data_stack.append(self.td_data)

        #make it keep only the last 2 td_data (works since we append only one item at a time)
        if len(self.td_data_stack) > 2:
            self.td_data_stack.pop(0)

        self.td_data = ""

        self.in_small = False
Beispiel #4
0
def translateWord(word,fromLang,toLang):
  print "myscript1: Translating Word ...", word, fromLang, toLang
  Parley.addTranslation("Hello","en_US","fr","bonbon")
Beispiel #5
0
def translateWord(word, fromLang, toLang):
    print "myscript1: Translating Word ...", word, fromLang, toLang
    Parley.addTranslation("Hello", "en_US", "fr", "bonbon")