import nltk
from nltk import word_tokenize, bigrams
from collections import Counter
nltk.download('punkt')
nltk.download('punkt_tab')
###full text
text_data = """
Artificial intelligence is powerful.
Artificial intelligence is the future.
Artificial intelligence enables automation.
Machine learning is a part of artificial intelligence.
"""
##define function
def suggest_next_nltk(full_text, input_term, top_n=5):
tokens = word_tokenize(full_text.lower())
bi_grams = bigrams(tokens)
next_words = [second for first, second in bi_grams if first == input_term.lower()]
return Counter(next_words).most_common(top_n)
###call function to get output
print(suggest_next_nltk(text_data, "artificial", 3))
###call function to get output
print(suggest_next_nltk(text_data, "Machine", 3))