#basic keyword-in-contexttext3.concordance(‘begat’)
# show other than default 25 linestext1.concordance(‘sea’, lines=100)
#show other than default 25 linestext1.concordance(‘sea’, lines=100)
# show all resultstext1.concordance(‘sea’, lines=all)
# change left and right context width to 10 characters and show all resultstext1.concordance(‘sea’, 10, lines=all)
Common Contexts
1
text1.common_contexts([‘sea’,’ocean’])
Similar
A concordance permits us to see words in context. For example, we saw that monstrous occurred in contexts such as the ___ pictures and a ___ size .
What other words appear in a similar range of contexts? We can find out by appending the term similar to the name of the text in question, then inserting the relevant word in parentheses:
1
text1.similar("monstrous")
Word Location
we can also determine the location of a word in the text: how many words from the beginning it appears. This positional information can be displayed using a dispersion plot. Each stripe represents an instance of a word, and each row represents the entire text.
So Genesis has 44,764 words and punctuation symbols, or “tokens.” A tokenis the technical name for a sequence of characters — such as hairy, his, or :) — that we want to treat as a group.
Count a String
1
len(‘this is a string of text’) – number of characters
Count a list of tokens
1
len(text1) –number of tokens
Make and Count a list of unique tokens
1
len(set(text1)) – notice that setreturn a list of unique tokens
Count Occurrences
1
2
text1.count(‘heaven’) # how many times does a word occur?Frequency