NLP Python Flashcards
Function for importing
import
Function for opening nltk downloader
nltk.download()
Function for importing nltk
import nltk
Function for importing NLTK’s book module
from nltk.book import*
Function for pulling up the name of text 1
text1
Function for finding every occurrence of a given word
.concordance()
Finding every occurrence of a given word example
text2.concordance(“monstrous”)
Function for finding other words used in a similar range of contexts
.similar()
Finding other words used in a similar range of contexts example
text1.similar(“monstrous”)
Function which examines the shared contexts of two or more words
.common_contexts([])
Examining the shared contexts of two or more words example
text2.common_contexts([“monstrous”, “very”])
Dispersion plot definition
A plot which shows where words occur in a text
Dispersion plot function
.dispersion_plot([])
Dispersion plot example
text4.dispersion_plot([“citizens”, “democracy”])
Function for generating random text
.generate()
Generating random text example
text3.generate()
Function for generating real random text
import random
.generate(random_seed=random.random())
Real random text generator example
import random
text3.generate(random_seed=random.random())
Function for counting words and symbols in a text
len()
Token definition
a sequence of characters such as hairy, his or :) that we want to treat as a group
Function to sort a list of vocabulary items
sorted()
Word type definition
unique items of vocabulary
Function to create a list of all the unique words in a text
set()
Creating a list of all the unique words in a text example
set(text3)
Function to create a sorted list of all the unique words in a text
sorted(set())
Creating sorted list of all the unique words in a text example
sorted(set(text3))