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 details)

Uploaded Source

Built Distribution

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

pysurprisal-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pysurprisal-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for pysurprisal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 11b83f0aab855cf2fd676a2283107f6016a1507bea952a52adc389c42597c425
MD5 d3e049da55183468e9f4e7a919ba6cd0
BLAKE2b-256 44afc78c9a4378efb442c1261fef6c981de15de1199de64b0a0cce7af3fb1673

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysurprisal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for pysurprisal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d5b719cd2a225d573dbc903e3052b383c6634b47f6395bffdb90c387b486833
MD5 b3c1263cd2f0915f4213b281656136b5
BLAKE2b-256 90e9ee5a84d21486ff2345cf9edf7481fb7710b19c71dc66f1089ec71df63bfc

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