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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for pysurprisal-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d5b719cd2a225d573dbc903e3052b383c6634b47f6395bffdb90c387b486833 |
|
MD5 | b3c1263cd2f0915f4213b281656136b5 |
|
BLAKE2b-256 | 90e9ee5a84d21486ff2345cf9edf7481fb7710b19c71dc66f1089ec71df63bfc |