NLP Python Flashcards

1
Q

Function for importing

A

import

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Function for opening nltk downloader

A

nltk.download()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Function for importing nltk

A

import nltk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Function for importing NLTK’s book module

A

from nltk.book import*

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Function for pulling up the name of text 1

A

text1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Function for finding every occurrence of a given word

A

.concordance()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Finding every occurrence of a given word example

A

text2.concordance(“monstrous”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Function for finding other words used in a similar range of contexts

A

.similar()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Finding other words used in a similar range of contexts example

A

text1.similar(“monstrous”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Function which examines the shared contexts of two or more words

A

.common_contexts([])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Examining the shared contexts of two or more words example

A

text2.common_contexts([“monstrous”, “very”])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Dispersion plot definition

A

A plot which shows where words occur in a text

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Dispersion plot function

A

.dispersion_plot([])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Dispersion plot example

A

text4.dispersion_plot([“citizens”, “democracy”])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Function for generating random text

A

.generate()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Generating random text example

A

text3.generate()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Function for generating real random text

A

import random

.generate(random_seed=random.random())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Real random text generator example

A

import random

text3.generate(random_seed=random.random())

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Function for counting words and symbols in a text

A

len()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Token definition

A

a sequence of characters such as hairy, his or :) that we want to treat as a group

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Function to sort a list of vocabulary items

A

sorted()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Word type definition

A

unique items of vocabulary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Function to create a list of all the unique words in a text

A

set()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Creating a list of all the unique words in a text example

A

set(text3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Function to create a sorted list of all the unique words in a text
sorted(set())
26
Creating sorted list of all the unique words in a text example
sorted(set(text3))
27
Function to calculate how many times each word is used on average
len() / len(set())
28
Calculating how many times each word is used on average example
len(text3) / len(set(text3))
29
Function to count how often a word occurs in a text
.count()
30
Counting number of times a word appears example
text3.count(“smote”)
31
Function to find what percentage of a text is taken up by a specific word
100 * .count() / len()
32
Finding what percentage of a text is taken up by a specific word example
100 * text4.count(‘a’) / len(text4)
33
Parameter definition
a placeholder for a variable which can be entered as an argument to a function
34
Argument definition
The thing in a function which we place in the parentheses
35
Function for defining a function
def
36
List operator
[ ]
37
Concatenation operator
+
38
Function to add an item to a list
.append()
39
Index operator
[ ]
40
Index definition
The number in which an item in a list occurs
41
Function for finding an item in a list
.index()
42
Function for finding an item in a list example
text4.index(‘awaken’)
43
Slicing operator
[ : ]
44
Operator to set a variable
=
45
Frequency distribution definition
Counts the frequency of each vocabulary item in a text
46
Frequency distribution function
FreqDist()
47
Function to pull up only the keys of a dictionary
.keys()
48
Hapax definition
A word occurring only once in a document
49
Function for viewing hapaxes
.hapaxes()
50
“The set of all w such that w is an element of V”
[w for w in V]
51
“Property of w”
P(w)
52
“The set of all w such that w is an element of V and w has property P”
[w for w in V if p(w)]
53
Function for finding all the long words in a text
[w for w in V if len(w) > 15]
54
Function to find words that occur more than 7 times
[w for w in set(text5) if fdist5[w] > 7]
55
Function to combine multiple words into a single string
.join()
56
Function to combine multiple words into a single string example
‘ ‘.join([‘Monty’, ‘Python’])
57
Function to split a string into a list
.split()
58
Function to split a string into a list example
‘Monty Python’.split()
59
Collocation definition
a sequence of words that occur together unusually often (ex. red wine)
60
Function to find a sequence of words that occur together unusually often
.collocations()
61
Bigram definition
word pairs that occur next to each other in a text. They may or may not occur together frequently
62
Function to find word pairs that occur next to each other in a text
list(bigrams())
63
Anaphora resolution definition
Identifying what a pronoun or noun phrase refers to
64
Semantic role labeling definition
Identifying how a noun phrase relates to the verb (agent, patient, etc)
65
Function to create a list with a given start and stop point
range()
66
Three parameters for range
range(start, stop, step)