Exemplo n.º 1
0
 def __init__(self):
     self.client = zulip.Client(site="https://fazeup.zulipchat.com/api/")
     self.subscribe_all()
     self.hacknews = Hackernews()
     self.trans = Translate()
     self.movie = Movie()
     self.lyrics = Lyrics()
     self.holiday = Holiday()
     self.currency = Currency()
     self.cricket = Cricket()
     # self.chatbot.train("chatterbot.corpus.english")
     self.crypto = Crypto()
     self.trans = Translate()
     self.g = Giphy()
     self.w = WikiPedia()
     # self.tw = Twimega()
     # self.motivate = Motivate()
     self.shortenedurl = Urlshortener()
     self.geo = Geocode()
     self.weather = Weather()
     self.dict_ = Dictionary()
     self.joke = Joke()
     self.pnr = Pnr()
     self.mustread = Mustread()
     self.ss = Ss()
     self.cricket = Cricket()
     self.poll = Poll()
     print("done init")
     self.subkeys = [
         "crypto", "translate", "define", "joke", "weather", "giphy", "pnr",
         "mustread", "poll", "hackernews", "hn", "HN", "motivate",
         "twitter", "screenshot", "memo", "cricnews", "help", "shorturl",
         "movie", "currency", "holiday", "lyrics"
     ]
Exemplo n.º 2
0
 def __init__(self):
     self.system_sound = SoundMP3('../sound/system_sound/registerd',
                                  '../sound/system_sound/dev')
     self.trans = Translate()
     self.gc_controller = GoogleCloudController('', api_key='')
     self.translater = Translate()
     self.forecast = Forecast('')
     self.mecab = MeCab.Tagger(
         "-d /home/linuxbrew/.linuxbrew/lib/mecab/dic/mecab-ipadic-neologd")
     self.temporary_data = ''
     self.return_state = {}
     self.jalan_controller = jalan_controller()
