Ejemplo n.º 1
0
def showMenus(show_menu_channels=(),
              show_zh_menu_channels=(),
              meal_types=(),
              when=None):

  if isinstance(show_menu_channels, basestring):
    show_menu_channels = (show_menu_channels,)
  if isinstance(show_zh_menu_channels, basestring):
    show_zh_menu_channels = (show_zh_menu_channels,)
  if isinstance(meal_types, basestring):
    meal_types = (meal_types,)
  meal_types = meal_types and [meal_type.title() for meal_type in meal_types]

  meal_type = FacebookMenu.getMealType(when)
  if meal_type and (not meal_types or
                    meal_type in meal_types):
    menus = FacebookMenu.getMenus(when)
    if menus:
      if ' ' not in meal_type:
        meal_type += ' time'
      message = '%s\n%s' % (meal_type, '\n'.join(menus))
      sayOnChannels(show_menu_channels, message)
      zh_message = GoogleTranslate.translate(message)
      sayOnChannels(show_zh_menu_channels, zh_message)
Ejemplo n.º 2
0
 def translate_en2cn(self, text):
     text_ = GoogleTranslate.translate('en', 'zh-CN', text)
     return text_
Ejemplo n.º 3
0
def ActualBot(sentence):
    if __name__ == '__main__':
        WAKE = 'hello'
        SERVICE = Gcalender.authenticate_google()

        while True:
            print("Listening")
            sentence = CInput.get_command()
            #sentence = SInput.VoiceCommand()

            if sentence.count(WAKE) > 0:
                speak("Im ready")
                sentence = CInput.get_command()
                #sentence = SInput.VoiceCommand()
                if "poweroff" in sentence or "power of" in sentence or "powerdown" in sentence or "power off" in sentence or "power down" in sentence or "powerof" in sentence:
                    break

                botresponse = MIntegration.MLFunc(sentence)

                if botresponse == None:
                    pass

                elif "weather" in botresponse:
                    speak("Which City's weather report should I look for ?")
                    command = input()
                    #command = SInpuy.VoiceCommand()
                    command = command.lower()
                    Weather.weatherreport(command)

                elif "event" in botresponse:
                    date = Gcalender.get_date(sentence)
                    if date:
                        Gcalender.get_events(date, SERVICE)
                    else:
                        speak("I dont understand")

                elif "mail" in botresponse:
                    try:
                        speak("Enter the Recipient")
                        to = str(input())

                        speak("Enter the subject")
                        subject = input()

                        speak("What should I write?")
                        content = input()

                        UserEmail.SendSubEmail(to, subject, content)
                        speak("Email has been sent")

                    except Exception as e:
                        print(e)
                        speak("An Error has occured")

                #########BUG########
                elif "search" in botresponse:
                    speak("What should I search for ?")
                    command = input()
                    #command = SInput.VoiceCommand()
                    CF.searchnet(command)

                elif "news" in botresponse:
                    CF.shownews()

                elif "screenshot" in botresponse:
                    CF.takescreenshot()

                elif "translate" in botresponse:
                    Gtranslate.translatesentence()

                elif "shutdown" in botresponse:
                    speak("Do you wish to shutdown the system ?")
                    command = CInput.get_command()
                    #command = SInput.VoiceCommand()
                    if (command == 'yes' or command == 'yep'
                            or command == 'sure'):
                        os.system("shutdown /s /t 1")
                    else:
                        pass

                elif "restart" in botresponse:
                    speak("Do you wish to restart the system ?")
                    command = CInput.get_command()
                    #command = SInput.VoiceCommand()
                    if (command == 'yes' or command == 'yep'
                            or command == 'sure'):
                        os.system("shutdown /r /t 1")
                    else:
                        pass

                elif "maps" in botresponse:
                    speak("Which place should i search for ?")
                    place = input()
                    #place = SInput.VoiceCommand()
                    webbrowser.open("https://www.google.com/maps/place/" +
                                    place)

                elif "reddit" in botresponse:
                    try:
                        subreddit = input("Which subreddit ?")
                        #subreddit = SInput.VoiceCommand()
                        subreddit = subreddit.replace(" ", "")
                        webbrowser.open_new_tab('www.reddit.com/r/' +
                                                subreddit)
                        speak("Opening reddit")
                    except Exception as e:
                        speak("Something Went wrong")

                elif "note" in botresponse:
                    speak("What should i write down ?")
                    note_text = CInput.get_command()
                    #note_text = SInput.VoiceCommand()
                    Notes.instantnote(note_text)
                    speak("I've made a note of that")

                elif "console" in botresponse:
                    webbrowser.open_new_tab(
                        "https://play.google.com/console/u/0/developers/5469473923678169464/app-list"
                    )

                elif "insta" in botresponse:
                    speak("Initializing")
                    CF.instagram()

                elif "standby" in botresponse:
                    break

                elif "wiki" in botresponse:
                    speak("What do you want me to search on wikipedia ?")
                    wikisearch = CInput.get_command()
                    CF.wiki(wikisearch)

                elif "wolfram" in botresponse:
                    speak("Ask me")
                    wolframquery = CInput.get_command()
                    WRFile.wolframfunc(wolframquery)

                elif "read" in botresponse:
                    EM.copydata()

                elif "copy" in botresponse:
                    EM.copy()

                elif "paste" in botresponse:
                    EM.paste()

                elif "time" in botresponse:
                    CF.timetoday()

                elif "date" in botresponse:
                    CF.daytoday()

                else:
                    print("I dont understand you. Please be more specific")

    return
