Skip to content

Commit

Permalink
Work Area: Add Profiler - Readability - Easy Listening Formula
Browse files Browse the repository at this point in the history
  • Loading branch information
BLKSerene committed Aug 2, 2023
1 parent b2af8e8 commit 6e944a5
Show file tree
Hide file tree
Showing 18 changed files with 690 additions and 589 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- Utils: Add spaCy's Korean sentence recognizer, word tokenizer, part-of-speech tagger, lemmatizer, and dependency parser
- Utils: Add spaCy's Malay word tokenizer
- Utils: Add spaCy's Slovenian sentence recognizer, part-of-speech tagger, lemmatizer, and dependency parser
- Work Area: Add Profiler - Readability - Bormuth's Cloze Mean / Bormuth's Grade Placement / Coleman's Readability Formula / Dale-Chall Readability Formula (New) / Danielson-Bryan's Readability Formula / Degrees of Reading Power
- Work Area: Add Profiler - Readability - Bormuth's Cloze Mean / Bormuth's Grade Placement / Coleman's Readability Formula / Dale-Chall Readability Formula (New) / Danielson-Bryan's Readability Formula / Degrees of Reading Power / Easy Listening Formula

### ✨ Improvements
- Utils: Update Wordless's sentence and sentence segment splitters
Expand Down
154 changes: 76 additions & 78 deletions doc/doc_eng.md

Large diffs are not rendered by default.

130 changes: 65 additions & 65 deletions doc/measures/dispersion_adjusted_frequency/ald.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 47 additions & 45 deletions doc/measures/dispersion_adjusted_frequency/arf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
116 changes: 58 additions & 58 deletions doc/measures/dispersion_adjusted_frequency/awt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 57 additions & 57 deletions doc/measures/dispersion_adjusted_frequency/carrolls_um.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 18 additions & 17 deletions doc/measures/dispersion_adjusted_frequency/engwalls_fm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 63 additions & 62 deletions doc/measures/dispersion_adjusted_frequency/griess_dp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 56 additions & 56 deletions doc/measures/dispersion_adjusted_frequency/juillands_u.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 31 additions & 31 deletions doc/measures/dispersion_adjusted_frequency/kromers_ur.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 40 additions & 40 deletions doc/measures/dispersion_adjusted_frequency/lynes_d3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 42 additions & 41 deletions doc/measures/dispersion_adjusted_frequency/rosengrens_s.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions doc/measures/readability/elf.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions tests/wl_tests_measures/test_measures_readability.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,23 @@ def test_devereux_readability_index():
assert grade_placement_eng_0 == 'text_too_short'
assert grade_placement_eng_12 == grade_placement_spa_12 == 1.56 * (47 / 12) + 0.19 * (12 / 3) - 6.49

def test_elf():
elf_eng_0 = wl_measures_readability.elf(main, test_text_eng_0)
elf_eng_12 = wl_measures_readability.elf(main, test_text_eng_12)
elf_spa_12 = wl_measures_readability.elf(main, test_text_spa_12)
elf_other_12 = wl_measures_readability.elf(main, test_text_other_12)

print('Easy Listening Formula:')
print(f'\teng/0: {elf_eng_0}')
print(f'\teng/12: {elf_eng_12}')
print(f'\tspa/12: {elf_spa_12}')
print(f'\tother/12: {elf_other_12}')

assert elf_eng_0 == 'text_too_short'
assert elf_eng_12 == (15 - 12) / 3
assert elf_spa_12 != 'no_support'
assert elf_other_12 == 'no_support'

def test_gl():
gl_eng_0 = wl_measures_readability.gl(main, test_text_eng_0)
gl_eng_12 = wl_measures_readability.gl(main, test_text_eng_12)
Expand Down Expand Up @@ -572,6 +589,7 @@ def test_wstf():
test_danielson_bryans_readability_formula()
test_drp()
test_devereux_readability_index()
test_elf()
test_gl()
test_re_flesch()
test_re_simplified()
Expand Down
2 changes: 1 addition & 1 deletion tests/wl_tests_work_area/test_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def update_gui(err_msg, texts_stats_files):
count_tokens_lens_syls.append(collections.Counter(len_tokens_syls))
count_tokens_lens_chars.append(collections.Counter(len_tokens_chars))

assert len(readability_statistics) == 28
assert len(readability_statistics) == 29

# Counts
assert count_paras
Expand Down
19 changes: 18 additions & 1 deletion wordless/wl_measures/wl_measures_readability.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ def dale_chall_readability_formula(main, text):
return x_c50

# Dale-Chall Readability Formula (New)
# Reference: Chall, J. S., & Dale, E. (1995). Readability revisited: The new Dale-Chall readability formula. Brookline Books.
# References:
# Chall, J. S., & Dale, E. (1995). Readability revisited: The new Dale-Chall readability formula. Brookline Books.
# 清川英男. (1996). CHALL, J. S. and DALE, E.(1995) Readability Revisited: The New Dale-Chall Readability Formula. Brookline Books. 教育メディア研究, 3(1), 59. https://www.jstage.jst.go.jp/article/jaems/3/1/3_KJ00009004543/_pdf
def dale_chall_readability_formula_new(main, text):
if text.lang.startswith('eng_'):
text = get_counts(main, text)
Expand Down Expand Up @@ -365,6 +367,21 @@ def devereux_readability_index(main, text):

return grade_placement

# Easy Listening Formula
# Reference: Fang, I. E. (1966). The easy listening formula. Journal of Broadcasting, 11(1), 63–68. https://doi.org/10.1080/08838156609363529
def elf(main, text):
if text.lang in main.settings_global['syl_tokenizers']:
text = get_counts(main, text)

if text.count_sentences:
elf = (text.count_syls - text.count_words) / text.count_sentences
else:
elf = 'text_too_short'
else:
elf = 'no_support'

return elf

# Flesch-Kincaid Grade Level
# Reference: Kincaid, J. P., Fishburne, R. P., Rogers, R. L., & Chissom, B. S. (1975). Derivation of new readability formulas (automated readability index, fog count, and Flesch reading ease formula) for navy enlisted personnel. Naval Air Station Memphis. https://apps.dtic.mil/sti/pdfs/ADA006655.pdf
def gl(main, text):
Expand Down
2 changes: 2 additions & 0 deletions wordless/wl_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def __init__(self, parent):
_tr('wl_profiler', "Danielson-Bryan's Readability Formula"),
_tr('wl_profiler', 'Degrees of Reading Power'),
_tr('wl_profiler', 'Devereaux Readability Index'),
_tr('wl_profiler', 'Easy Listening Formula'),
_tr('wl_profiler', 'Flesch-Kincaid Grade Level'),
_tr('wl_profiler', 'Flesch Reading Ease'),
_tr('wl_profiler', 'Flesch Reading Ease (Simplified)'),
Expand Down Expand Up @@ -1188,6 +1189,7 @@ def run(self):
wl_measures_readability.danielson_bryans_readability_formula(self.main, text),
wl_measures_readability.drp(self.main, text),
wl_measures_readability.devereux_readability_index(self.main, text),
wl_measures_readability.elf(self.main, text),
wl_measures_readability.gl(self.main, text),
wl_measures_readability.re_flesch(self.main, text),
wl_measures_readability.re_simplified(self.main, text),
Expand Down

0 comments on commit 6e944a5

Please sign in to comment.