Extractive Sentence Ranker avatar

Extractive Sentence Ranker

Pricing

$0.01 / actor start

Go to Apify Store
Extractive Sentence Ranker

Extractive Sentence Ranker

Pricing

$0.01 / actor start

Rating

0.0

(0)

Developer

Eichan Jolly

Eichan Jolly

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

4 days ago

Last modified

Categories

Features

Limited permissions

Share

One job: Score and rank existing sentences from user-supplied text. It never generates, paraphrases, checks, or rewrites a sentence. This is a local text-frequency heuristic, not an LLM-based summary or human-level assessment of importance.

Who it is for

Developers prototyping extractive text previews, content triage, sentence-selection steps in retrieval pipelines, or educational readability workflows. It uses only the Python standard library. No Apify SDK, external LLM, login, or user-supplied API key is required.

How it works (plain words)

  1. Split the supplied text at end punctuation followed by whitespace, at newlines, and after Japanese full stops. This is a simple sentence splitter, not a grammar parser.
  2. Extract runs of Unicode letters and remove a fixed list of common English words and tokens shorter than three letters.
  3. Count each remaining word throughout the input. In each sentence, calculate the average of its word frequencies divided by the most frequent word's frequency.
  4. Apply a mild penalty for sentences with fewer than four retained tokens: multiply by min(retained_word_count / 4, 1).
  5. Rank by descending unrounded score, breaking ties by original sentence position. Output the topN original sentences (or fewer if fewer can be scored).

The emitted score is a heuristic weight between 0 and 1, not a probability, factual-quality grade, or summary confidence score. This ranking tends to reward words repeated elsewhere in the input; repeated boilerplate can skew it.

Input

FieldTypeDefaultConstraints
textstringrequiredNonempty, max 100,000 characters
topNinteger31–20; fewer items when fewer scoreable sentences

Tiny example (one short text):

{
"text": "Solar panels produce electricity. Solar energy powers homes. Wind turbines produce electricity.",
"topN": 2
}

The prefilled UI provides only one short text. There are no URLs, data extraction, or generated answers.

Output (Dataset items)

For the example above, the Actor appends two rows. The actual first item from a python src/main.py smoke run is:

{
"rank": 1,
"sentence": "Solar panels produce electricity.",
"score": 0.875,
"sentence_index": 1,
"word_count": 4
}

Every row has the same five fields: output rank starts at 1, sentence is copied from the input with internal whitespace collapsed, score is the heuristic weight, sentence_index is the original 1-based sentence position, and word_count counts words before stopword filtering. See verification/dataset_items.json for both actual example rows.

Limits and honesty

  • Extractive only: cannot invent coherent connecting text or produce a rewritten, factual, or human-quality summary. Higher-scored sentences are not necessarily important, complete, trustworthy, or representative.
  • Scoring is based on repeated words, not meaning or context. There is no semantic similarity, translation, entity recognition, bias correction, or fact checking.
  • The English stopword list is fixed. Non-English text and languages without spaces may give unreliable results.
  • Abbreviations (e.g. Dr.), decimal points, ellipses, quotations, and punctuation without whitespace may split incorrectly or remain together. HTML/Markdown is not parsed.
  • A sentence with no retained content tokens cannot score and is skipped. If the entire input has no scoreable tokens, the run ends with a readable error. A maximum of 2,000 detected sentences is accepted.
  • Scores are rounded to six decimal places for display; ties are decided using unrounded scores and original sentence order. No network or external LLM is used for the ranking.

Running locally

Requires Python 3.12+, without pip install:

cd extractive-sentence-ranker
mkdir -p storage/key_value_stores/default
cp verification/sample_input.json storage/key_value_stores/default/INPUT.json
python src/main.py

Output appears under storage/datasets/default/000000001.json and increments for additional items. Alternatively, set ACTOR_INPUT_JSON to a JSON object. The local storage root can be changed with APIFY_LOCAL_STORAGE_DIR. Errors appear as plain Error: ... messages on standard error, without tracebacks.

On Apify cloud, the Actor reads its input and saves its Dataset rows through the Apify REST API using the Apify-provided run storage IDs and runtime APIFY_TOKEN. Users do not supply credentials or LLM keys; the Apify SDK is not used.

Verification (included with this Actor)

$python -m unittest discover -s tests -v

tests/test_main.py runs the real python src/main.py script with both local INPUT.json and ACTOR_INPUT_JSON, checks error messages, and uses a local HTTP stub to test the cloud storage call pattern. verification/smoke_terminal.txt, verification/sample_input.json, and verification/dataset_items.json contain evidence from the script-mode smoke run. The exact smoke invocation was:

mkdir -p verification/smoke_storage/key_value_stores/default
cp verification/sample_input.json verification/smoke_storage/key_value_stores/default/INPUT.json
APIFY_LOCAL_STORAGE_DIR=verification/smoke_storage python src/main.py

Running again appends local Dataset items. The if __name__ == "__main__": block is the final statement in src/main.py.

Store categorization and pricing proposal

  • Intended Apify Store category: AI (1 category; positioned as a deterministic text-preparation utility, not a chatbot). Store classification is controlled by the available Apify publishing interface.
  • Suggested billing model: Pay-per-event, one successful processing run (up to 20 returned sentences) rather than per sentence. This makes a short extract predictable to price.
  • Current state: No pay events, pricing setup, or publication is included or enabled.