Spaces:
Sleeping
Sleeping
File size: 483 Bytes
f75a3db |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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() |