{"id":21520,"library":"lexical-diversity","title":"lexical-diversity","description":"A Python library for calculating lexical diversity metrics such as TTR, HDD, MTLD, and vocd-D. Version 0.1.1 is current, with an irregular release cadence.","status":"active","version":"0.1.1","language":"python","source_language":"en","source_url":"https://github.com/kristopherkyle/lexical_diversity","tags":["lexical diversity","text analysis","readability","TTR","MTLD","HDD"],"install":[{"cmd":"pip install lexical-diversity","lang":"bash","label":"Latest release"}],"dependencies":[],"imports":[{"note":"Common alias 'ld' is recommended for brevity.","wrong":"import lexical_diversity","symbol":"lexical_diversity","correct":"import lexical_diversity as ld"}],"quickstart":{"code":"import lexical_diversity as ld\ntext = \"the cat sat on the mat another cat\"\nttr = ld.flemm_ttr(text)\nprint(ttr)","lang":"python","description":"Calculate Type-Token Ratio using Flemm's method."},"warnings":[{"fix":"Strip punctuation and lowercase text before passing to MTLD.","message":"Some functions like 'mtld' may require text preprocessing (punctuation removal). Not automatically handled.","severity":"deprecated","affected_versions":"<=0.1.1"},{"fix":"Ensure input is a string: ' '.join(tokens) if needed.","message":"Input must be a single string, not a list of tokens. Many users pass a list and get TypeError.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use ' '.join(tokens) to convert the list to a string.","cause":"Passing a list of tokens instead of a single string.","error":"TypeError: expected string or bytes-like object"},{"fix":"Convert input to string using str() or ensure you pass a proper text string.","cause":"Non-string input (e.g., integer or None).","error":"ValueError: input must be a string"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}