SUGAR metrics in python
Project description
sugarpy
A library, API and web app for using NLP to perform language sample analysis using the SUGAR framework. This is primarily meant as a tool for Speech Language Pathologists (SLPs) to expedite the often time-consuming process of computing SUGAR metrics by hand.
The sugarpy python library is the core driver of the tool. It uses classical NLP (spacy) to perform rule-based and token based analysis on the input language samples.
Install
To install the python library, use pip:
pip install sugar-python
You can also clone this repo and install from source using uv:
uv sync
Use
The main operation in sugarpy is get_metrics:
from sugarpy import get_metrics
language_samples = [
"My last name is Y and my middle name is Z",
"And you can take this bag off and wear it",
"But it’s a little small",
"Yea mine didn’t come with one that matches",
"It didn’t come with this; it came with these markers"
]
metrics = get_metrics(language_samples)
The result is an object with the four SUGAR metrics as attributes: mlu (mean length utterance), cps (clauses per sentence), wps (words per sentence), and tnw (total number of words).
One can also check whether the resulting metrics are within established averages. The mean and standard deviation for each score depends on the subject's age, and they are found in sugarpy/norms.py. To retrieve them, use get_norms:
from sugarpy import get_norms
age_y = 4 #Age in years
age_m = 11 #Age in months
norms = get_norms(age_y,age_m, "mlu") # Returns {'min_age': 108, 'max_age': 131, 'mean_score': 9.61, 'sd': 1.52}
The min_age and max_age are measured in months, and are the age range for which the mean_score and sd (standard deviation) apply. In the above example, children between the ages of 108 months and 131 months have a mean mlu score of 9.61, with a standard deviation of 1.52.
All of this data is taken directly from the SUGAR language website.
Configuration
The library is configured to use the spacy model en_core_web_lg by default. This is a CPU-performant token classification model. You can substitute a different spacy model, such as a transformer-based one like en_core_web_trf, by passing model=<your_model_name> to the get_metrics function:
from sugarpy import get_metrics
...
metrics = get_metrics(language_samples, model="en_core_web_trf")
You will need to ensure that any model you pass has already been installed on your machine.
License
This project is licensed under the MIT license. Please see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sugar_python-0.4.3.tar.gz.
File metadata
- Download URL: sugar_python-0.4.3.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba4b3430b411c64cd5e0f3378b8ad103dbdbe3bbc335814a204cf310b00c4c28
|
|
| MD5 |
aaacb5b7791ffbe03de23745e5559650
|
|
| BLAKE2b-256 |
b0e3aed3df62483ca6868269b3aa887d89244cb1b9edf1fd6ff01bbf194b6a04
|
Provenance
The following attestation bundles were made for sugar_python-0.4.3.tar.gz:
Publisher:
publish.yaml on geodavic/sugarpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sugar_python-0.4.3.tar.gz -
Subject digest:
ba4b3430b411c64cd5e0f3378b8ad103dbdbe3bbc335814a204cf310b00c4c28 - Sigstore transparency entry: 954365544
- Sigstore integration time:
-
Permalink:
geodavic/sugarpy@53204b247dbc661bdcaa60bb846784dd69b74639 -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/geodavic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@53204b247dbc661bdcaa60bb846784dd69b74639 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sugar_python-0.4.3-py3-none-any.whl.
File metadata
- Download URL: sugar_python-0.4.3-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61768dfeac7bd0cad7e97c712de1b95f7a0add9d2e528a2139270029a06f5573
|
|
| MD5 |
9f35ad350312cb24dd6f866217b5f722
|
|
| BLAKE2b-256 |
1534bfe4f6e3b35d2a6d58157ad93e83996e42af09fdc1e2cc31e795e99794a0
|
Provenance
The following attestation bundles were made for sugar_python-0.4.3-py3-none-any.whl:
Publisher:
publish.yaml on geodavic/sugarpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sugar_python-0.4.3-py3-none-any.whl -
Subject digest:
61768dfeac7bd0cad7e97c712de1b95f7a0add9d2e528a2139270029a06f5573 - Sigstore transparency entry: 954365545
- Sigstore integration time:
-
Permalink:
geodavic/sugarpy@53204b247dbc661bdcaa60bb846784dd69b74639 -
Branch / Tag:
refs/tags/v0.4.3 - Owner: https://github.com/geodavic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@53204b247dbc661bdcaa60bb846784dd69b74639 -
Trigger Event:
push
-
Statement type: