Spaces:
Runtime error
Runtime error
wudiashley
commited on
Commit
•
224ca5a
1
Parent(s):
918bd86
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
#import transformers
|
3 |
+
#from transformers import pipeline
|
4 |
+
|
5 |
+
|
6 |
+
def sentence_analysis(sent):
|
7 |
+
#length of token/length of type = TTR
|
8 |
+
#length = len(sent.split())
|
9 |
+
number_of_tokens = len(sent.lower().split())
|
10 |
+
number_of_types = len(set(sent.lower().split()))
|
11 |
+
TTR = number_of_types/number_of_tokens
|
12 |
+
return (f'''Your sentence has {number_of_tokens} tokens in it.
|
13 |
+
Your sentence has {number_of_types} types in it.
|
14 |
+
Type-token ratio of the sentence is {TTR}.
|
15 |
+
Please type another sentence.''')
|
16 |
+
|
17 |
+
iface = gr.Interface(fn=sentence_analysis, inputs="text", outputs="text")
|
18 |
+
iface.launch()
|
19 |
+
|
20 |
+
def word_analysis(word):
|
21 |
+
letter_count = len(word)
|
22 |
+
return (f'Your word has {letter_count} letters.')
|
23 |
+
|
24 |
+
iface = gr.Interface(fn=word_analysis, inputs="text", outputs="text")
|
25 |
+
iface.launch()
|