targetLanguage = "af"

# Using the chosen work area, do a POST to instantiate the new
# editable version
metadataEntry = sword2cnx.MetaData({'dcterms:source': sourceDocumentUrl})
derivationDepositReceipt = conn.create(
    col_iri = swordCollections[colId].href,
    metadata_entry = metadataEntry,
    in_progress = True)
print "=== DEPOSIT RECEIPT ==="
print derivationDepositReceipt
print "=== /DEPOSIT RECEIPT ==="

# Do auto-translate of CNXML through Google Translate
import GoogleTranslate
sourceCnxml = GoogleTranslate.module_to_cnxml(sourceDocumentId, iUrlPrefix=sourceDocumentUrlPrefix)
version = GoogleTranslate.get_cnxml_version(sourceCnxml)
sourceLanguage = GoogleTranslate.get_cnxml_language(sourceCnxml)
url = sourceDocumentUrlPrefix + sourceDocumentId + '/' + version + '/module_export?format=plain'
print "Translating from %s to %s..."%(sourceLanguage, targetLanguage)
targetCnxml = GoogleTranslate.translate_cnxml(url, sourceLanguage, targetLanguage)
targetCnxml = GoogleTranslate.fix_cnxml_translation(sourceCnxml, targetCnxml)

with open('source.cnxml','wt') as fp:
    fp.write(sourceCnxml)
with open('target.cnxml','wt') as fp:
    fp.write(targetCnxml)

sourceCnxml = sourceCnxml.decode('latin-1')
targetCnxml = targetCnxml.decode('latin-1')
Ejemplo n.º 5
0
import GoogleTranslate

with open('test.txt', 'w', encoding='utf-8') as f:
    f.writelines("\t测试\n")
exit(0)

