def test_parse(parser, sentence): parser.parse(sentence) assert sentence.length == 7 tokens = list(sentence.tokens) assert tokens[0].word == 'This' assert tokens[1].word == 'is' assert tokens[2].word == 'a' assert tokens[3].word == 'test' assert tokens[4].word == '.'
def postag(rvdata): piece = rvdata[0][3] test = TextBlob(piece) print test # print [str(x[0] + '/' + x[1]) for x in test.sentences[0].pos_tags] tagstc = ' '.join( [str(x[0]) + '/' + str(x[1]) for x in test.sentences[-1].pos_tags]) parser = redshift.parser.Parser('models') # print tagstc print test.sentences[0] + '' testsent = Input.from_pos( tagstc) #['A', 'list', 'of', 'tokens', 'is', 'required', '.']) # testsent = Input.from_untagged(test.sentences[0].words) parser.parse(testsent) print testsent.to_conll() #.split('\n') # sentence = Input.from_untagged( # parser.parse(test) '''
def parse(parser, sentences): for sent in sentences: parser.parse(sent)