Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cecoeco committed Sep 14, 2024
1 parent 6b655cc commit 849b337
Show file tree
Hide file tree
Showing 24 changed files with 654 additions and 340 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ docs/site/
Manifest.toml

# MacOS
*.DS_Store
*.DS_Store
app
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Readability"
uuid = "4455ec5f-b558-4ef1-b6d8-c3694046c382"
authors = ["Ceco E. Maples <mapleselijah9@gmail.com>"]
version = "0.4.0"
version = "0.5.0"

[compat]
julia = "1"
Expand Down
47 changes: 14 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,20 @@
# Readability
<div>
<a href="https://github.com/cecoeco/Readability.jl/actions/workflows/CI.yml"><img alt="CI test" src="https://github.com/cecoeco/Readability.jl/actions/workflows/CI.yml/badge.svg"></a>
<a href="https://cecoeco.github.io/Readability.jl/stable/"><img src="https://img.shields.io/badge/docs-stable-blue.svg" alt="Documentation Stable" /></a>
<a href="https://cecoeco.github.io/Readability.jl/dev/"><img src="https://img.shields.io/badge/docs-dev-blue.svg" alt="Documentation Dev"></a>
<a href="https://juliapkgstats.com/pkg/Readability"><img src="https://img.shields.io/badge/dynamic/json?url=http%3A%2F%2Fjuliapkgstats.com%2Fapi%2Fv1%2Fmonthly_downloads%2FReadability&query=total_requests&suffix=%2Fmonth&label=Downloads" alt="Package Statistics"></a>
<a href="https://github.com/JuliaDiff/BlueStyle"><img alt="Style: Blue" src="https://img.shields.io/badge/code%20style-blue-4495d1.svg"></a>

Julia package that analyzes the difficulty of texts using different indexes like Gunning-Fog, SMOG, and Flesch-Kincaid.

## Features
- count number of words in string
- count number of syllables in string
- count number of sentences in string
- count number of characters in string
- count number of complex words in string
- count number of polysyllabic words in string
- determine average reading time
- determine average speaking time
- determine difficulty and reading grade level of text
- web-based interface that requires zero knowledge of Julia or programming.
</div>

```julia
using Pkg
Pkg.add("Readability")
# Readability.jl

using Readability, HTTP
Julia package that analyzes the difficulty of texts using different indexes like Gunning-Fog, SMOG, and Flesch-Kincaid.

url = "https://en.wikipedia.org/wiki/Enzyme"
## Installation

response = HTTP.get(url)
txt = String(response.body)
use this command in the Julia REPL:

metric_01 = Readability.reading_time(txt, wpm=250)
metric_02 = Readability.speaking_time(txt, wpm=200)
metric_03 = Readability.characters(txt)
metric_04 = Readability.sentences(txt)
metric_05 = Readability.syllables(txt)
metric_06 = Readability.words(txt)
metric_07 = Readability.complex_words(txt)
metric_08 = Readability.polysyllabic_words(txt)
metric_09 = Readability.difficult_words(txt, "dale-chall")
metric_10 = Readability.difficult_words(txt, "spache")
metric_11 = Readability.ari(txt)
```
```julia
using Pkg; Pkg.add("TextCoder")
```
4 changes: 3 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
Readability = "4455ec5f-b558-4ef1-b6d8-c3694046c382"

[compat]
Documenter = "1"
Readability = "0.4"
DocumenterCitations = "1"
Readability = "0.5"
julia = "1"
16 changes: 12 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
using Documenter, Readability
using Documenter, DocumenterCitations, Readability

const ASSETS::String = joinpath(dirname(@__FILE__), "src/assets")

Documenter.makedocs(
modules=[Readability],
pages=["Home" => "index.md"],
repo="https://github.com/cecoeco/Readability.jl",
format=Documenter.HTML(assets=["assets/bib.css"]),
sitename="Readability.jl",
authors="Ceco Elijah Maples"
authors="Ceco Elijah Maples and Contributors",
pages=["Home" => "index.md", "API" => "api.md"],
plugins=[
DocumenterCitations.CitationBibliography(
joinpath(ASSETS, "references.bib"),
style=:numeric
)
]
)

Documenter.deploydocs(repo="github.com/cecoeco/Readability.jl.git")
27 changes: 27 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# API

```@docs
Readability.ari
Readability.characters
Readability.characters_per_word
Readability.coleman_liau
Readability.complex_words
Readability.dale_chall
Readability.difficult_words
Readability.flesch_kincaid_grade_level
Readability.flesch_reading_ease_score
Readability.gunning_fog
Readability.lines
Readability.paragraphs
Readability.polysyllabic_words
Readability.reading_time
Readability.sentences
Readability.sentences_per_paragraph
Readability.smog
Readability.spache
Readability.speaking_time
Readability.syllables
Readability.syllables_per_word
Readability.words
Readability.words_per_sentence
```
28 changes: 28 additions & 0 deletions docs/src/assets/bib.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.citation dl {
display: grid;
grid-template-columns: max-content auto;
}

.citation dt {
grid-column-start: 1;
}

.citation dd {
grid-column-start: 2;
margin-bottom: 0.75em;
}

.citation ul {
padding: 0 0 2.25em 0;
margin: 0;
list-style: none !important;
}

.citation ul li {
text-indent: -2.25em;
margin: 0.33em 0.5em 0.5em 2.25em;
}

