Firstly, load the module:
from clictagger.taggedtext import TaggedText
All clictagger operations are done on a TaggedText object, so we create one first. Text should conform to cleaning of corpora texts rules in the corpora repository.
Text can be loaded directly from a string. When printing out a summary we get a summary of the regions found in the text:
tt = TaggedText('''
Alice’s Adventures in Wonderland
Lewis Carroll
CHAPTER I. Down the Rabbit-Hole
Alice was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it, ‘and what is the use of a book,’ thought Alice ‘without pictures or
conversations?’
So she was considering in her own mind (as well as she could, for the
hot day made her feel very sleepy and stupid), whether the pleasure
of making a daisy-chain would be worth the trouble of getting up and
picking the daisies, when suddenly a White Rabbit with pink eyes ran
close by her.
'''.lstrip())
tt
characters | 675 |
---|---|
metadata.title | 1 |
metadata.author | 1 |
chapter.title | 1 |
chapter.text | 1 |
chapter.paragraph | 2 |
chapter.sentence | 2 |
quote.quote | 2 |
quote.nonquote | 3 |
quote.suspension.short | 1 |
tokens | 123 |
We can also load text from the corpora repository or directly (or any other repository if we specified the repo
parameter), by specifying a path to a ".txt" file in the repository. The tag is the version of corpora you are using. Enter the 7-character string of the latest commit on the commits page, so if the text changes in future your work will stay reproducible:
tt_corpora = TaggedText.from_github('ChiLit/alice', tag='80d00e4')
tt_corpora
characters | 144396 |
---|---|
metadata.title | 1 |
metadata.author | 1 |
chapter.title | 12 |
chapter.text | 12 |
chapter.paragraph | 804 |
chapter.sentence | 1674 |
quote.quote | 1098 |
quote.embedded | 47 |
quote.nonquote | 865 |
quote.suspension.short | 166 |
quote.suspension.long | 106 |
tokens | 26548 |
The markup()
function will reformat the tagged text into coloured output, highlighting regions that were found:
tt.markup()
We can also specify which region classes we want highlighted:
tt.markup(["quote.quote", "quote.suspension.short"])
Alternatively, the table()
function will return a table of each region tag, and it's start and end position in the text. Again we can provide a list of region classes we're interested in:
tt.table(["quote.quote", "quote.suspension.short"])
Region class | Start | End | Region value | Content |
---|---|---|---|---|
quote.quote | 300 | 332 | ‘and what is the use of a book,’ | |
quote.quote | 347 | 383 | ‘without pictures or conversations?’ | |
quote.suspension.short | 333 | 346 | thought Alice |
By providing the display parameter, we can have a CSV download link instead:
tt.table(["quote.quote", "quote.suspension.short"], display='csv-download')
Again, we can get a table of the region types we are interested in:
tt_corpora.table(["quote.embedded"])
Region class | Start | End | Region value | Content |
---|---|---|---|---|
quote.embedded | 15351 | 15374 | “How doth the little--” | |
quote.embedded | 16251 | 16273 | “Come up again, dear!” | |
quote.embedded | 16303 | 16443 | “Who am I then? Tell me that first, and then, if I like being that person, I’ll come up: if not, I’ll stay down here till I’m somebody else” | |
quote.embedded | 23759 | 24000 | “William the Conqueror, whose cause was favoured by the pope, was soon submitted to by the English, who wanted leaders, and had been of late much accustomed to usurpation and conquest. Edwin and Morcar, the earls of Mercia and Northumbria--” | |
quote.embedded | 24209 | 24362 | “Edwin and Morcar, the earls of Mercia and Northumbria, declared for him: and even Stigand, the patriotic archbishop of Canterbury, found it advisable--” | |
quote.embedded | 24701 | 24866 | “--found it advisable to go with Edgar Atheling to meet William and offer him the crown. William’s conduct at first was moderate. But the insolence of his Normans--” | |
quote.embedded | 28830 | 29059 | “Let us both go to law: I will prosecute YOU.--Come, I’ll take no denial; We must have a trial: For really this morning I’ve nothing to do.” | |
quote.embedded | 29106 | 29255 | “Such a trial, dear Sir, With no jury or judge, would be wasting our breath.” | |
quote.embedded | 29264 | 29311 | “I’ll be judge, I’ll be jury,” | |
quote.embedded | 29377 | 29521 | “I’ll try the whole cause, and condemn you to death.” | |
quote.embedded | 33844 | 33906 | “Miss Alice! Come here directly, and get ready for your walk!” | |
quote.embedded | 33907 | 33987 | “Coming in a minute, nurse! But I’ve got to see that the mouse doesn’t get out.” | |
quote.embedded | 48578 | 48609 | “HOW DOTH THE LITTLE BUSY BEE,” | |
quote.embedded | 48690 | 48720 | “YOU ARE OLD, FATHER WILLIAM,” | |
quote.embedded | 73790 | 73808 | “I see what I eat” | |
quote.embedded | 73830 | 73848 | “I eat what I see” | |
quote.embedded | 73910 | 73929 | “I like what I get” | |
quote.embedded | 73951 | 73970 | “I get what I like” | |
quote.embedded | 74069 | 74093 | “I breathe when I sleep” | |
quote.embedded | 74115 | 74139 | “I sleep when I breathe” | |
quote.embedded | 78302 | 78347 | “He’s murdering the time! Off with his head!” | |
quote.embedded | 83048 | 83068 | “much of a muchness” | |
quote.embedded | 90607 | 90621 | “What a pity!” | |
quote.embedded | 90713 | 90724 | “What for?” | |
quote.embedded | 100013 | 100071 | “Oh, ‘tis love, ‘tis love, that makes the world go round!” | |
quote.embedded | 100320 | 100390 | “Take care of the sense, and the sounds will take care of themselves.” | |
quote.embedded | 100862 | 100898 | “Birds of a feather flock together.” | |
quote.embedded | 101233 | 101289 | “The more there is of mine, the less there is of yours.” | |
quote.embedded | 101494 | 101524 | “Be what you would seem to be” | |
quote.embedded | 101563 | 101767 | “Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise.” | |
quote.embedded | 105472 | 105482 | “come on!” | |
quote.embedded | 108362 | 108398 | “French, music, AND WASHING--extra.” | |
quote.embedded | 108815 | 108830 | “Uglification,” | |
quote.embedded | 113244 | 113276 | “Will you walk a little faster?” | |
quote.embedded | 114051 | 114083 | “What matters it how far we go?” | |
quote.embedded | 116563 | 116610 | “Keep back, please: we don’t want YOU with us!” | |
quote.embedded | 116911 | 116932 | “With what porpoise?” | |
quote.embedded | 118280 | 118313 | “‘TIS THE VOICE OF THE SLUGGARD,” | |
quote.embedded | 118691 | 118743 | “You have baked me too brown, I must sugar my hair.” | |
quote.embedded | 119853 | 119878 | “I passed by his garden.” | |
quote.embedded | 121013 | 121027 | “Turtle Soup,” | |
quote.embedded | 130280 | 130381 | “There was some attempts at applause, which was immediately suppressed by the officers of the court,” | |
quote.embedded | 139239 | 139266 | “--SAID I COULD NOT SWIM--” | |
quote.embedded | 139543 | 139568 | “WE KNOW IT TO BE TRUE--” | |
quote.embedded | 139597 | 139634 | “I GAVE HER ONE, THEY GAVE HIM TWO--” | |
quote.embedded | 139711 | 139747 | “THEY ALL RETURNED FROM HIM TO YOU,” | |
quote.embedded | 139896 | 139923 | “BEFORE SHE HAD THIS FIT--” |