Exemplo n.º 3
0
 def targetcode(self):
     '''
     生成汇编代码
     :return:
     '''
     self.textBrowser.clear()
     t = Translate()
     s = self.textEdit.toPlainText()
     fg, info = t.entry(s)
     if fg:
         # t.optimize_code()
         ass_codes = gen_assemcodes(t.codes)
         info = ''.join(ass_codes)
         self.textBrowser.setText(info)
         self.textBrowser.selectAll()
         self.textBrowser.copy()
         # 提示已经复制到剪切板
         icon = QtGui.QIcon()
         icon.addPixmap(QtGui.QPixmap("icons/logo.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
         qw = QtWidgets.QWidget()
         qw.setWindowIcon(icon)
         QMessageBox.warning(qw, 'Tips', '汇编代码已复制!')
     else:
         pickle.dump((False, None), open('data/midway_sheet.pkl', 'wb'))
         info = '----- error !\n' + '\n'.join(info)
         self.textBrowser.setText(info)
     self.save()
 def translate_func(self):
     self.speak(
         'Opening Translate\nPlease Wait as opening Translate may take up to 4-5 seconds'
     )
     from translate import Translate
     self.translate_win = Translate()
     self.translate_win.show()
Exemplo n.º 5
0
 def Translate_event(self, value):
     val = self.memory.getData("translate")
     print("Evenement : Tranlate ??")
     if (val != "1"):
         print("Evenement : une demande de traduction de " + val)
         t = Translate(val)
         self.memory.raiseEvent("Translate_vers_Java", t)
Exemplo n.º 6
0
    def __update(self, event):
        tr = Translate()
        text = self.__TextArea.get(1.0, END)[:-1]
        if len(text) > 0:
            bin = tr.toBin(text)
            doubles = tr.getDoubles()

            self.__TextTranslatedArea.delete(1.0, END)
            self.__TextTranslatedArea.insert(1.0, bin)
            self.__ListDict.delete(1, END)

            doubles = sorted(doubles, key=lambda x: x[1])
            doubles.reverse()
            for d in doubles:
                if len(d) == 2:
                    letter = d[0]
                    count = d[1]
                    if letter == " ":
                        letter = "[SPACE]"
                    elif letter == "µ":
                        letter = "[NewLine]"
                        count -= 0
                    if count > 0:
                        self.__ListDict.insert(self.__ListDict.size(),
                                               letter + ": " + str(count))

        else:
            self.__TextTranslatedArea.delete(1.0, END)
            self.__TextTranslatedArea.insert(
                1.0, "le code Huffman apparaitera ici !")
            self.__ListDict.delete(1, END)
Exemplo n.º 7
0
 def __init__(self):
     self.client = zulip.Client(site="https://chunkzz.zulipchat.com/api/")
     self.subscribe_all()
     self.chatbot = ChatBot(
         "Omega", trainer='chatterbot.trainers.ChatterBotCorpusTrainer')
     self.chatbot.train("chatterbot.corpus.english")
     self.crypto = Crypto()
     self.trans = Translate()
     self.g = Giphy()
     self.w = WikiPedia()
     self.tw = Twimega()
     self.motivate = Motivate()
     self.shortenedurl = Urlshortener()
     self.hacknews = Hackernews()
     self.geo = Geocode()
     self.weather = Weather()
     self.dict_ = Dictionary()
     self.joke = Joke()
     self.pnr = Pnr()
     self.mustread = Mustread()
     self.ss = Ss()
     self.cricket = Cricket()
     self.poll = Poll()
     self.subkeys = [
         "crypto", "translate", "define", "joke", "weather", "giphy", "pnr",
         "mustread", "poll", "hackernews", "hn", "HN", "motivate",
         "twitter", "screenshot", "memo", "cricnews", "help", "shorturl"
     ]
def main():
    XML_DIR = config['SYSTEM']['xml_dir']
    HTML_DIR = config['SYSTEM']['html_dir']
    DOMAIN = config['SYSTEM']['server_domain']
    translateObj = Translate(DOMAIN, XML_DIR, HTML_DIR)
    translateObj.parseXMLs()
    translateObj.generate_sitemap()
Exemplo n.º 9
0
 def __init__(self):
     self.client = zulip.Client(site="https://bint.zulipchat.com/api/")
     self.subscribe_all()
     self.translate = Translate()
     self.location = Location()
     self.news = News()
     self.subKeys = ["hello", "sample"]
     self.todoList = []
Exemplo n.º 10
0
                    def parseImage():
                        self.progress.grid(row=1, column=0)
                        self.progress.start()
                        time.sleep(5)

                        temp = os.path.basename(self.file_path)
                        temp2 = os.path.dirname(self.file_path)
                        filename, file_extension = os.path.splitext(
                            self.file_path)
                        print(file_extension)

                        # if pdf
                        if (file_extension == ".pdf"):
                            print(file_extension)
                            pdfread = Pdfread(self.file_path, filename)
                            v = pdfread.extract()
                            obj2 = Translate(v)
                            detectedLang = obj2.detectLang()
                            self.progress.stop()
                            self.progress.grid_forget()
                        elif (file_extension == ".odt"
                              or file_extension == "docx"):
                            obj = DocReader(self.file_path, filename)
                            v = obj.extract()
                            obj2 = Translate(v)
                            detectedLang = obj2.detectLang()
                            self.progress.stop()
                            self.progress.grid_forget()

                        else:
                            obj = Converter(temp, temp2)
                            v = obj.execute()
                            obj2 = Translate(v)
                            detectedLang = obj2.detectLang()
                            self.progress.stop()
                            self.progress.grid_forget()

                        if not v.isspace():
                            self.setTempText(v)
                            self.load_desc()
                            self.load_detect_lang(detectedLang)
                        else:
                            tkinter.messagebox.showerror(
                                "OOPS!", "No Text Found!!\n")
                        self.browseTButton['state'] = 'normal'
Exemplo n.º 11
0
 def generate_query(self):
     if 'workload' in self.scheme:
         rel_list = [(x.source, x.target, x.label)
                     for x in self.relation_ins]
         wl = Workload(list(self.node_labels), rel_list, self.workload)
         queries = wl.generate_workload()
         filename = 'query.cypher'
         tl = Translate(filename)
         tl.translate(queries)
Exemplo n.º 12
0
    def __init__(self):
        # initialize crawler object for Article Scraper
        super(ArticleScraper, self).__init__()
        self.crawler = self.browser

        # initialize a translator object 
        self.translator = Translate()

        self.CSS_SELECTOR = "div.bilingual.cf > div.cf.articleContent"
Exemplo n.º 13
0
def charts():
    translate = Translate()
    words_to_translate = request.args['words']
    count_words = translate.count_words(words_to_translate)
    words = translate.sort_words(count_words)
    visual = Visual(dict_words=words, file_name="line")

    return render_template('chart.html',
                           title='Analysis',
                           chart=visual.mkPie())
Exemplo n.º 14
0
 def translate_word(self):
     ab = self.TargetLanguageList1.get(
         self.TargetLanguageList1.curselection())
     nput = self.imgTxtScrolled.get("1.0", END)
     obj2 = Translate(nput)
     obj2.translate(ab)
     translatedLang = obj2.translatedLang()
     self.TargetLanguageTextScrolled.delete('0', END)
     self.TargetLanguageTextScrolled.insert('0', translatedLang)
     print(ab)
Exemplo n.º 15
0
def getTranslatedResume():  #change to ajax
    inInfo = request.args.get("inInfo", type=str)
    outInfo = Translate(inInfo)
    outInfo.tr1()
    if 'login' in session:
        g.db.execute("insert into resumes (username,outresume) values(?,?)",
                     [session["login"]["username"],
                      outInfo.tojson()])
        g.db.commit()
    return jsonify(result=outInfo.tojson())
Exemplo n.º 16
0
def translate_words():
    translate_server = getenv("TRANSLATE_SRV", "http://127.0.0.1:8080")
    translate = Translate(translate_server)
    words_to_translate = request.args['words']
    count_words = translate.count_words(words_to_translate)
    translate_words = translate.translate_words(count_words)
    words = translate.sort_words(translate_words)

    return render_template('translate_words.html',
                           title='Translated words',
                           words=words)
Exemplo n.º 17
0
 def _numba_compile(func):
     global __tr_map__
     llvm = kws.pop('llvm', True)
     if func in __tr_map__:
         print(
             "Warning: Previously compiled version of %r may be "
             "garbage collected!" % (func, ))
     t = Translate(func, *args, **kws)
     t.translate()
     __tr_map__[func] = t
     return t.get_ctypes_func(llvm)
Exemplo n.º 18
0
    def __init__(self, **kwargs):
        self.span_list = []
        kwargs[
            'class_'] = 'w-2/3 bg-white mt-20  rounded-lg shadow p-12 flex flex-wrap'
        kwargs['style'] = 'min-height: 20rem;'
        super().__init__(**kwargs)
        self.en_area = None
        self.tw_area = None
        self.sentence_list = []

        self.ts = Translate('zh-TW', 'en')
Exemplo n.º 19
0
    def my_validater(self):
        nput = self.InputText.get()

        self.OutputText.delete('0', END)
        ab = self.TargetLanguageList2.get(
            self.TargetLanguageList2.curselection())

        obj2 = Translate(nput)
        obj2.translate(ab)
        translatedLang = obj2.translatedLang()
        self.OutputText.insert('0', translatedLang)

        return True
Exemplo n.º 20
0
    def __init__(self):
        self.client = zulip.Client(site="https://saharsh.zulipchat.com/api/")
        self.subscribe_all()
        self.trans = Translate()
        self.tw = Twimega()
        self.pnr = Pnr()
        self.weather = Weather()
        self.geo = Geocode()

        print("Initialization Done ...")
        self.subkeys = [
            "crypto", "translate", "define", "joke", "weather", "giphy", "pnr",
            "mustread", "poll", "hackernews", "hn", "HN", "motivate",
            "twitter", "screenshot", "memo", "cricnews", "help", "shorturl"
        ]
Exemplo n.º 21
0
	def __init__(self):
		self.client = zulip.Client(site="https://technh.zulipchat.com/api/", api_key="vkEQgQYDPUgAGmXaTXdMPsMwlkkgMfM5", email="*****@*****.**")
		self.subscribe_all()
		self.hacknews = Hackernews()
		self.trans = Translate()
		self.movie= Movie()
		self.lyrics = Lyrics()
		self.holiday = Holiday()
		self.currency = Currency()
		self.cricket = Cricket()
		self.github = GitHub()
		self.chatbot = ChatBot(name="technehru")

		print("done init")
		self.subkeys = ["use", "help", "translate", "hackernews", "hn", "hotel", "HN", "cricnews", "cricketnews", "movie", "currency", "holiday", "lyrics", "github"]
 def translate(self):
     t = Translate()
     target = 'zh'
     plainText = self.plainEdit.toPlainText()
     if len(plainText) == 0:
         return
     else:
         # TODO 处理原始文本
         plainText = self.utils.processPlainText(plainText)
         translatedText = t.translated_content(plainText, target)
         self.translatedEdit.setText(translatedText)
         if self.settings.autoCopy:
             self.clipboard.setText(translatedText)
         else:
             pass
Exemplo n.º 23
0
    def open(self):
        '''
        Permet d'ouvrir un fichier .thc ou .txt pour le lire et le modifier
        :return: (translate) Class translate contenant le texte
        '''
        translate = Translate()

        self.OpenFileDialog()
        if self.file.lower().endswith(".txt"):
            doc = open(self.file, "r", encoding='utf8')
            text = doc.read()
            translate.toBin(text)

            return translate
        binary = Binary()

        if self.file == "":
            return None

        doc = open(self.file, "rb")
        data = self.bytes2binstr(doc.read())
        doc.close()

        dic = ""
        text = ""
        isDic = True
        countLenDic = 0
        for i in range(len(data) // 7 + ceil((len(data) % 7) / 7)):
            value = ""
            for y in range(7):
                b = ""
                if isDic:
                    b = "0"
                if len(data) >= i * 7 + y + 1:
                    b = data[i * 7 + y]
                value += b
            if value == cbch["[SUPERSEP¤]"]:
                isDic = False
            elif isDic:
                countLenDic += 7
            if isDic:
                dic += value
            else:
                if value != cbch["[SUPERSEP¤]"]:
                    text += value

        translate.toText(text[(len(text) % 8):], binary.SaveToDict(dic))
        return translate
Exemplo n.º 24
0
    def __init__(self):
        self.client = zulip.Client(site="https://saharsh.zulipchat.com/api/")
        self.subscribe_all()
        self.trans = Translate()
        self.tw = Twimega()
        self.pnr = Pnr()
        self.weather = Weather()
        self.geo = Geocode()
        self.searching = Places()
        self.help = Help()

        print("Initialization Done ...")
        self.subkeys = [
            "translate", "weather", "pnr", "post", "post_image", "twitter",
            "help", "search"
        ]
Exemplo n.º 25
0
def vectorize(func):
    global __tr_map__
    try:
        if func not in __tr_map__:
            t = Translate(func)
            t.translate()
            __tr_map__[func] = t
        else:
            t = __tr_map__[func]
        return t.make_ufunc()
    except Exception as msg:
        print "Warning: Could not create fast version...", msg
        import traceback
        traceback.print_exc()
        import numpy
        return numpy.vectorize(func)
Exemplo n.º 26
0
    def __init__(self):
        self.client = zulip.Client(site="https://myra.zulipchat.com/api/")
        self.subscribe_all()
        self.hacknews = Hackernews()
        self.trans = Translate()
        self.movie = Movie()
        self.lyrics = Lyrics()
        self.holiday = Holiday()
        self.currency = Currency()
        self.cricket = Cricket()

        print("done init")
        self.subkeys = [
            "translate", "hackernews", "hn", "hotel", "HN", "askme",
            "cricnews", "movie", "currency", "holiday", "lyrics"
        ]
Exemplo n.º 27
0
 def midcode(self):
     '''
     生成中间代码
     :return:
     '''
     self.textBrowser.clear()
     t = Translate()
     s = self.textEdit.toPlainText()
     fg, info = t.entry(s)
     if fg:
         t.optimize_code()
         pickle.dump((True, t.codes), open('data/midway_sheet.pkl', 'wb'))
     else:
         pickle.dump((False, None), open('data/midway_sheet.pkl', 'wb'))
         info = '----- error !\n' + '\n'.join(info)
         self.textBrowser.setText(info)
     self.save()
Exemplo n.º 28
0
    def getAllIngredients(self):
        df = self.df_AllergenData
        ingredients = df['IngredientsInfo'].tolist()
        productId = df['Gtin'].tolist()
        languageInfo = df['LanguageInfo'].tolist()

        wordToTranslation = {}
        uniqueIngredients = set()
        # product_ingredients_mapping = defaultdict(list)
        x = 0
        for i in range(len(ingredients)):
            try:
                if (languageInfo[i] != 'en'):
                    vals = re.findall(r'\(E\d+\)|([^\W\d]+(?:\s+[^\W\d]+)*)',
                                      ingredients[i])
                    instance = Translate()
                    for item in vals:
                        if (len(item) < 3): continue
                        translatedItem = instance.TranslateWord(
                            item, languageInfo[i])
                        uniqueIngredients.add(translatedItem.lower())
                        wordToTranslation.update({
                            item: [
                                translatedItem,
                                instance.DetectLanguage(translatedItem)
                            ]
                        })
                else:
                    vals = re.findall(r'\(E\d+\)|([^\W\d]+(?:\s+[^\W\d]+)*)',
                                      ingredients[i])
                    for j in vals:
                        if (len(item) < 3): continue
                        uniqueIngredients.add(j.lower())
                        # product_ingredients_mapping[j].append(str(productId[i]))
                        wordToTranslation.update({item: [item, 'en']})
            except Exception as e:
                x += 1

        # Dataframe of items ===> productId mapping
        # frame = pd.DataFrame(dict([ (k,Series(v)) for k,v in product_ingredients_mapping.items() ])).transpose()
        frame = pd.DataFrame(wordToTranslation,
                             index=['Translation', 'Language']).transpose()
        frame.to_csv('frame.csv', sep=',', encoding='latin-1')
        return uniqueIngredients
Exemplo n.º 29
0
 def __init__(self, uiPrintMessage, sendQuit=None):
     self.settings = Settings(self.printMessage)
     self.turing = Backend()
     self.client = None
     self.server = None
     self.uiPrintMessage = uiPrintMessage
     self.sendQuit = sendQuit
     self.connexion = None
     self.server = Server(self.turing, self.printMessage,
                          self.writeMessages)
     self.client = Client(self.turing, self.printMessage,
                          self.writeMessages)
     self.username = self.settings.getSetting("username")
     self.otherUsername = None
     self.trustManager = TrustManager(self.printMessage)
     self.msgBuffer = []
     self.fileList = []
     self.translate = Translate(self.printMessage,
                                self.settings.getSetting("language"))
     setObject(self.translate)
Exemplo n.º 30
0
 def f2(self):
     print("[中英单词互译](可译短语)(需要联网)")
     d = Translate()
     print("")