Skip to content

Commit c163059

Browse files
Merge pull request #379 from HLasse/drop-39
feat: drop python 3.9 support
2 parents 58eefff + ca98b04 commit c163059

14 files changed

Lines changed: 5596 additions & 2903 deletions

.github/workflows/documentation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions/checkout@v3
1616
with:
1717
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
18-
token: ${{ secrets.SPHINX_DOCUMENTATION}}
18+
token: ${{ secrets.GITHUB_TOKEN}}
1919

2020
- name: Set up Python
2121
uses: actions/setup-python@v4
@@ -41,5 +41,5 @@ jobs:
4141
if: ${{ github.event_name == 'push' }}
4242
uses: ad-m/github-push-action@v0.6.0
4343
with:
44-
github_token: ${{ secrets.SPHINX_DOCUMENTATION }}
44+
github_token: ${{ secrets.GITHUB_TOKEN }}
4545
branch: gh-pages

.github/workflows/tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ jobs:
1111
strategy:
1212
matrix:
1313
os: [ubuntu-latest, macos-latest, windows-latest]
14-
python-version: ["3.9", "3.10"]
14+
python-version: ["3.10", "3.11"]
1515

1616
# This allows a subsequently queued workflow run to interrupt previous runs
1717
concurrency:
1818
group: "${{ github.workflow }} - ${{ matrix.python-version}} - ${{ matrix.os }} @ ${{ github.ref }}"
19-
cancel-in-progress: true
2019

