# English Readability Scorer (`eichan/english-readability-scorer`) Actor

- **URL**: https://apify.com/eichan/english-readability-scorer.md
- **Developed by:** [Eichan Jolly](https://apify.com/eichan) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.01 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## English Readability Scorer

A small, **deterministic English text readability estimator**. It counts words and sentences, estimates syllables from spelling, and applies three published readability formulas. It does not use machine learning, LLMs, APIs, browsing, or third-party Python packages.

### Who this is for

Editors, documentation writers, content operations teams, and anyone who wants a quick **approximate** difficulty check for an English passage. It is not a substitute for a reader study or editorial review.

### What it does

Given one block of English text, writes **exactly one** JSON Dataset item. The output always includes `charactersAnalyzed`, `wordCount`, `sentenceCount`, `syllableCount`, `fleschReadingEase`, `fleschKincaidGrade`, `gunningFog`, `averageWordsPerSentence`, `method`, `level`, and `note`.

- `fleschReadingEase`: higher is conventionally easier; formula `206.835 − 1.015 × words/sentences − 84.6 × syllables/words`.
- `fleschKincaidGrade`: approximate US grade-level formula `0.39 × words/sentences + 11.8 × syllables/words − 15.59`.
- `gunningFog`: approximate grade-based index `0.4 × (words/sentences + 100 × complexWords/words)`; **complex** means **3+ estimated syllables** here, without dictionary-based proper-noun or inflection exclusions.
- `averageWordsPerSentence`: `wordCount / sentenceCount`.

Computed scores are rounded to three decimals. Output label `level` is a simple interpretation of **unrounded Flesch Reading Ease**, with these exact thresholds:

| Label | Flesch Reading Ease |
|---|---|
| `easy` | ≥ 70 |
| `standard` | ≥ 50 and < 70 |
| `difficult` | < 50 |
| `insufficient` | fewer than 30 recognized English words **or** fewer than 3 recognized sentences |

When insufficient, the four computed numeric metrics are `null` and the `note` describes the minimum sample requirement. The counts still appear. In particular, **a short passage will never receive a confident score or level**.

### Tiny working example

Input (`input_schema.json` includes this same text as the prefill):

```json
{
  "text": "A clear report helps readers understand the facts. Short sentences often make a message easier to follow. Writers can choose common words and explain each new idea with a simple example. These choices may help people read the report without stopping to look up every unfamiliar word."
}
```

One Dataset item (generated using the bundled `tests/run_smoke.py`):

```json
{
  "charactersAnalyzed": 283,
  "wordCount": 47,
  "sentenceCount": 4,
  "syllableCount": 74,
  "fleschReadingEase": 61.709,
  "fleschKincaidGrade": 7.571,
  "gunningFog": 8.955,
  "averageWordsPerSentence": 11.75,
  "method": "deterministic readability formulas",
  "level": "standard",
  "note": "Approximate English spelling-based scores; not a comprehension assessment."
}
```

### Method and limitations

1. Words are ASCII English letter sequences with an optional apostrophe; numbers, emoji, other writing systems, and most technical tokens are ignored. Hyphens split words.
2. Sentence boundaries are punctuation (`.`, `!`, `?`) **followed by whitespace**, or a newline. Abbreviations, headings, punctuation without spaces, and unusual formatting may be miscounted.
3. Syllables are **estimated** by counting spelling vowel groups and applying a couple of simple ending rules; irregular pronunciation, acronyms, names, dialect differences, and unfamiliar words can distort the results.
4. These formulas were developed for English prose; **do not use on non-English text or treat the grade values as measured learning outcomes**. Highly specialized vocabulary can be misrepresented.
5. Does not provide human-level reading assessment, semantic understanding, editorial judgment, or professional evaluation.
6. Text limit: 50,000 characters. Empty or wrong-type input produces a plain-language error and nonzero exit, without a traceback.

### Run locally

Requires Python 3.12+; no `pip install` required. From this Actor directory:

```bash
ACTOR_INPUT_JSON='{"text":"This is too short."}' python src/main.py
```

The short input produces an `insufficient` item. To run the full prefill and save a reproducible result, run `python tests/run_smoke.py`; the script launches **`python src/main.py` as a subprocess** using `tests/sample_input.json` as `ACTOR_INPUT_JSON`, then checks the Dataset item. Local output is stored as `storage/datasets/default/000000001.json` by default, or at `$APIFY_LOCAL_STORAGE_DIR/datasets/default` if set. Alternatively, place JSON at `storage/key_value_stores/default/INPUT.json` and call `python src/main.py`.

On Apify, when `APIFY_IS_AT_HOME` is set, the Actor fetches the run's `INPUT` record from the default key-value store through Apify's REST API, using the **platform-provided** `APIFY_TOKEN`, then appends records to the default Dataset via the REST API. No SDK or user LLM key is required. Local JSON overrides via `ACTOR_INPUT_JSON` are for development and testing.

### Store and suggested pricing (not configured)

- Store category: **AI**.
- Suggested pricing: **$0.005 per completed run**, including insufficient-text results. This is a suggestion only; no billing is configured and the Actor is not published.

### Verification

Run `python -m unittest discover -s tests -v` and `python tests/run_smoke.py` from this directory. The `tests/` folder includes tests, valid smoke input, actual terminal output, the produced Dataset JSON, and reproducibility notes. Docker builds and Apify cloud deployment are not claimed as verified.

# Actor input Schema

## `text` (type: `string`):

One English passage (maximum 50,000 characters); fewer than 30 words or 3 sentences yields an insufficient result.

## Actor input object example

```json
{
  "text": "A clear report helps readers understand the facts. Short sentences often make a message easier to follow. Writers can choose common words and explain each new idea with a simple example. These choices may help people read the report without stopping to look up every unfamiliar word."
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing the Actor's result items

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "text": "A clear report helps readers understand the facts. Short sentences often make a message easier to follow. Writers can choose common words and explain each new idea with a simple example. These choices may help people read the report without stopping to look up every unfamiliar word."
};

// Run the Actor and wait for it to finish
const run = await client.actor("eichan/english-readability-scorer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "text": "A clear report helps readers understand the facts. Short sentences often make a message easier to follow. Writers can choose common words and explain each new idea with a simple example. These choices may help people read the report without stopping to look up every unfamiliar word." }

# Run the Actor and wait for it to finish
run = client.actor("eichan/english-readability-scorer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "text": "A clear report helps readers understand the facts. Short sentences often make a message easier to follow. Writers can choose common words and explain each new idea with a simple example. These choices may help people read the report without stopping to look up every unfamiliar word."
}' |
apify call eichan/english-readability-scorer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eichan/english-readability-scorer"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/gSqHDasaRWE3FyFRE/builds/Uar14WcuIH8h06FEV/openapi.json
