Skip to main content

Keystroke Revision Extraction and Visualisation library

Project description

K-REV

Keystroke Revision Tracking and Extraction

PyPI version License: Python Versions Build


Overview

K-Rev is a Python library for detecting and analyzing revision episodes in streams of keystroke data.
It helps researchers and developers understand how writers revise their text — identifying bursts of deletion, retyping, or restructuring that reveal cognitive and editing processes during writing.

Whether you are studying writing behavior, building educational tools, or visualizing editing timelines, K-Rev makes keystroke-based revision analysis simple, reproducible, and extensible.


Features

  • Automatic detection of revision episodes from raw keystroke logs
  • Flexible data model for representing typing, pauses, and edits
  • Analytics and visualization utilities (coming soon)
  • Extensible architecture — plug in your own revision classifiers
  • Compatible with common keystroke formats (e.g., InputLog, ScriptLog, or custom JSON)

Installation

pip install kretrace

Quickstart

Once you extracted you keystroke data, create a list that represents the text after each keystroke and a list that keeps the cursor position after each keystroke. Example:

    text_list = [
        "The quick brown fox",
        "The quick brown fox ",
        "The quick brown fox j",
        "The quick brown fox ju",
        "The quick brown fox jum",
        "The quick brown fox jumps",
        "The quick brown fox jumps ",
        "The quick brown fox jumps o",
        "The quick brown fox jumps ov",
        "The quick brown fox jumps ove",
        "The quick brown fox jumps over",
        "The quick brown fo jumps over",
        "The quick brown f jumps over",
        "The quick brown  jumps over",
        "The quick brown c jumps over",
        "The quick brown ca jumps over",
        "The quick brown cat jumps over",
        "The quick brown cat jumps over ",
        "The quick brown cat jumps over t",
        "The quick brown cat jumps over th",
        "The quick brown cat jumps over the",
        "The quick brown cat jumps over the ",
        "The quick brown cat jumps over the d",
        "The quick brown cat jumps over the do",
        "The quick brown cat jumps over the dog",
    ]
    cursor_list = [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 18, 17, 16, 17, 18, 19, 31, 32, 33, 34, 35, 36, 37, 38]

Then we can extract the revision events from the keystroke data.

>>> from krev.main import characterize_revisions
>>> revisions = characterize_revisions(text_list, cursor_list)

If you are working with french text, you can also already use our pipeline to classify the revision event through requesting an LLM. In order to do so, you must precise the model you want to use and an API key. You should be aware of the tokens that might be used by doing such a request. Prompts are available in the open-source code of the library.

>>> from krev.main import characterize_revisions
>>> revisions = characterize_revisions(text_list, cursor_list, "gpt-5", api_key=API-KEY)

Finally you can go through the list of revisions to observe the text before/after the revision, the revision type, where it appends in the text...

>>> for revision in revisions:
... print(revision.text_before, revision.text_end, revision.reason_start, revision.start_point, revision.type)

How it works


Next steps

Taking into account trailing text. For now, the presence of trailing text might cause problems to the revision extraction procedure. Multi-lingual pipeline for revision classification (only in French for now, but revision extraction works for any Indo-European language). Replace the API use of LLMs to classify the revision by smaller models.


License

K-Rev operates under an ASL License, and is a property of EvidenceB. It is open source for research purpose, but not open for commercial use. If you would like to use this library for a commercial purpose, please contact the owners of this repository. See the License file for further details.


Citation


Acknowledgements

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

krev-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

krev-0.1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file krev-0.1.0.tar.gz.

File metadata

  • Download URL: krev-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for krev-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9ac4873b97e3c5a851218b09cdb4239f08e9301fd288115cf74fc20b7b8dec93
MD5 7a16fcda64bc7cab5d41b2973a5cdee9
BLAKE2b-256 b178107996c445779b05851cd01971ad7dea630631f31a82c8be4f141b4f8149

See more details on using hashes here.

File details

Details for the file krev-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: krev-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.9

File hashes

Hashes for krev-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ccf1976fd8647785ed0cc63188d9643a5e511459b6f0a06ac829cb6c87e2a9a3
MD5 431407fcb4b820372593801417bc91b5
BLAKE2b-256 1aac087fa2cd4fea05e87567d858aa69da63930326e9478eab74f9a725fdecb6

See more details on using hashes here.

Supported by

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