.citation ol li {
padding-left: 0.75em;
}
12 changes: 12 additions & 0 deletions docs/src/assets/references.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@article{bezanson_julia_2017,
title = {Julia: {A} fresh approach to numerical computing},
volume = {59},
url = {https://epubs.siam.org/doi/10.1137/141000671},
doi = {10.1137/141000671},
number = {1},
journal = {SIAM Review},
author = {Bezanson, Jeff and Edelman, Alan and Karpinski, Stefan and Shah, Viral B},
year = {2017},
note = {Publisher: SIAM},
pages = {65--98}
}
43 changes: 1 addition & 42 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,42 +1 @@
```@docs
Readability.reading_time
Readability.speaking_time
Readability.characters
Readability.characters_per_word
Readability.syllables
Readability.syllables_per_word
Readability.words
Readability.words_per_sentence
Readability.difficult_words
Readability.complex_words
Readability.polysyllabic_words
Readability.sentences
Readability.sentences_per_paragraph
Readability.lines
Readability.paragraphs
Readability.ari
Readability.coleman_liau
Readability.gunning_fog
Readability.flesch_reading_ease
Readability.flesch_kincaid_grade_level
Readability.smog
Readability.dale_chall
Readability.spache
```
# Home
98 changes: 76 additions & 22 deletions src/Readability.jl
Original file line number Diff line number Diff line change
@@ -1,27 +1,81 @@
"""
# Readability.jl
Julia package for computing readability scores.
## Functions:
- `Readability.ari(text::String)::Int`
- `Readability.characters(text::String)::Int`
- `Readability.characters_per_word(text::String)::Number`
- `Readability.coleman_liau(text::String)::Number`
- `Readability.complex_words(text::String)::Int`
- `Readability.dale_chall(text::String)::Number`
- `Readability.difficult_words(text::String, word_list::String)::Int`
- `Readability.flesch_kincaid_grade_level(text::String)::Float64`
- `Readability.flesch_reading_ease_score(text::String)::Float64`
- `Readability.gunning_fog(text::String)::Number`
- `Readability.lines(text::String)::Int`
- `Readability.paragraphs(text::String)::Int`
- `Readability.polysyllabic_words(text::String)::Int`
- `Readability.reading_time(text::String; wpm::Number=183)::Number`
- `Readability.sentences(text::String)::Int`
- `Readability.sentences_per_paragraph(text::String)::Number`
- `Readability.smog(text::String)::Number`
- `Readability.spache(text::String)::Number`
- `Readability.speaking_time(text::String; wpm::Number=183)::Number`
- `Readability.syllables(text::String)::Int`
- `Readability.syllables_per_word(text::String)::Number`
- `Readability.words(text::String)::Int`
- `Readability.words_per_sentence(text::String)::Number`
"""
module Readability

export reading_time, speaking_time
export characters, characters_per_word
export syllables, syllables_per_word
export words, words_per_sentence
export sentences, sentences_per_paragraph
export lines, paragraphs
export ari
export coleman_liau
export dale_chall, spache, difficult_words
export flesch_kincaid_grade_level, flesch_reading_ease
export gunning_fog, complex_words
export smog, polysyllabic_words
export
# core.jl
characters,
characters_per_word,
sentences,
sentences_per_paragraph,
syllables,
syllables_per_word,
words,
words_per_sentence,
lines,
paragraphs,
# ari.jl
ari,
# coleman-liau.jl
coleman_liau,
# dale-chall+spache.jl
dale_chall,
spache,
difficult_words,
# flesch.jl
flesch_kincaid_grade_level,
flesch_reading_ease_score,
# gunning_fog.jl
gunning_fog,
complex_words,
# smog.jl
smog,
polysyllabic_words,
# time.jl
reading_time,
speaking_time

include("counts.jl")
include("time.jl")
include("ari.jl") # Automatic Readability Index
include("coleman-liau.jl")
include("dale-chall.jl")
include("fkgl.jl") # Flesch-Kincaid Grade Level
include("fres.jl") # Flesch Reading Ease Score
include("gunning_fog.jl")
include("smog.jl") # Simple Measure of Gobbledygook
include("spache.jl")
for file in [
"core.jl",
"ari.jl",
"coleman-liau.jl",
"dale-chall+spache.jl",
"flesch.jl",
"gunning_fog.jl",
"smog.jl",
"time.jl",
]
include(file)
end

end
14 changes: 13 additions & 1 deletion src/ari.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
ari(text::String)
Returns the Automated Readability Index (ARI) of `text`.
## Argument
- `text::String`: The text to analyze.
## Returns
- `Int`: The ARI score.
## Reference
- [ARI](https://en.wikipedia.org/wiki/Automated_readability_index)
"""
function ari(text::String)
function ari(text::String)::Int
return Base.ceil(Int, 4.71 * characters_per_word(text) + 0.5 * words_per_sentence(text) - 21.43)
end
33 changes: 28 additions & 5 deletions src/coleman-liau.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
function characters_per_100_words(text::String)::Number
return characters(text) / words(text) * 100
end

function sentences_per_100_words(text::String)::Number
return sentences(text) / words(text) * 100
end

"""
coleman_liau(text::String)
Returns the Coleman-Liau index of `text`.
Returns the Coleman-Liau Index of `text`.
CLI = 0.0588 * L - 0.296 * S - 15.8
L = number of characters per 100 words
S = number of sentences per 100 words
## Argument
- `text::String`: The text to analyze.
## Returns
- `Number`: The Coleman-Liau Index.
"""
function coleman_liau(text::String)
characters_per_100_words::Float64 = characters(text) / words(text) * 100
sentences_per_100_words::Float64 = sentences(text) / words(text) * 100
function coleman_liau(text::String)::Number
L::Number = characters_per_100_words(text)
S::Number = sentences_per_100_words(text)

return 0.0588 * characters_per_100_words - 0.296 * sentences_per_100_words - 15.8
return 0.0588 * L - 0.296 * S - 15.8
end
Loading

0 comments on commit 849b337

Please sign in to comment.