Beispiel #1
0
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()
Beispiel #2
0
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()
Beispiel #3
0
 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)
Beispiel #4
0
 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)