Spaces:
Sleeping
Sleeping
Commit
·
378cc86
1
Parent(s):
0aad19c
new
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from collections import Counter
|
3 |
import re
|
4 |
-
from textblob import TextBlob
|
5 |
import textstat
|
6 |
from transformers import pipeline
|
7 |
from langdetect import detect
|
@@ -22,9 +21,6 @@ def word_and_char_counter(text):
|
|
22 |
most_common_words = word_freq.most_common(3)
|
23 |
unique_words = [word for word, count in word_freq.items() if count == 1]
|
24 |
|
25 |
-
# Analyze sentiment
|
26 |
-
sentiment = TextBlob(text).sentiment
|
27 |
-
|
28 |
# Calculate Flesch Reading Ease score
|
29 |
reading_ease = textstat.flesch_reading_ease(text)
|
30 |
|
@@ -37,8 +33,8 @@ def word_and_char_counter(text):
|
|
37 |
# Format the results
|
38 |
freq_results = ', '.join([f"'{word}': {count}" for word, count in most_common_words])
|
39 |
unique_words_result = ', '.join(unique_words)
|
40 |
-
|
41 |
-
return f"Language: {language}. {num_sentences} sentences, {num_words} words, {num_chars} characters. Most common words: {freq_results}. Unique words: {unique_words_result}.
|
42 |
|
43 |
# Define your interface
|
44 |
interface = gr.Interface(
|
@@ -46,7 +42,7 @@ interface = gr.Interface(
|
|
46 |
inputs=gr.Textbox(lines=4, placeholder="Type something here..."),
|
47 |
outputs="text",
|
48 |
title="Comprehensive Text Analysis with Language Detection",
|
49 |
-
description="This app provides detailed analysis including language detection, sentence, word, and character counts, lists the most common and unique words,
|
50 |
)
|
51 |
|
52 |
# Launch the app
|
|
|
1 |
import gradio as gr
|
2 |
from collections import Counter
|
3 |
import re
|
|
|
4 |
import textstat
|
5 |
from transformers import pipeline
|
6 |
from langdetect import detect
|
|
|
21 |
most_common_words = word_freq.most_common(3)
|
22 |
unique_words = [word for word, count in word_freq.items() if count == 1]
|
23 |
|
|
|
|
|
|
|
24 |
# Calculate Flesch Reading Ease score
|
25 |
reading_ease = textstat.flesch_reading_ease(text)
|
26 |
|
|
|
33 |
# Format the results
|
34 |
freq_results = ', '.join([f"'{word}': {count}" for word, count in most_common_words])
|
35 |
unique_words_result = ', '.join(unique_words)
|
36 |
+
|
37 |
+
return f"Language: {language}. {num_sentences} sentences, {num_words} words, {num_chars} characters. Most common words: {freq_results}. Unique words: {unique_words_result}. Readability (Flesch Reading Ease): {reading_ease:.2f}. Summary: {summary}"
|
38 |
|
39 |
# Define your interface
|
40 |
interface = gr.Interface(
|
|
|
42 |
inputs=gr.Textbox(lines=4, placeholder="Type something here..."),
|
43 |
outputs="text",
|
44 |
title="Comprehensive Text Analysis with Language Detection",
|
45 |
+
description="This app provides detailed analysis including language detection, sentence, word, and character counts, lists the most common and unique words, calculates readability, and provides a concise summary of the text."
|
46 |
)
|
47 |
|
48 |
# Launch the app
|