Package: buskin
BuskinBuskin is a python package for analyzing various attributes of characters in fictional texts. This was developed as part of a project for the terrificComputational Humanitiescourse at UC Berkeley. Buskin's pipeline utilizes state-of-the-art techniques in processing the text (to obtain Emotions, Characters, Character Arcs, Patient-agent-predicatives, Part-of-speech tags,etc.)We created this package to understand character arcs from various novels, but we hope it will reduce the effort to get started in analyzing fictional text for any purpose. We hope that Buskin makes it easier to peel open any novel and the characters within, in all their idiosyncrasies. Over time, we intend to add more features to the package in pursuit of that goal. Also, this is very much a work in progress. We appreciate any feedback, or contribution to the project!“Plot is no more than footprints left in the snow after your characters have run by on their way to incredible destinations.” ― Ray Bradbury, Zen in the Art of WritingContributors :nuwandavek,DmacracyUsageBuskin needs Pytorch (>=1.4) which can be installed fromhere. Once that's done, Buskin can be installed with Pip by :pip install buskinBuskin requiresspacy,torchand huggingface'stransformersamong other dependencies. So installation might take a while.Many examples can be found in theexample_notebooksdirectory.Functionsparse_bookparse_book(book_path, batch_size=None, threads=None, max_chunk_size=None, pipeline=None,  model=None, tokenizer=None)Description : Parse a fictional textParameters :book_path :str: Path to the.txtfile of the bookbatch_size :int, optional : Batch size of sentences for emotion classification (default = 8)threads :int, optional : Number of threads to be used in the processing of chunks (default = 5). The larger the number of threads, the faster the processing; but this might fill up the memory since neural coreference is memory heavymax_chunk_size :int, optional : Max size of a chunk that the text is divided into (default = 10k). The larger the chunks, the better the corefernce, but, memory is a constraint.pipeline :Spacy Pipeline, optional : This is used to process the text tokens to obtain the POS tags, etc. If not provided, a default pipeline is initialized.model :HuggingFace BertForSequenceClassification model, optional : Model used to obtain emotion for sentences. If not provided, a default model is initialized.tokenizer :HuggingFace BertTokenizer, optional : Tokenizer used for the emotion model. If not provided, a default tokenizer is initialized.Returns:Book : An instance of theBookclassload_default_modelsload_default_models()Description : Explicitly initialize the pipeline, model and tokenizer in case a batch of books are parses and you want to avoid initializing for each book.Returns :nlp :Spacy Pipeline, optional : This is used to process the text tokens to obtain the POS tags, etc.model :HuggingFace BertForSequenceClassification model, optional : Model used to obtain emotion for sentences.tokenizer :HuggingFace BertTokenizer, optional : Tokenizer used for the emotion model.ClassesBookBook(book_path=None, sentences=None, characters=None)AttributeTypeDescriptionbook_pathstrPath to the book text filesentencesList ofSentenceList of all sentences in the fictional textcharactersList ofCharacterList of all characters in the fictional textSentenceSentence(sentence_id=None, cluster_id=None,  global_token_start=None, text=None, token_tags=None, emotion_tags=None)AttributeTypeDescriptionsentence_idintID of the sentencecluster_idintID of the sentence cluster used for coreference resolutionglobal_token_startintID of the tokentextstrText in the sentencetoken_tagsList ofTokenTagsList of all tags for each token in the sentenceemotion_tagsList ofEmotionList of all emotions for each token in the sentenceCharacterCharacter(rank=None, name=None, mentions=None, agents=None, patients=None, predicatives=None)AttributeTypeDescriptionrankintRank of the character (1 = most mentioned character)namestrName of the charactermentionsList ofOccurrenceList of all occurrences of the character mentionsagentsList ofOccurrenceList of all occurrences of the character agent verbspatientsList ofOccurrenceList of all occurrences of the character patient verbspredicativesList ofOccurrenceList of all occurrences of the character predicativesTokenTagsTokenTags(token_id=None, token_global_id=None, token=None, lemma=None, pos=None, tag=None, dep=None, head_global_id=None)AttributeTypeDescriptiontoken_idintID of the tokentoken_global_idintGlobal ID of the tokentokenstrText of the tokenlemmastrLemma of the tokenposstrPart of Speech of the tokentagstrPOS Tag of the tokendepstrDependency Parse tag of the tokenhead_global_idintID of the parse-head of the tokenEmotionEmotion(emotion=None, mini_emotion=None, probability=None)AttributeTypeDescriptionemotionstrEmotion of the sentence (28 values)mini_emotionstrReduced Emotion of the sentence (3 values)probabilityfloatProbability of the emotion [0,1]OccurrenceOccurrence(text=None, sentence_id=None, cluster_id=None, start=None, end=None)AttributeTypeDescriptiontextstrText of the occurrencesentence_idintID of the sentence with the occurrencecluster_idintID of the cluster with the occurrencestartintStart token ID of the occurrenceendintEnd token ID of the occurrenceIcon made byFreepikfromwww.flaticon.com