def translate(source): t = PartOfSpeechTagger('http://text-processing.com/api/tag/', 'text') source = expand_contractions(source) source = t.tag(source) source = source.replace('\n','') logging.warning("Foo: " + source) sentences = source.split(')(') translated = "" for pos_tagged in sentences: s = Sentence(pos_tagged) apply_yodish_grammar(s) translated += s.render() + ' ' return translated.strip()
def translate(source): t = PartOfSpeechTagger('http://text-processing.com/api/tag/', 'text') source = expand_contractions(source) source = t.tag(source) source = source.replace('\n', '') logging.warning("Foo: " + source) sentences = source.split(')(') translated = "" for pos_tagged in sentences: s = Sentence(pos_tagged) apply_yodish_grammar(s) translated += s.render() + ' ' return translated.strip()
def test_expand_contractions(self): actual = expand_contractions("can't ain't i'm you're") self.assertEqual("cannot am not I am you are", actual)