def __init__(self, word, sentLoc = -1, clauseLoc = -1, numWords = -1): word = self.doUmlauts(word) self.word = utf8.encode(word) self.verb = canoo(self.word) self.translations = cache(self.word) #these are useful for doing calculations with word locations in sentences #in order to figure out if something is a verb or just a noun hanging out in #the middle self.sentLoc = sentLoc self.clauseLoc = clauseLoc self.numWords = numWords
def translate(query, beAggressive): """Does the hefty work of translating the input""" try: query = utf8.encode(query) if (sentenceFigurer.canTranslate(query)): s = sentenceFigurer(query) return s.translate(beAggressive) else: w = word.word(query) return w.get() except: if (app.config.get('debug', False)): raise else: return []