2120
steps:
2221
- uses: actions/checkout@v3
@@ -49,7 +48,6 @@ jobs:
4948
pip install ".[tutorials]"
5049
pip install -r ./docs/tutorials/requirements.txt
5150
52-
5351
- name: Convert and run notebooks
5452
shell: bash
5553
run: |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![github actions pytest](https://github.com/hlasse/textdescriptives/actions/workflows/tests.yml/badge.svg)](https://github.com/hlasse/textdescriptives/actions)
99
[![github actions docs](https://github.com/hlasse/textdescriptives/actions/workflows/documentation.yml/badge.svg)](https://hlasse.github.io/TextDescriptives/)
1010
[![status](https://joss.theoj.org/papers/06447337ee61969b5a64de484199df24/status.svg)](https://joss.theoj.org/papers/06447337ee61969b5a64de484199df24)
11-
[![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://huggingface.co/spaces/HLasse/textdescriptives)
11+
[![Open in Spaces](https://huggingface.co/datasets/huggingface/badges/resolve/main/open-in-hf-spaces-sm-dark.svg)](https://huggingface.co/spaces/HLasse/textdescriptives)
1212

1313
A Python library for calculating a large variety of metrics from text(s) using spaCy v.3 pipeline components and extensions.
1414

docs/coherence.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The `coherence` components calculates the coherence of the document, based on
55
word embedding cosine similarity between sentences.
66

77
textdescriptives currently implements first-order and second-order coherence. The
8-
implementation follows e.g. [1] and [2]:
8+
implementation follows e.g. `[1] <https://doi.org/10.1038/npjschz.2015.30>_` and `[2] <https://doi.org/10.1016/j.schres.2022.07.002>_`:
99
* First-order coherence: The cosine similarity between consecutive sentences.
1010
* Second-order coherence: The cosine similarity between sentences that are two sentences apart.
1111

@@ -18,17 +18,13 @@ and `overwriting the vector attribute <https://spacy.io/usage/linguistic-feature
1818

1919
The following attributes are added to :code:`Doc` objects.:
2020

21-
* ._.first_order_coherence_values: A list of floats, where each float is the
21+
* :code:`._.first_order_coherence_values`: A list of floats, where each float is the
2222
cosine similarity between consecutive sentences.
23-
* ._.second_order_coherence_values: A list of floats, where each float is the
23+
* :code:`._.second_order_coherence_values`: A list of floats, where each float is the
2424
cosine similarity between sentences that are two sentences apart.
25-
* ._.cohererence: a dict containing the mean coherence values for first and
25+
* :code:`._.coherence`: a dict containing the mean coherence values for first and
2626
second order coherence (keys: "first_order_coherence", "second_order_coherence")
2727

28-
[1] Bedi, G., Carrillo, F., Cecchi, G. A., Slezak, D. F., Sigman, M., Mota, N. B., Ribeiro, S., Javitt, D. C., Copelli, M., & Corcoran, C. M. (2015). Automated analysis of free speech predicts psychosis onset in high-risk youths. Npj Schizophrenia, 1(1), Article 1. https://doi.org/10.1038/npjschz.2015.30
29-
30-
[2] Parola, A., Lin, J. M., Simonsen, A., Bliksted, V., Zhou, Y., Wang, H., Inoue, L., Koelkebeck, K., & Fusaroli, R. (2022). Speech disturbances in schizophrenia: Assessing cross-linguistic generalizability of NLP automated measures of coherence. Schizophrenia Research. https://doi.org/10.1016/j.schres.2022.07.002
31-
3228

3329
Usage
3430
~~~~~~
@@ -66,3 +62,8 @@ Component
6662
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6763

6864
.. autofunction:: textdescriptives.components.coherence.create_coherence_component
65+
66+
67+
[1] Bedi, G., Carrillo, F., Cecchi, G. A., Slezak, D. F., Sigman, M., Mota, N. B., Ribeiro, S., Javitt, D. C., Copelli, M., & Corcoran, C. M. (2015). Automated analysis of free speech predicts psychosis onset in high-risk youths. Npj Schizophrenia, 1(1), Article 1. https://doi.org/10.1038/npjschz.2015.30
68+
69+
[2] Parola, A., Lin, J. M., Simonsen, A., Bliksted, V., Zhou, Y., Wang, H., Inoue, L., Koelkebeck, K., & Fusaroli, R. (2022). Speech disturbances in schizophrenia: Assessing cross-linguistic generalizability of NLP automated measures of coherence. Schizophrenia Research. https://doi.org/10.1016/j.schres.2022.07.002

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@
5959
# -- Options for myst-nb -----------------------------------------------------
6060

6161
# set the timeout for executing notebooks
62-
# nb_execution_timeout = 600 # in seconds, default 30 seconds
63-
nb_execution_timeout = 600 # in seconds, default 30 seconds. 600 seconds = 10 minutes
62+
# nb_execution_timeout = 600 # in seconds, default 30 seconds. 600 seconds = 10 minutes
6463

6564
# always fail CI pipeline when nb cannot be executed
66-
nb_execution_raise_on_error = True
65+
# nb_execution_raise_on_error = True
66+
nb_execution_mode = "off" # for now we will not execute the notebooks during doc build
6767

6868

6969
# -- Options for HTML output -------------------------------------------------

docs/faq.rst

Lines changed: 0 additions & 61 deletions
This file was deleted.

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TextDescriptives
77
TextDescriptives is Python library for calculating a large variety of statistics from text(s) using spaCy v.3 pipeline components and extensions.
88
TextDescriptives can be used to calculate several descriptive statistics, readability metrics, and metrics related to dependency distance.
99
If you wish to try out the package, you can use the `online demo <https://huggingface.co/spaces/HLasse/textdescriptives>`__.
10-
10+
1111
The documentation is organized in two parts:
1212

1313
- **Getting Started** contains the installation instructions, guides, and tutorials on how to use the package.

docs/information_theory.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ Information Theory
44
The `information_theory` component calculates information theoretic measures derived
55
from the text. These include:
66

7-
- `{doc/span}._.entropy`: the Shannon entropy of the text using the `token.prob` as the probability
7+
8+
- :code:`{doc/span}._.entropy`: the Shannon entropy of the text using the `token.prob` as the probability
89
of each token. Entropy is defined as :math:`H(X) = -\sum_{i=1}^n p(x_i) \log_e p(x_i)`. Where :math:`p(x_i)` is the probability of the token :math:`x_i`.
9-
- `{doc/span}._.perplexity`: the perplexity of the text. Perplexity is a measurement of how well a
10+
- :code:`{doc/span}._.perplexity`: the perplexity of the text. Perplexity is a measurement of how well a
1011
probability distribution or probability model predicts a sample. Perplexity is defined as :math:`PPL(X) = e^{-H(X)}`, where :math:`H(X)` is the entropy of the text.
11-
- `{doc/span}._.per_word_perplexity`: The perplexity of the text, divided by the number of words. Can be considered the length-normalized perplexity.
12+
- :code:`{doc/span}._.per_word_perplexity`: The perplexity of the text, divided by the number of words. Can be considered the length-normalized perplexity.
1213

1314
These information theoretic measures are for example often used to describe the complexity of a text.
1415
The higher the entropy, the more complex the text is.

docs/news.rst

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/readability.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,49 @@ The *readability* component adds the following readabiltiy metrics under the :co
99

1010

1111

12-
* **`Gunning-Fog <https://en.wikipedia.org/wiki/Gunning_fog_index>`__**, is a readability index originally developed for English writing, but works for any language. The index estimates the years of formal education needed to understand the text on a first reading. A Gunning-Fog index of 12 requires the reading level of a U.S. high school senior (around 18 years old). The formula for calculating the index is:
12+
* `Gunning-Fog <https://en.wikipedia.org/wiki/Gunning_fog_index>`__, is a readability index originally developed for English writing, but works for any language. The index estimates the years of formal education needed to understand the text on a first reading. A Gunning-Fog index of 12 requires the reading level of a U.S. high school senior (around 18 years old). The formula for calculating the index is:
1313

1414
*Grade level = 0.4 × (ASL + PHW)*
1515

1616
Where *ASL* is the average sentence length (total words / total sentences), and *PHW* is the percentage of hard words (words with three or more syllables).
1717

1818
Note: requires hyphenation.
1919

20-
* **`SMOG <https://en.wikipedia.org/wiki/SMOG>`__**, or Simple Measure of Gobbledygook, is a readability formula that estimates the years of education required to understand a piece of writing. It primarily focuses on the complexity of words, using the number of polysyllabic words in the text. The formula is:
20+
* `SMOG <https://en.wikipedia.org/wiki/SMOG>`__, or Simple Measure of Gobbledygook, is a readability formula that estimates the years of education required to understand a piece of writing. It primarily focuses on the complexity of words, using the number of polysyllabic words in the text. The formula is:
2121

2222
*SMOG Index = 1.043 × √(30 × (hard words / n_sentences)) + 3.1291*
2323

2424
Note: requires hyphenation.
2525

26-
* **`Flesch reading ease <https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch_reading_ease>`__**, is a readability score that indicates how easy a text is to read. Higher scores indicate easier reading, while lower scores indicate more difficult reading. The score is calculated using the following formula:
26+
* `Flesch reading ease <https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch_reading_ease>`__, is a readability score that indicates how easy a text is to read. Higher scores indicate easier reading, while lower scores indicate more difficult reading. The score is calculated using the following formula:
2727

2828
*Flesch Reading Ease = 206.835 - (1.015 × ASL) - (84.6 × ASW)*
2929

3030
Where *ASL* is the average sentence length and *ASW* is the average number of syllables per word.
3131

3232
Note: requires hyphenation.
3333

34-
* **`Flesch-Kincaid grade <https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch%E2%80%93Kincaid_grade_level>`__**, is a readability metric that estimates the grade level needed to comprehend a text. It is based on the average sentence length and average number of syllables per word. The formula is:
34+
* `Flesch-Kincaid grade <https://en.wikipedia.org/wiki/Flesch%E2%80%93Kincaid_readability_tests#Flesch%E2%80%93Kincaid_grade_level>`__, is a readability metric that estimates the grade level needed to comprehend a text. It is based on the average sentence length and average number of syllables per word. The formula is:
3535

3636
*Flesch-Kincaid Grade = 0.39 × (ASL) + 11.8 × (ASW) - 15.59*
3737

3838
Note: requires hyphenation.
3939

40-
* **`Automated readability index <https://en.wikipedia.org/wiki/Automated_readability_index>`__**, is a readability test that calculates an approximate U.S. grade level needed to understand a text. It is based on the average number of characters per word and the average sentence length. The formula is:
40+
* `Automated readability index <https://en.wikipedia.org/wiki/Automated_readability_index>`__, is a readability test that calculates an approximate U.S. grade level needed to understand a text. It is based on the average number of characters per word and the average sentence length. The formula is:
4141

4242
*ARI = 4.71 × (n_chars / n_words) + 0.5 × (n_words / n_sentences) - 21.43*
4343

44-
* **`Coleman-Liau index <https://en.wikipedia.org/wiki/Coleman%E2%80%93Liau_index>`___**, is a readability test that estimates the U.S. grade level needed to understand a text. It is based on the average number of letters per 100 words and the average number of sentences per 100 words. The original formula is:
44+
* `Coleman-Liau index <https://en.wikipedia.org/wiki/Coleman%E2%80%93Liau_index>`___, is a readability test that estimates the U.S. grade level needed to understand a text. It is based on the average number of letters per 100 words and the average number of sentences per 100 words. The original formula is:
4545

4646
*CLI = 0.0588 × L - 0.296 × S - 15.8*
4747

4848
Where *L* is the average number of characters per 100 words and *S* is the average number of sentences per 100 words. In our implementation we average over the entire text instead of just 100 words.
4949

50-
* **`Lix <https://en.wikipedia.org/wiki/Lix_(readability_test)>`__**, or Lesbarhetsindex, is a readability measure that calculates a readability score based on the average sentence length and the percentage of long words (more than six characters) in the text. The formula is:
50+
* `Lix <https://en.wikipedia.org/wiki/Lix_(readability_test)>`__, or Lesbarhetsindex, is a readability measure that calculates a readability score based on the average sentence length and the percentage of long words (more than six characters) in the text. The formula is:
5151

5252
*Lix = (n_words / n_sentences) + (n_long_words * 100) / n_words*
5353

54-
* **`Rix <https://www.jstor.org/stable/40031755>`__**, is a readability measure that estimates the difficulty of a text based on the proportion of long words (more than six characters) in the text. The formula is:
54+
* `Rix <https://www.jstor.org/stable/40031755>`__, is a readability measure that estimates the difficulty of a text based on the proportion of long words (more than six characters) in the text. The formula is:
5555

5656
*Rix = (n_long_words / n_sentences)*
5757

0 commit comments

Comments
 (0)