NLTK Lexical Dispersion Plot - word offset to percentile in the x-axis

This page summarizes the projects mentioned and recommended in the original post on /r/learnpython

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • cheatsheets

    Official Matplotlib cheat sheets (by matplotlib)

  • # Natural Language Toolkit: Dispersion Plots # # Copyright (C) 2001-2022 NLTK Project # Author: Steven Bird # URL: # For license information, see LICENSE.TXT import numpy as np """ A utility for displaying lexical dispersion. """ def dispersion_plot(text, words, ignore_case=False, title="Lexical Dispersion Plot"): """ Generate a lexical dispersion plot. :param text: The source text :type text: list(str) or enum(str) :param words: The target words :type words: list of str :param ignore_case: flag to set if case should be ignored when searching text :type ignore_case: bool """ try: from matplotlib import pylab except ImportError as e: raise ValueError( "The plot function requires matplotlib to be installed." "See https://matplotlib.org/" ) from e text = list(text) words.reverse() if ignore_case: words_to_comp = list(map(str.lower, words)) text_to_comp = list(map(str.lower, text)) else: words_to_comp = words text_to_comp = text points = [ (x, y) for x in range(len(text_to_comp)) for y in range(len(words_to_comp)) if text_to_comp[x] == words_to_comp[y] ] if points: x, y = list(zip(*points)) else: x = y = () pylab.plot(x, y, "b|", scalex=0.1) pylab.yticks(list(range(len(words))), words, color="b") pylab.title(title) pylab.xlabel("Word Offset") pylab.show() if __name__ == "__main__": from nltk.corpus import gutenberg words = ["Elinor", "Marianne", "Edward", "Willoughby"] dispersion_plot(gutenberg.words("austen-sense.txt"), words

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • How to retrieve and analyze crypto order book data using Python and a cryptocurrency API

    1 project | dev.to | 27 Nov 2023
  • Matplotlib

    1 project | news.ycombinator.com | 12 Nov 2023
  • Help with an array

    2 projects | /r/learnpython | 17 Jun 2023
  • Getting visual studio code to work with imported library

    1 project | /r/learnprogramming | 26 May 2023
  • What else should I complete before applying for a data analyst role?

    2 projects | /r/learnprogramming | 5 May 2023