Commit ·
c21347b
1
Parent(s): 360a122
reorganize grammar and word origin tables
Browse files
app.py
CHANGED
|
@@ -9,6 +9,17 @@ st.set_page_config(
|
|
| 9 |
page_icon='favicon.svg'
|
| 10 |
)
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
@st.cache_data
|
| 13 |
def load_dataframes():
|
| 14 |
|
|
@@ -18,9 +29,81 @@ def load_dataframes():
|
|
| 18 |
|
| 19 |
return video_df, word_coverage_df, num_video_df
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
st.markdown("Note: this analysis is meant to viewed on a computer and not a phone (sorry!)")
|
| 25 |
|
| 26 |
st.markdown("[Code can be found [here](https://github.com/joshdavham/cij-analysis)]")
|
|
@@ -1315,49 +1398,8 @@ st.altair_chart(sconj_hist, use_container_width=True)
|
|
| 1315 |
|
| 1316 |
st.markdown("We also notice differences in the use of other types of words.")
|
| 1317 |
|
| 1318 |
-
data = {
|
| 1319 |
-
'Complete Beginner': [0.02638719922016275 ,0.0192492959834, 0.00476028625918155, 0.2503071253071253],
|
| 1320 |
-
'Beginner': [0.0473047304730473, 0.0266429840142095, 0.005813953488372, 0.2454068241469816],
|
| 1321 |
-
'Intermediate': [0.06625719079578135, 0.03514773095199635, 0.0087719298245614, 0.23239271705403663],
|
| 1322 |
-
'Advanced': [0.0766787658802177, 0.0373056994818652, 0.0108588351431391, 0.2237101220953131]
|
| 1323 |
-
}
|
| 1324 |
-
df = pd.DataFrame(data)
|
| 1325 |
-
|
| 1326 |
-
row_labels = ['Median Perc. Subordinating Conjunctions', 'Median Perc. Adverbs', 'Median Perc. Determiners', 'Median Perc. Nouns']
|
| 1327 |
-
df.index = row_labels
|
| 1328 |
-
|
| 1329 |
-
styled_df = df.style.set_table_styles(
|
| 1330 |
-
{
|
| 1331 |
-
'Complete Beginner': [
|
| 1332 |
-
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(165, 190, 228, 0.45)')]},
|
| 1333 |
-
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 1334 |
-
],
|
| 1335 |
-
'Beginner': [
|
| 1336 |
-
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(154, 214, 216, 0.45)')]},
|
| 1337 |
-
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 1338 |
-
],
|
| 1339 |
-
'Intermediate': [
|
| 1340 |
-
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(199, 174, 205, 0.45)')]},
|
| 1341 |
-
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 1342 |
-
],
|
| 1343 |
-
'Advanced': [
|
| 1344 |
-
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(221, 158, 158, 0.45)')]},
|
| 1345 |
-
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 1346 |
-
]
|
| 1347 |
-
}).set_properties(**{'background-color': 'white'}).format("{:.2%}")
|
| 1348 |
-
|
| 1349 |
-
st.markdown(
|
| 1350 |
-
"""
|
| 1351 |
-
<style>
|
| 1352 |
-
.dataframe-divv {
|
| 1353 |
-
background-color: white;
|
| 1354 |
-
}
|
| 1355 |
-
</style>
|
| 1356 |
-
""", unsafe_allow_html=True
|
| 1357 |
-
)
|
| 1358 |
-
|
| 1359 |
st.markdown(
|
| 1360 |
-
'<div class="dataframe-
|
| 1361 |
, unsafe_allow_html=True)
|
| 1362 |
|
| 1363 |
###
|
|
@@ -1527,39 +1569,8 @@ st.markdown("In Japanese, Kango are somewhat analogous to French words in Englis
|
|
| 1527 |
|
| 1528 |
st.markdown("We also notice orderings when counting the percentage of Wago and Gairaigo as well.")
|
| 1529 |
|
| 1530 |
-
data = {
|
| 1531 |
-
'Complete Beginner': [0.06999874574159035, 0.8578043261266064, 0.03301790801790795],
|
| 1532 |
-
'Beginner': [0.0955284552845528, 0.8399311531841652, 0.0279441117764471],
|
| 1533 |
-
'Intermediate': [0.1165702954621605, 0.8259877335615461, 0.0241447813837379],
|
| 1534 |
-
'Advanced': [0.1303328645100797, 0.8225274725274725, 0.0157535445475231],
|
| 1535 |
-
}
|
| 1536 |
-
df = pd.DataFrame(data)
|
| 1537 |
-
|
| 1538 |
-
row_labels = ['Median Perc. Kango (漢語)', 'Median Perc. Wago (和語)', 'Median Perc. Garaigo (外来語)']
|
| 1539 |
-
df.index = row_labels
|
| 1540 |
-
|
| 1541 |
-
styled_df = df.style.set_table_styles(
|
| 1542 |
-
{
|
| 1543 |
-
'Complete Beginner': [
|
| 1544 |
-
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(165, 190, 228, 0.45)')]},
|
| 1545 |
-
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 1546 |
-
],
|
| 1547 |
-
'Beginner': [
|
| 1548 |
-
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(154, 214, 216, 0.45)')]},
|
| 1549 |
-
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 1550 |
-
],
|
| 1551 |
-
'Intermediate': [
|
| 1552 |
-
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(199, 174, 205, 0.45)')]},
|
| 1553 |
-
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 1554 |
-
],
|
| 1555 |
-
'Advanced': [
|
| 1556 |
-
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(221, 158, 158, 0.45)')]},
|
| 1557 |
-
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 1558 |
-
],
|
| 1559 |
-
}).set_properties(**{'background-color': 'white'}).format("{:.2%}")
|
| 1560 |
-
|
| 1561 |
st.markdown(
|
| 1562 |
-
'<div class="dataframe-
|
| 1563 |
, unsafe_allow_html=True)
|
| 1564 |
|
| 1565 |
###
|
|
|
|
| 9 |
page_icon='favicon.svg'
|
| 10 |
)
|
| 11 |
|
| 12 |
+
# colors white the index columns of rendered dataframes
|
| 13 |
+
st.markdown(
|
| 14 |
+
"""
|
| 15 |
+
<style>
|
| 16 |
+
.dataframe-div {
|
| 17 |
+
background-color: white;
|
| 18 |
+
}
|
| 19 |
+
</style>
|
| 20 |
+
""", unsafe_allow_html=True
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
@st.cache_data
|
| 24 |
def load_dataframes():
|
| 25 |
|
|
|
|
| 29 |
|
| 30 |
return video_df, word_coverage_df, num_video_df
|
| 31 |
|
| 32 |
+
def get_grammar_table():
|
| 33 |
+
|
| 34 |
+
data = {
|
| 35 |
+
'Complete Beginner': [0.02638719922016275 ,0.0192492959834, 0.00476028625918155, 0.2503071253071253],
|
| 36 |
+
'Beginner': [0.0473047304730473, 0.0266429840142095, 0.005813953488372, 0.2454068241469816],
|
| 37 |
+
'Intermediate': [0.06625719079578135, 0.03514773095199635, 0.0087719298245614, 0.23239271705403663],
|
| 38 |
+
'Advanced': [0.0766787658802177, 0.0373056994818652, 0.0108588351431391, 0.2237101220953131]
|
| 39 |
+
}
|
| 40 |
+
df = pd.DataFrame(data)
|
| 41 |
+
|
| 42 |
+
row_labels = ['Median Perc. Subordinating Conjunctions', 'Median Perc. Adverbs', 'Median Perc. Determiners', 'Median Perc. Nouns']
|
| 43 |
+
df.index = row_labels
|
| 44 |
+
|
| 45 |
+
styled_df = df.style.set_table_styles(
|
| 46 |
+
{
|
| 47 |
+
'Complete Beginner': [
|
| 48 |
+
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(165, 190, 228, 0.45)')]},
|
| 49 |
+
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 50 |
+
],
|
| 51 |
+
'Beginner': [
|
| 52 |
+
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(154, 214, 216, 0.45)')]},
|
| 53 |
+
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 54 |
+
],
|
| 55 |
+
'Intermediate': [
|
| 56 |
+
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(199, 174, 205, 0.45)')]},
|
| 57 |
+
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 58 |
+
],
|
| 59 |
+
'Advanced': [
|
| 60 |
+
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(221, 158, 158, 0.45)')]},
|
| 61 |
+
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 62 |
+
]
|
| 63 |
+
}).set_properties(**{'background-color': 'white'}).format("{:.2%}")
|
| 64 |
+
|
| 65 |
+
return styled_df
|
| 66 |
+
|
| 67 |
+
def get_word_origin_table():
|
| 68 |
+
|
| 69 |
+
data = {
|
| 70 |
+
'Complete Beginner': [0.06999874574159035, 0.8578043261266064, 0.03301790801790795],
|
| 71 |
+
'Beginner': [0.0955284552845528, 0.8399311531841652, 0.0279441117764471],
|
| 72 |
+
'Intermediate': [0.1165702954621605, 0.8259877335615461, 0.0241447813837379],
|
| 73 |
+
'Advanced': [0.1303328645100797, 0.8225274725274725, 0.0157535445475231],
|
| 74 |
+
}
|
| 75 |
+
df = pd.DataFrame(data)
|
| 76 |
+
|
| 77 |
+
row_labels = ['Median Perc. Kango (漢語)', 'Median Perc. Wago (和語)', 'Median Perc. Garaigo (外来語)']
|
| 78 |
+
df.index = row_labels
|
| 79 |
+
|
| 80 |
+
styled_df = df.style.set_table_styles(
|
| 81 |
+
{
|
| 82 |
+
'Complete Beginner': [
|
| 83 |
+
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(165, 190, 228, 0.45)')]},
|
| 84 |
+
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 85 |
+
],
|
| 86 |
+
'Beginner': [
|
| 87 |
+
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(154, 214, 216, 0.45)')]},
|
| 88 |
+
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 89 |
+
],
|
| 90 |
+
'Intermediate': [
|
| 91 |
+
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(199, 174, 205, 0.45)')]},
|
| 92 |
+
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 93 |
+
],
|
| 94 |
+
'Advanced': [
|
| 95 |
+
{'selector': 'th.col_heading.level0', 'props': [('background-color', 'rgba(221, 158, 158, 0.45)')]},
|
| 96 |
+
{'selector': 'td:hover', 'props': [('background-color', '#e0f7fa')]}
|
| 97 |
+
],
|
| 98 |
+
}).set_properties(**{'background-color': 'white'}).format("{:.2%}")
|
| 99 |
+
|
| 100 |
+
return styled_df
|
| 101 |
|
| 102 |
|
| 103 |
+
video_df, word_coverage_df, num_video_df = load_dataframes()
|
| 104 |
+
grammar_table = get_grammar_table()
|
| 105 |
+
word_origin_table = get_word_origin_table()
|
| 106 |
+
|
| 107 |
st.markdown("Note: this analysis is meant to viewed on a computer and not a phone (sorry!)")
|
| 108 |
|
| 109 |
st.markdown("[Code can be found [here](https://github.com/joshdavham/cij-analysis)]")
|
|
|
|
| 1398 |
|
| 1399 |
st.markdown("We also notice differences in the use of other types of words.")
|
| 1400 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1401 |
st.markdown(
|
| 1402 |
+
'<div class="dataframe-div">' + grammar_table.to_html() + "</div>"
|
| 1403 |
, unsafe_allow_html=True)
|
| 1404 |
|
| 1405 |
###
|
|
|
|
| 1569 |
|
| 1570 |
st.markdown("We also notice orderings when counting the percentage of Wago and Gairaigo as well.")
|
| 1571 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1572 |
st.markdown(
|
| 1573 |
+
'<div class="dataframe-div">' + word_origin_table.to_html() + "</div>"
|
| 1574 |
, unsafe_allow_html=True)
|
| 1575 |
|
| 1576 |
###
|