Skip to content

Instantly share code, notes, and snippets.

View magnusnissel's full-sized avatar

Magnus Nissel magnusnissel

  • Wiesloch, Germany
View GitHub Profile
@magnusnissel
magnusnissel / lexical_diversity_yule.py
Last active October 1, 2024 08:38
Yule's K and Yule's I for lexical diversity in Python 3 (quick & dirty)
import collections
import re
def tokenize(s):
tokens = re.split(r"[^0-9A-Za-z\-'_]+", s)
return tokens
def get_yules(s):
"""
Returns a tuple with Yule's K and Yule's I.