Skip to main content

Calculate surprisal for words in text.

Project description

Surprisal

An implementation of surprisal in Python.

Installation

pip install surprisal

Usage

from pysurprisal import Surprisal

text = "..."

# calculate surprisal for each word in the text
data = Surprisal(text)
surprisals = data.calculate_surprisals()

# get the top 10 most surprising words
top_k = data.get_top_k(10)

# print dictionary of all surprisals
# key = word, value = surprisal
print(surprisals.surprisals)

Contributors

  • capjamesg

License

This project is licensed under an MIT license.

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

pysurprisal-0.1.0.tar.gz (3.6 kB view hashes)

Uploaded Source

Built Distribution

pysurprisal-0.1.0-py3-none-any.whl (3.8 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