wudiashley's picture
Create app.py
224ca5a
raw
history blame contribute delete
791 Bytes
import gradio as gr
#import transformers
#from transformers import pipeline
def sentence_analysis(sent):
#length of token/length of type = TTR
#length = len(sent.split())
number_of_tokens = len(sent.lower().split())
number_of_types = len(set(sent.lower().split()))
TTR = number_of_types/number_of_tokens
return (f'''Your sentence has {number_of_tokens} tokens in it.
Your sentence has {number_of_types} types in it.
Type-token ratio of the sentence is {TTR}.
Please type another sentence.''')
iface = gr.Interface(fn=sentence_analysis, inputs="text", outputs="text")
iface.launch()
def word_analysis(word):
letter_count = len(word)
return (f'Your word has {letter_count} letters.')
iface = gr.Interface(fn=word_analysis, inputs="text", outputs="text")
iface.launch()