Spaces:
Runtime error
Runtime error
File size: 612 Bytes
27880c1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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 |