Esempio n. 1
0
class SMSParser():
    def __init__(self):
        self.wiki = Wikipedia()
        self.translate = Translate()
        self.grammar = Grammar()
        self.math_solver = MathSolver()

    def commands(self):
        commands = '''List of commands:
        1. commands
        2. wiki <search/summary/content> <topic>
        3. translate <dest lang abbrev.> <text>
        4. grammar <text>
        5. mathpix <img> (image in new sms)
        6. duesoon
        '''
        return cleandoc(commands)

    def parse(self, text):
        # add some placeholders for error handling
        sections = text.strip().split() + [''] * 2
        features = [
            'commands', 'wiki', 'translate', 'grammar', 'mathpix', 'duesoon'
        ]
        try:
            feature = sections[0]
            if feature not in features:
                return 'Feature not found'
            elif feature == 'commands':
                return self.commands()
            elif feature == 'wiki':
                action = sections[1]
                wiki_actions = ['search', 'summary', 'content']
                if action not in wiki_actions:
                    return 'Action not found'
                text = ' '.join(sections[2:])
                print(text)
                print(self.wiki.summary(text))
                return getattr(self.wiki, action)(text)
            elif feature == 'translate':
                dest_lang = sections[1]
                text = ' '.join(sections[2:])
                return self.translate.translate(text, dest=dest_lang)
            elif feature == 'mathpix':
                equation = self.math_solver.read_math('test1.jpg')
                return self.math_solver.solve_math2("find zeroes for:" +
                                                    equation)
            elif feature == 'grammar':
                text = ' '.join(sections[1:])
                return self.grammar.check(text)
            elif feature == "duesoon":
                time.sleep(4)
                return (
                    'Upcoming due dates:\n\n14.4 Problem Set - Due in 2 day(s)\n\nHemingway Reading Questions - Due in 1 day(s)'
                )
        except Exception as e:
            print(e)
            return 'Something went wrong. Please double-check your command!'
Esempio n. 2
0
 def __init__(self):
     self.wiki = Wikipedia()
     self.translate = Translate()
     self.grammar = Grammar()
     self.math_solver = MathSolver()
Esempio n. 3
0
#Warten, bis Touch gedrueckt wird
robot.clearDisplay()
robot.drawString("Waiting for press", 1, 1)
while True:
    if ts.isPressed():
        break

robot.clearDisplay()
robot.drawString("Getting Aufgabe", 1, 1)
#Aufgabe = sc.get()
Aufgabe = Aufgabe11
robot.clearDisplay()
robot.drawString("Got Aufgabe", 1, 1)

Aufgabe = Sicher(Aufgabe)
if Test(Aufgabe, "E") != "Fertig":
    Aufgabe = Raten(Aufgabe, None)
robot.clearDisplay()
robot.drawString("Got Solution", 1, 1)
data = Translate(Aufgabe)
print data
robot.clearDisplay()
robot.drawString("Start plotting", 1, 1)
#data = [data[0],data[1]]
solve(data, motx, moty, motz)

down(motz)
up(motz)
down(motz)
robot.exit()
Esempio n. 4
0
from Translator import Translate

app = Translate()

to_translate = "Hello"
to_language = "de"

result = app.autodetect(to_language, to_translate)
print(result)

#Output:
#{'From': 'en-US', 'To': 'de', 'Thing': 'Hello', 'Result': 'Hallo'}
Esempio n. 5
0
 def __init__(self):
     self.wiki = Wikipedia()
     self.translate = Translate()
     self.grammar = Grammar()
from TwitterScraper import Scrape
from Translator import Translate
from VaderAnalyzer import Analyze

Scrape()
Translate()
Analyze()
Esempio n. 7
0
from Translator import Translate

app = Translate()

languages = app.list_languages()
print(languages)

#Output:
'''
 '1 Afrikaans af'
 '2 Albanian sq'
 '3 Arabic ar'
 '4 Armenian hy'
 '5 Azerbaijani az'
 '6 Basque eu'
 '7 Belarusian be'
 '9 Bulgarian bg'
 '9 Catalan ca'
 '10 Chinese (Simplified) zh-CN'
 '11 Chinese (Traditional) zh-TW'
 '12 Croatian hr'
 '13 Czech cs'
 '14 Danish da'
 '15 Dutch nl'
 '16 English en'
 '17 Estonian et'
 '18 Filipino tl'
 '19 Finnish fi'
 '20 French fr'
 '21 Galician gl'
 '22 Georgian ka'
Esempio n. 8
0
from Translator import Translate

app = Translate()

to_translate = "Hello"
from_language = "en"
to_language = "de"

result = app.translate(to_language,from_language,to_translate)  
print(result)

#Output:
#{'From': 'en', 'To': 'de', 'Thing': 'Hello', 'Result': 'Hallo'}