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
Q

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

A

sorted(set())

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

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

A

sorted(set(text3))

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

Function to calculate how many times each word is used on average

A

len() / len(set())

28
Q

Calculating how many times each word is used on average example

A

len(text3) / len(set(text3))

29
Q

Function to count how often a word occurs in a text

A

.count()

30
Q

Counting number of times a word appears example

A

text3.count(“smote”)

31
Q

Function to find what percentage of a text is taken up by a specific word

A

100 * .count() / len()

32
Q

Finding what percentage of a text is taken up by a specific word example

A

100 * text4.count(‘a’) / len(text4)

33
Q

Parameter definition

A

a placeholder for a variable which can be entered as an argument to a function

34
Q

Argument definition

A

The thing in a function which we place in the parentheses

35
Q

Function for defining a function

A

def

36
Q

List operator

A

[ ]

37
Q

Concatenation operator

A

+

38
Q

Function to add an item to a list

A

.append()

39
Q

Index operator

A

[ ]

40
Q

Index definition

A

The number in which an item in a list occurs

41
Q

Function for finding an item in a list

A

.index()

42
Q

Function for finding an item in a list example

A

text4.index(‘awaken’)

43
Q

Slicing operator

A

[ : ]

44
Q

Operator to set a variable

A

=

45
Q

Frequency distribution definition

A

Counts the frequency of each vocabulary item in a text

46
Q

Frequency distribution function

A

FreqDist()

47
Q

Function to pull up only the keys of a dictionary

A

.keys()

48
Q

Hapax definition

A

A word occurring only once in a document

49
Q

Function for viewing hapaxes

A

.hapaxes()

50
Q

“The set of all w such that w is an element of V”

A

[w for w in V]

51
Q

“Property of w”

A

P(w)

52
Q

“The set of all w such that w is an element of V and w has property P”

A

[w for w in V if p(w)]

53
Q

Function for finding all the long words in a text

A

[w for w in V if len(w) > 15]

54
Q

Function to find words that occur more than 7 times

A

[w for w in set(text5) if fdist5[w] > 7]

55
Q

Function to combine multiple words into a single string

A

.join()

56
Q

Function to combine multiple words into a single string example

A

‘ ‘.join([‘Monty’, ‘Python’])

57
Q

Function to split a string into a list

A

.split()

58
Q

Function to split a string into a list example

A

‘Monty Python’.split()

59
Q

Collocation definition

A

a sequence of words that occur together unusually often (ex. red wine)

60
Q

Function to find a sequence of words that occur together unusually often

A

.collocations()

61
Q

Bigram definition

A

word pairs that occur next to each other in a text. They may or may not occur together frequently

62
Q

Function to find word pairs that occur next to each other in a text

A

list(bigrams())

63
Q

Anaphora resolution definition

A

Identifying what a pronoun or noun phrase refers to

64
Q

Semantic role labeling definition

A

Identifying how a noun phrase relates to the verb (agent, patient, etc)

65
Q

Function to create a list with a given start and stop point

A

range()

66
Q

Three parameters for range

A

range(start, stop, step)