Skip to main content

Free Spaced Repetition Scheduler

Project description

Open Spaced Repetition logo

🧠🔄 Build your own Spaced Repetition System in Python 🧠🔄


Py-FSRS is a python package that allows developers to easily create their own spaced repetition system using the Free Spaced Repetition Scheduler algorithm.


Installation

You can install the fsrs python package from PyPI using pip:

pip install fsrs

Quickstart

Import and initialize the FSRS scheduler

from fsrs import *

f = FSRS()

Create a new Card object

# all new cards are 'due' immediately upon creation
card_object = Card()

Review the card

scheduling_cards = f.repeat(card_object)

Choose a rating and update the card object

# you can choose one of the four possible ratings
"""
Rating.Again # forget; incorrect response
Rating.Hard # recall; correct response recalled with serious difficulty
Rating.Good # recall; correct response after a hesitation
Rating.Easy # recall; perfect response
"""

card_rating = Rating.Good

card_object = scheduling_cards[card_rating].card

See when the card is due next

from datetime import datetime, timezone

due = card_object.due

# how much time between when the card is due and now
time_delta = due - datetime.now(timezone.utc)

print(f"Card due: at {repr(due)}")
print(f"Card due in {time_delta.seconds} seconds")

"""
> Card due: at datetime.datetime(2024, 7, 6, 20, 6, 39, 147417, tzinfo=datetime.timezone.utc)
> Card due in: 599 seconds
"""

Reference

Card objects have one of four possible states

State.New # Never been studied
State.Learning # Been studied for the first time recently
State.Review # Graduate from learning state
State.Relearning # Forgotten in review state

There are four possible ratings when reviewing a card object:

Rating.Again # forget; incorrect response
Rating.Hard # recall; correct response recalled with serious difficulty
Rating.Good # recall; correct response after a hesitation
Rating.Easy # recall; perfect response

Get the review log for a given rating

review_log = scheduling_cards[card_rating].review_log

Get the schdeduled days after rating a card

scheduled_days = card_object.scheduled_days

License

Distributed under the MIT License. See LICENSE for more information.

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

fsrs-2.2.0.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

fsrs-2.2.0-py3-none-any.whl (7.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page