text = 'Social media has been developing rapidly in public due to its nature of spreading new information, which leads to rumors being circulated. Meanwhile, detecting rumors from such massive information in social media is becoming an arduous challenge. Therefore, some deep learning methods are applied to discover rumors through the way they spread, such as Recursive Neural Network (RvNN) and so on. However, these deep learning methods only take into account the patterns of deep propagation but ignore the structures of wide dispersion in rumor detection. Actually, propagation and dispersion are two crucial characteristics of rumors. In this paper, we propose a novel bi-directional graph model, named Bi-Directional Graph Convolutional Networks (Bi-GCN), to explore both characteristics by operating on both top-down and bottom-up propagation of rumors. It leverages a GCN with a top-down directed graph of rumor spreading to learn the patterns of rumor propagation; and a GCN with an opposite directed graph of rumor diffusion to capture the structures of rumor dispersion. Moreover, the information from source post is involved in each layer of GCN to enhance the influences from the roots of rumors. Encouraging empirical results on several benchmarks confirm the superiority of the proposed method over the state-of-the-art approaches.'
print(GoogleTranslate.translate('en', 'zh-CN', text))
Ejemplo n.º 6
0
    def process(self):
        sentence = self.lineEdit.text().lower()
        SERVICE = Gcalender.authenticate_google()
        botresponse = ModelIntegration.MLFunc(sentence)

        if botresponse != None:

            if "poweroff" in sentence or "exit" in sentence:
                self.close()

            elif "weather" in botresponse:
                self.setTB(speak("which City ?"))
                self.command = self.ShowDiag()
                try:
                    self.setTB(Weather.weatherreport((self.command)))
                except Exception as e:
                    self.setTB(speak("An Error Occured"))

            elif "event" in botresponse:
                date = Gcalender.get_date(sentence)
                if date:
                    self.setTB(speak(Gcalender.get_events(date, SERVICE)))
                else:
                    self.setTB(speak("I dont understand"))

            elif "mail" in botresponse:
                try:
                    self.setTB("Enter the Recipient")
                    to = self.ShowDiag()

                    self.setTB(speak("Enter the subject"))
                    subject = self.ShowDiag()

                    self.setTB(speak("What should I write?"))
                    content = self.ShowDiag()

                    UserEmail.SendSubEmail(to, subject, content)
                    self.setTB(speak("Email has been sent"))
                except Exception as e:
                    print(e)
                    self.setTB(speak("An Error has occured"))

            elif "news" in botresponse:
                self.setTB(speak(CF.shownews()))  #Not Sorted out yet!! #######

            elif "screenshot" in botresponse:
                self.setTB(speak(CF.takescreenshot()))

            elif "translate" in botresponse:
                self.setTB(
                    speak("Enter the language you want to translate from"))
                inputlang = self.ShowDiag()
                self.setTB(speak("Enter the text"))
                userinput = self.ShowDiag()
                self.setTB(
                    speak("Enter the language you want to translate to"))
                lang = self.ShowDiag()

                self.setTB(
                    speak(
                        Gtranslate.translatesentence(inputlang, userinput,
                                                     lang)))

            elif "shutdown" in botresponse:
                self.setTB("Do you wish to shutdown the system ?")
                command = self.ShowDiag()
                if (command == 'yes' or command == 'yep' or command == 'sure'):
                    os.system("shutdown /s /t 1")
                else:
                    pass

            elif "restart" in botresponse:
                self.setTB("Do you wish to restart the system ?")
                command = self.ShowDiag()
                if (command == 'yes' or command == 'yep' or command == 'sure'):
                    os.system("shutdown /r /t 1")
                else:
                    pass

            elif "maps" in botresponse:  #Not Sorted out!!
                self.setTB(speak("Which place should i search for ?"))
                place = self.ShowDiag()
                webbrowser.open("https://www.google.com/maps/place/" + place)

            elif "reddit" in botresponse:
                try:
                    self.setTB("Which subbreddit ?")
                    subreddit = self.ShowDiag()
                    subreddit = subreddit.replace(" ", "")
                    webbrowser.open_new_tab('www.reddit.com/r/' + subreddit)
                except Exception as e:
                    print(e)
                    self.setTB(speak("Something Went wrong"))

            elif "note" in botresponse:
                self.setTB("What should i write down ?")
                note_text = self.ShowDiag()
                Notes.instantnote(note_text)
                self.setTB(speak("I've made a note of that"))

            elif "console" in botresponse:
                self.setTB(speak("Opening your Playstore Console"))
                webbrowser.open_new_tab(
                    "https://play.google.com/console/u/0/developers/5469473923678169464/app-list"
                )

            elif "insta" in botresponse:
                self.setTB("Initializing")
                CF.instagram()

            elif "wiki" in botresponse:
                self.setTB(
                    speak("What do you want me to search on wikipedia ?"))
                wikisearch = self.ShowDiag()
                self.setTB(speak(CF.wiki(wikisearch)))

            elif "wolfram" in botresponse:
                self.setTB(speak("Ask me"))
                self.wolframquery = self.ShowDiag()
                self.setTB(
                    speak(wolframalphafile.wolframfunc(self.wolframquery)))

            elif "read" in botresponse:
                self.setTB(EM.copydata())

            elif "copy" in botresponse:
                EM.copy()
                self.setTB("Copied")

            elif "paste" in botresponse:
                EM.paste()

            elif "time" in botresponse:
                self.setTB(speak(CF.timetoday()))

            elif "date" in botresponse:
                self.setTB(speak(CF.daytoday()))

            else:
                self.setTB(
                    speak("I dont understand you. Please be more specific"))
        else:
            self.setTB(speak("Please try again"))
