File size: 614 Bytes
4b75840
 
 
 
 
 
e99a699
59fcc9f
620af8b
4b75840
 
 
 
620af8b
a00f9ba
620af8b
 
a00f9ba
620af8b
 
a00f9ba
620af8b
 
4b75840
a00f9ba
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import nltk
from nltk.tokenize import word_tokenize
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')


class POSTagging:
    """Part of Speech Tagging on text data"""

    def __init__(self):
       pass

    def classify(self, text):
        """
        Generate Part of Speech tags.

        Parameters:
            text (str): The user input string to generate tags for

        Returns:
            predictions (list): list of tuples containing words and their respective tags
        """

        text = word_tokenize(text)
        predictions = nltk.pos_tag(text)
        return predictions