If you know how to train and predict texts (or sentences in your case) using the nltk naive bayes classifier and words as functions, you can easily extend this approach to classify texts by position labels. This is because the classifier does not care about whether your function lines are words or tags. Thus, you can simply replace the words of your sentences with pos tags using, for example, nltk standard pos tagger:
sent = ['So', 'they', 'have', 'internet', 'on', 'computers' , 'now'] tags = [t for w, t in nltk.pos_tag(sent)] print tags
['IN', 'PRP', 'VBP', 'JJ', 'IN', 'NNS', 'RB']
From now on, you can move on to the "contains-a-word" approach.
source share