import speech_recognition as sr
import GoogleTranslate
import argparse


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--selfLanguage", required=True, type=str)
    parser.add_argument("-t", "--targetLanguage", required=True, type=str)

    args = parser.parse_args()
    r = sr.Recognizer()
    m = sr.Microphone()

    with m as source:
        print "say something"
        audio = r.listen(source)

    try:
        text = r.recognize_google(audio)
    except sr.UnknownValueError:
        print "Google Speech Recognition could not understand audio"
    except sr.RequestError as e:
        print "Could not request results from Google Speech Recognition service; {0}".format(e)

    if text is not None:
        try:
            translatedText = GoogleTranslate.translate(text, args.targetLanguage, args.selfLanguage)
        except:
            print "Something went wrong with the translation"
Ejemplo n.º 8
0
            elif "take screenshot" in Vinput or "take screen shot" in Vinput or "screenshot" in Vinput or "screen shot" in Vinput or "screenshot this" in Vinput:
                CF.takescreenshot()
                speak('Screenshot Saved')

            elif "news for today" in Vinput or "todays news" in Vinput or "news today" in Vinput or "today's news" in Vinput:
                CF.shownews()

            elif "weather report" in Vinput:
                speak("Which City's weather report should i look for ?: ")
                command = CInput.get_command()
                command = command.lower()
                Weather.weatherreport(command)

            elif "translate" in Vinput:
                Gtranslate.translatesentence()

            elif "power off" in Vinput or "power down" in Vinput or 'powerdown' in Vinput or 'poweroff' in Vinput:
                exit()

            elif "shutdown system" in Vinput or "shutdown machine" in Vinput or "shutdown the machine" in Vinput:
                speak("Do you wish to shutdown the system ?")
                command = CInput.get_command()
                if (command == 'yes' or command == 'yep' or command == 'sure'):
                    os.system("shutdown /s /t 1")
                else:
                    pass

            elif "restart system" in Vinput or "restart machine" in Vinput or "restart the machine" in Vinput or "Restart the system" in Vinput:
                speak("Do you wish to restart the system ?")
                command = CInput.get_command()
Ejemplo n.º 9
0
import argparse

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--selfLanguage", required=True, type=str)
    parser.add_argument("-t", "--targetLanguage", required=True, type=str)

    args = parser.parse_args()
    r = sr.Recognizer()
    m = sr.Microphone()

    with m as source:
        print "say something"
        audio = r.listen(source)

    try:
        text = r.recognize_google(audio)
    except sr.UnknownValueError:
        print "Google Speech Recognition could not understand audio"
    except sr.RequestError as e:
        print "Could not request results from Google Speech Recognition service; {0}".format(
            e)

    if text is not None:
        try:
            translatedText = GoogleTranslate.translate(text,
                                                       args.targetLanguage,
                                                       args.selfLanguage)
        except:
            print "Something went wrong with the translation"