# Generator http://pad.constantvzw.org/p/writing_with_film_generator from pattern.en import parse, pprint, tag, tokenize, tag, parsetree from argparse import ArgumentParser p = ArgumentParser("This parser translates a sentences into a list of word-tags.") p.add_argument("--text", default=None, help="the input text, a sentence, written in between quotes.") args = p.parse_args() # Loading a document from a text file: if args.text == None: args.text = "I eat pizza with a fork." sentencePosTags = [] for word, pos in tag(args.text): sentencePosTags.append(pos) print args.text print sentencePosTags -------------------------------------------- run sentence-parser.py: >>> python sentence-pos-tag-parser.py --text "hello this is me from Brussels." prints: *hello this is me from Brussels. *[u'UH', u'DT', u'VBZ', u'PRP', u'IN', u'NNP', u'.']