joshdavham commited on
Commit
770d00e
·
1 Parent(s): 1c38e22

add button

Browse files
Files changed (1) hide show
  1. app.py +26 -20
app.py CHANGED
@@ -6,8 +6,7 @@ st.set_page_config(
6
  page_icon='favicon.svg',
7
  )
8
 
9
- st.markdown("[Code for jreadability python [package](https://github.com/joshdavham/jreadability)]")
10
- st.markdown("[Code for this [demo](https://github.com/joshdavham/jreadability-demo)]")
11
 
12
  lower_intermediate_text = "茶々はわたしの日本語の先輩でした。毎日、日本語を一生懸命勉強して3か月ぐらいたったころには、日本人の友達といろいろな話もできるようになりました。そして茶々よりも日本語がわかるようになりました。けれどわたしの日本語の発音はまだ上手ではありません。家の人はわかってくれますが、茶々はわかりません。「おいで」と言っても茶々は来ません。「ちょっと見てごらん」と言っても見ません。「散歩に行こう」と言ってもふりむいてくれません。だから、いっしょに散歩することもできません。わたしの発音が家の人とちがうからです。それが大変ざんねんでした。それで、わたしはテープをたくさん聞いて練習しました。そして、はじめて茶々がわたしの「おいで」を聞いて、わたしのところへ来てくれた時は、本当にうれしくなりました。\
13
  わたしの日本語がやっと茶々につうじたからです。今は、わたしは日本の生活にだいぶなれました。茶々はもう、わたしの日本語が大体わかりますから、毎日いっしょに散歩します。わたしの日本語の先輩、茶々のおかげで日本語も上手になったし、犬がこわくなくなって、犬が好きになりました。今度、わたしは茶々に中国語を教えようと思います。そして、中国語と日本語と、二つのことばのわかる犬にするつもりです。"
@@ -15,7 +14,7 @@ lower_intermediate_text = "茶々はわたしの日本語の先輩でした。
15
  st.image("logo.svg", use_column_width=False, width=350)
16
 
17
  text = st.text_area(
18
- label="Input Japanese text below",
19
  label_visibility='visible',
20
  height=350,
21
  max_chars=None,
@@ -24,30 +23,37 @@ text = st.text_area(
24
  value = lower_intermediate_text,
25
  )
26
 
27
- if text:
28
 
29
- score = compute_readability(text)
30
 
31
- if 0.5 <= score < 6.5:
32
 
33
- if 0.5 <= score < 1.5:
34
- st.error(f"Readability score: **{score:.2f}** \nLevel: **Upper-advanced**")
35
- elif 1.5 <= score < 2.5:
36
- st.error(f"Readability score: **{score:.2f}** \nLevel: **Lower-advanced**")
37
- elif 2.5 <= score < 3.5:
38
- st.info(f"Readability score: **{score:.2f}** \nLevel: **Upper-intermediate**")
39
- elif 3.5 <= score < 4.5:
40
- st.info(f"Readability score: **{score:.2f}** \nLevel: **Lower-intermediate**")
41
- elif 4.5 <= score < 5.5:
42
- st.success(f"Readability score: **{score:.2f}** \nLevel: **Upper-elementary**")
43
- elif 5.5 <= score < 6.5:
44
- st.success(f"Readability score: **{score:.2f}** \nLevel: **Lower-elementary**")
45
 
46
- st.progress(1-((score - 0.5) / 6.0) )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  else:
49
 
50
- st.warning(f"Readability score: **{score:.2f}** \nLevel: **Undefined**")
 
51
 
52
  else:
53
 
 
6
  page_icon='favicon.svg',
7
  )
8
 
9
+ st.markdown("[Code for jreadability python [package](https://github.com/joshdavham/jreadability) and [demo](https://github.com/joshdavham/jreadability-demo)]")
 
10
 
11
  lower_intermediate_text = "茶々はわたしの日本語の先輩でした。毎日、日本語を一生懸命勉強して3か月ぐらいたったころには、日本人の友達といろいろな話もできるようになりました。そして茶々よりも日本語がわかるようになりました。けれどわたしの日本語の発音はまだ上手ではありません。家の人はわかってくれますが、茶々はわかりません。「おいで」と言っても茶々は来ません。「ちょっと見てごらん」と言っても見ません。「散歩に行こう」と言ってもふりむいてくれません。だから、いっしょに散歩することもできません。わたしの発音が家の人とちがうからです。それが大変ざんねんでした。それで、わたしはテープをたくさん聞いて練習しました。そして、はじめて茶々がわたしの「おいで」を聞いて、わたしのところへ来てくれた時は、本当にうれしくなりました。\
12
  わたしの日本語がやっと茶々につうじたからです。今は、わたしは日本の生活にだいぶなれました。茶々はもう、わたしの日本語が大体わかりますから、毎日いっしょに散歩します。わたしの日本語の先輩、茶々のおかげで日本語も上手になったし、犬がこわくなくなって、犬が好きになりました。今度、わたしは茶々に中国語を教えようと思います。そして、中国語と日本語と、二つのことばのわかる犬にするつもりです。"
 
14
  st.image("logo.svg", use_column_width=False, width=350)
15
 
16
  text = st.text_area(
17
+ label="Input Japanese text below and then click the button",
18
  label_visibility='visible',
19
  height=350,
20
  max_chars=None,
 
23
  value = lower_intermediate_text,
24
  )
25
 
26
+ if st.button("Compute readability"):
27
 
28
+ if text:
29
 
30
+ score = compute_readability(text)
31
 
32
+ if 0.5 <= score < 6.5:
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ if 0.5 <= score < 1.5:
35
+ st.error(f"Readability score: **{score:.2f}** \nLevel: **Upper-advanced**")
36
+ elif 1.5 <= score < 2.5:
37
+ st.error(f"Readability score: **{score:.2f}** \nLevel: **Lower-advanced**")
38
+ elif 2.5 <= score < 3.5:
39
+ st.info(f"Readability score: **{score:.2f}** \nLevel: **Upper-intermediate**")
40
+ elif 3.5 <= score < 4.5:
41
+ st.info(f"Readability score: **{score:.2f}** \nLevel: **Lower-intermediate**")
42
+ elif 4.5 <= score < 5.5:
43
+ st.success(f"Readability score: **{score:.2f}** \nLevel: **Upper-elementary**")
44
+ elif 5.5 <= score < 6.5:
45
+ st.success(f"Readability score: **{score:.2f}** \nLevel: **Lower-elementary**")
46
+
47
+ st.progress(1-((score - 0.5) / 6.0) )
48
+
49
+ else:
50
+
51
+ st.warning(f"Readability score: **{score:.2f}** \nLevel: **Undefined**")
52
 
53
  else:
54
 
55
+ st.info(f"Readability score: \nLevel:")
56
+ st.progress(0.0)
57
 
58
  else:
59