NLP / TEXTBLOB Flashcards
1
Q
mean
A
def mean(sequence): total = 0 for element in sequence: total = total + element return total / len(sequence)
2
Q
open text file
A
source = open(‘text-pride-and-prejudice.txt’)
pride = source.readlines()
source.close()
3
Q
A
print(pride[:100])
4
Q
calculate mean
/sentence mean
A
def mean(sequence): total = 0 for element in sequence: total = total + element return total / len(sequence)
def mean_line_length(sequence): total = 0 for line in sequence: total = total + len(line) return total / len(sequence)
5
Q
prose vesus verse
A
def verse_or_prose(text): if mean_line_length(text) < 57.82: return "verse" else: return "prose"
6
Q
Classification
A
Classification is the process of categorizing data into discrete sets.
7
Q
line.strip()
A
returns a string that has all leading and trailing whitespace removed.