Spaces:
Sleeping
Sleeping
import gradio as gr | |
from nltk import ngrams | |
from nltk.tokenize import word_tokenize | |
import nltk | |
nltk.download('punkt') | |
def generate_ngrams(sentence, n): | |
tokens = word_tokenize(sentence) | |
n_grams = list(ngrams(tokens, n)) | |
res=[' '.join(gram) for gram in n_grams] | |
print(res) | |
return res | |
iface = gr.Interface( | |
fn=generate_ngrams, | |
inputs=["text", gr.Number(precision=0)], | |
outputs="text", | |
live=True, | |
title="Python Code With N-Gram", | |
) | |
iface.launch() | |