<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>NOVEL2GRAPH: Visual Summaries of Narrative Text Enhanced by Machine Learning</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Alessandro Antonucci</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>A machine learning approach to the creation of visual summaries for narrative text is presented. Standard natural language processing tools for named entities recognition are used together with a clustering algorithm to detect the characters of the novel and their aliases. The most relevant ones and their relations are evaluated on the basis of a simple statistical analysis. These characters are visually depicted as nodes of an undirected graph whose edges describe relations with other characters. Specialized sentiment analysis techniques based on sentence embedding decide the colours of characters/nodes and their relations/edges. Additional information about the characters (e.g., gender) and their relations (e.g., siblings or partnerships) are returned by binary classi ers and visually depicted in the graph. For those specialized tasks, small amounts of manually annotated data are su cient to achieve good accuracy. Compared to analogous tools, the machine learning approach we present allows for a richer representation of texts of this kind. A case study to demonstrate this approach for a series of books is also reported.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>improve the quality of the information extracted from a narrative text, thus enhancing the readability of the
corresponding summaries. In particular we focus on the creation of visual outlines based on graphs, analogous
to what readers and specialists are often doing to understand the plot of complex novels as the one in Figure 1.</p>
      <p>Our approach to literary text analysis encompasses various NLP techniques such as named entity recognition,
syntactic parsing, semantic text analysis and NLP application tasks such as gender recognition, sentiment analysis
and social network analysis. Most of these tasks have been deeply studied in the literature and standard tools
are available for them. Yet, some tuning and adaptation to the speci c case of narrative text is required, mainly
because of the inherent nature of text content. For instance, sentiment analysis is generally intended to process
short texts such as product reviews or social networks comments. Using those tools for narrative texts can
produce inaccurate evaluations and (Section 4), as collecting dedicated training data might be problematic,
tools for semantic learning can instead give good results [HM17, KIO+16, MPGC17, NS07, NS19]. Besides
sentiment analysis, extensive textual pre-processing is needed for literary texts because of the di culty in terms
of interpretability, as experienced even by humans.</p>
      <p>Overall, we present a combination of natural language processing (NLP) and machine learning (ML), with a
particular focus on current trends of deep learning (DL), adapted to the analysis and visualization of textual
narrative data. DL approaches are used to improve natural language understanding (NLU) of text together with
specialized syntactic and semantic analyses to recognize the characters and their relations. Furthermore, for the
extraction of the character and relationship sentiments, we use the classi cation and prediction approaches based
on the universal sentence embedding (USE, [CYK+18]). USE helps in transfer learning using the transformer
architectures [VSP+17] or deep averaging networks [IMBGDI15]. Moreover, family relations between the
characters are reduced to binary classi cation tasks. The proposed method shows the strength of these techniques
to achieve a good understanding of this particular kind of texts.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Existing Work</title>
      <p>The automatic interpretation and visual analysis of literary texts has been explored in the past few years from
various perspectives. Most of the studies in this area focus on di erent methodologies to detect the characters
of a novel and identifying their relationships. One of the works focused on character detection proposes a
new approach to named entity recognition based on co-reference resolutions and based on a set of heuristic
rules integrating the Stanford CoreNLP.1[VJPR15]. A similar tool2 for e cient character annotations and alias
resolutions was proposed by [VDJ+16]. Sentiment analysis for the characters and their relations is another
focus area. Besides the Stanford CoreNLP, the approach in [FPU15] uses also the SentiWordNet ontology3 to
build character networks. In [PAHS+17], the literary characters and the network associations have been also
studied, where the features that de nes character qualities are identi ed, while in [NB13] sentiment relations
between characters in Shakespeare's plays have been processed using AFINN sentiment lexicon4. Some of the
reported studies also presented a dynamical analysis of the novels, this taking into account that the character
traits and relations varies over the pages. In [Els12], a kernel method to capture novelistic plots over time has
been considered. In [KC12] a map of the emotions over time to indicate the information ow over time was used
to predict the emotions. Gender based stereotypes in novels are studied in [Cri16] analysing the masculine and
feminine adjectives and the gender-biased portrayal of characters. The present work should be intended as one
of the rst attempts to apply the recent advances of DL in NLP in the particular area of the creation of visual
summaries for narrative text.s
3</p>
    </sec>
    <sec id="sec-3">
      <title>Methodology</title>
      <p>The algorithms we adopt to generate visual summaries of narrative text have been shaped as a single Python
software tool called NOVEL2GRAPH. The associated work ow is depicted in Figure 2. The three sections here
below describe the main NOVEL2GRAPH modules, while the very last step, i.e., the actual creation of the graph
is based on the Graphviz free software.5
1https://stanfordnlp.github.io/CoreNLP
2https://github.com/hardik-vala/charles
3https://sentiwordnet.isti.cnr.it
4https://github.com/fnielsen/afinn
5https://www.graphviz.org
The rst module of the ow handles identi cation of the characters in novel. This also involves the recognition of
aliases, as the author might refer to the same character in di erent ways. The Stanford named entity recognizer
(NER)6 is initially used to detect all the person entities. Afterwards, part-of-speech tagging is applied to lter
out the false positives returned by the NER. The basic pre-processing such as tokenisation and stopwords removal
are also applied. The so-obtained list of persons is nally processed by the DBSCAN clustering algorithm [BK07]
to group together the aliases of a same character. As a pairwise distance between the person names we use the
Ratcli -Obershelp algorithm [RM88]. A dictionary with the representative character names (corresponding to
the longest alias of each group) as keys and the aliases as values is eventually created.
This module focuses on the identi cation of (positive or negative) sentiments describing the character traits and
the relationships with other characters. Phrasal and sentence information extracted from the previous module
are processed by two di erent methods: (a) the NLTK-VADER sentiment analyser;8 (b) the Universal Sentence
Encoder (USE).9 The goal is to compare the two approaches in terms of accuracy in the classi cation of the
possibly intricate sentiments occurring in a narrative text. NLTK-VADER uses a rule-based lexicon method
built up with words annotated in terms of positive or negative sentiments. The phrasal and sentence information
is directly processed by the sentiment analyser and the corresponding sentiscores, giving positive, negative or
neutral weights to the sentiments, are recorded. The tool eventually computes the compound score (i.e., the
average of sentiscores) which de nes the sentiment. The second approach, based on DL, requires a supervised
training, and allows to formulate the problem as a classi cation task. USE helps to capture the sentence
meanings and their relations representing them as embeddings at the sentence level. For the training, we use
lists of adjectives collected online.10 Adjectives seem to be the most informative tags to reasonably describe a
character or a relationship. Similar techniques based on USE are also used for gender identi cation, for which
dedicated and su ciently large training sets are already available. In both cases, we used the Keras model with
256 dense layers and a prediction layer with softmax activation, Adam optimisation, and categorical loss entropy.
The model is trained with 10 epochs on 32 batches. Another focus is to extract the relation types, which can
describe the family links or other relations such as siblings, friends, enemies, killers. For this task we created
manually annotated data of small size, which are instead processed with classical ML algorithms and currently
we focus only on the sibling relations. s
4</p>
    </sec>
    <sec id="sec-4">
      <title>Empirical Analysis on a Case Study</title>
      <p>For a preliminary validation of our methodology, we fed NOVEL2GRAPH with the six books of the Harry Potter
series by J.K. Rowling. Due to the lack of space, in Figures 4 and 5 we depict the graphs of two books, with two
thresholds: only the most important characters of each book are depicted; only relations expressed more than
a given threshold are displayed. The size of nodes and the thickness of edges increase linearly with the number
of occurrences in the text. Red denotes negative sentiments and blue the positive ones. Relatives recognized
6https://nlp.stanford.edu/software/CRF-NER.shtml
7https://www.clips.uantwerpen.be/pages/pattern-en
8https://www.nltk.org/_modules/nltk/sentiment/vader.html
9https://tfhub.dev/google/universal-sentence-encoder/2
10https://lesn.appstate.edu/fryeem/re4030/character_trait_descriptive_adje.htm
by relation type classi ers are connected by dashed edges. A small focus group of persons who carefully read
the books was asked to decide the quality of the detected relations and sentiments and the comments have been
unanimously positive.</p>
      <p>For a quantitative evaluation, we focus on the sentiment analysis. The focus group was asked to annotate
the sentiments of the characters and the relations as positive or negative. While NLTK-VADER was originally
trained by a large data set, we train USE with a data set of only 4000 adjective conveying positive or negative
sentiments. Sentiment analysis accuracy of NLTK-VADER and USE are compared in Figure 3. The specialized
USE, outperforms the general purpose NLTK-VADER, which con rms the strength of transfer learning when
used in speci c domains such as narrative text. The combination of NLP and DL approaches seems therefore
to ease the text understanding. USE gives similar accuracies (71% on average over all the six books) for gender
analysis. As a rst test for the relationships classi cation, a simple naive Bayes classi er with bag-of-words
features and trained with a small data set of 100 manually annotated sentences was able to detect the notion of
sibling with full accuracy.</p>
      <p>100
)
t
n
e
im 80
t
n
e
S
re 60
t
c
a
r
a
h 40
C
(
y
c
ra 20
u
c
c
A
0</p>
      <p>NLTK-VADER</p>
      <p>USE
NLTK-VADER</p>
      <p>USE
100
)
t
n
e 80
m
i
t
n
e
nS 60
o
i
t
a
l
eR 40
(
y
c
a
ru 20
c
c
A</p>
      <p>0
I</p>
      <p>II</p>
      <p>III</p>
      <p>IV</p>
      <p>V</p>
      <p>VI</p>
      <p>I</p>
      <p>II</p>
      <p>III</p>
      <p>IV</p>
      <p>V</p>
      <p>VI
The present work attempted to explore and analyse the synergy of natural language processing and deep learning
for the analysis and summarization of literary texts. We see many directions to improve the techniques proposed
here. First, we need to test the tool on an extensive benchmark of novels. The dynamic evolution of those graphs,
either incrementally or by using a xed-length window over the pages, could be expressed by an animation. To
properly achieve that, the problem of a proper temporal positioning of the detected events, which are currently
described only by their position in the text, should be tackled. Regarding the character identi cation module,
deeper analysis based on co-reference resolutions and contextual analysis should be considered. Regarding the
analysis of sentiments, gender and relationships, improvements can be achieved by recognizing the roles of the
characters within the context. While semantic role labelling could be used for that by labelling triplets (subject,
predicate, object) in a better way, in narrative texts the structure of the sentence may not follow a speci c
syntactic rule. In many cases, the literary texts contain many conversations enriched with semantic usages. To
tackle the problem more e ectively, it is important that the current cutting edge deep learning approaches are
used in conjunction with the NLP techniques to achieve better text understanding.</p>
      <p>Acknowledgements
We acknowledge Arpitha Prasad Bharathi, who helped us in evaluating our results with the Harry Potter series
throughout the work, and Markus Zohner, who rst suggested us the idea of developing visual outlines of novels
by means of AI techniques.</p>
      <p>Figure 4: NOVEL2GRAPH output of the second book of the Harry Potter series</p>
      <p>Figure 5: NOVEL2GRAPH output of the fth book of the Harry Potter series
[BK07]</p>
      <p>Derya Birant and Alp Kut. ST-DBSCAN: An algorithm for clustering spatial{temporal data. Data
&amp; Knowledge Engineering, 60(1):208{221, 2007.</p>
      <p>Rebecca Cripps. The persistence of gender-based stereotypes in the language of Harry Potter and
the Philosopher's Stone and Harry Potter and the Goblet of Fire, 2016.</p>
      <p>Daniel Cer, Yinfei Yang, Sheng-yi Kong, Nan Hua, Nicole Limtiaco, Rhomni St John, Noah
Constant, Mario Guajardo-Cespedes, Steve Yuan, Chris Tar, et al. Universal sentence encoder. arXiv
preprint arXiv:1803.11175, 2018.</p>
      <p>Micha Elsner. Character-based kernels for novelistic plot structure. In Proceedings of the 13th
Conference of the European Chapter of the Association for Computational Linguistics, pages 634{
644. Association for Computational Linguistics, 2012.</p>
      <p>Matt Fernandez, Michael Peterson, and Ben Ulmer. Extracting social network from literature to
predict antagonist and protagonist. 2015.</p>
      <p>Abdalraouf Hassan and Ausif Mahmood. Deep learning approach for sentiment analysis of short
texts. In Control, Automation and Robotics (ICCAR), 2017 3rd International Conference on, pages
705{710. IEEE, 2017.
[IMBGDI15] Mohit Iyyer, Varun Manjunatha, Jordan Boyd-Graber, and Hal Daume III. Deep unordered
composition rivals syntactic methods for text classi cation. In Proceedings of the 53rd Annual Meeting
of the Association for Computational Linguistics and the 7th International Joint Conference on
Natural Language Processing, volume 1, pages 1681{1691, 2015.</p>
      <p>Tabitha Kirkland and William A Cunningham. Mapping emotions through time: How a ective
trajectories inform the language of emotion. Emotion, 12(2):268, 2012.</p>
      <p>Ankit Kumar, Ozan Irsoy, Peter Ondruska, Mohit Iyyer, James Bradbury, Ishaan Gulrajani, Victor
Zhong, Romain Paulus, and Richard Socher. Ask me anything: Dynamic memory networks for
natural language processing. In International Conference on Machine Learning, pages 1378{1387,
2016.</p>
      <p>Omer Levy, Yoav Goldberg, and Ido Dagan. Improving distributional similarity with lessons learned
from word embeddings. Transactions of the Association for Computational Linguistics, 3:211{225,
2015.</p>
      <p>Marina Mart nez Carbajal et al. Neologisms in Harry Potter books. 2014.</p>
      <p>Navonil Majumder, Soujanya Poria, Alexander Gelbukh, and Erik Cambria. Deep learning-based
document modeling for personality detection from text. IEEE Intelligent Systems, 32(2):74{79,
2017.</p>
      <p>Tomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Je Dean. Distributed
representations of words and phrases and their compositionality. In C. J. C. Burges, L. Bottou, M. Welling,
Z. Ghahramani, and K. Q. Weinberger, editors, Advances in Neural Information Processing Systems
26, pages 3111{3119. 2013.</p>
      <p>Eric T Nalisnick and Henry S Baird. Character-to-character sentiment analysis in Shakespeare's
plays. In Proceedings of the 51st Annual Meeting of the Association for Computational Linguistics,
volume 2, pages 479{483, 2013.</p>
      <p>David Nadeau and Satoshi Sekine. A survey of named entity recognition and classi cation.
Lingvisticae Investigationes, 30(1):3{26, 2007.</p>
      <p>Mohammad K. Nammous and Khalid Saeed. Natural language processing: Speaker, language,
and gender identi cation with LSTM. In Advanced Computing and Systems for Security, pages
143{156. 2019.</p>
      <p>Asa Nygren. Essay on the linguistic features in J.K. Rowling's Harry Potter and the Philosopher's
Stone, 2006.
[PAHS+17] Andrew Piper, Mark Algee-Hewitt, Koustuv Sinha, Derek Ruths, and Hardik Vala. Studying
literary characters and character networks. In DH, 2017.
[VDJ+16]
[VJPR15]
[VSP+17]</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <given-names>John W.</given-names>
            <surname>Ratcli</surname>
          </string-name>
          and
          <string-name>
            <given-names>David E.</given-names>
            <surname>Metzener</surname>
          </string-name>
          .
          <article-title>Pattern matching: The gestalt approach</article-title>
          .
          <source>Dr Dobbs Journal</source>
          ,
          <volume>13</volume>
          (
          <issue>7</issue>
          ):
          <fpage>46</fpage>
          ,
          <year>1988</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <given-names>Roger</given-names>
            <surname>Alan</surname>
          </string-name>
          <string-name>
            <surname>Stein</surname>
          </string-name>
          ,
          <article-title>Patricia A Jaques, and Jo~ao Francisco Valiati</article-title>
          .
          <article-title>An analysis of hierarchical text classi cation using word embeddings</article-title>
          .
          <source>Information Sciences</source>
          ,
          <volume>471</volume>
          :
          <fpage>216</fpage>
          {
          <fpage>232</fpage>
          ,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <given-names>Hardik</given-names>
            <surname>Vala</surname>
          </string-name>
          , Stefan Dimitrov, David Jurgens,
          <string-name>
            <given-names>Andrew</given-names>
            <surname>Piper</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Derek</given-names>
            <surname>Ruths</surname>
          </string-name>
          .
          <article-title>Annotating characters in literary corpora: A scheme, the CHARLES tool, and an annotated novel</article-title>
          .
          <source>In LREC</source>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <given-names>Hardik</given-names>
            <surname>Vala</surname>
          </string-name>
          , David Jurgens,
          <string-name>
            <given-names>Andrew</given-names>
            <surname>Piper</surname>
          </string-name>
          , and
          <string-name>
            <given-names>Derek</given-names>
            <surname>Ruths</surname>
          </string-name>
          . Mr.
          <article-title>Bennet, his coachman, and the archbishop walk into a bar but only one of them gets recognized: On the di culty of detecting characters in literary texts</article-title>
          .
          <source>In Proceedings of the 2015 Conference on Empirical Methods in Natural Language Processing</source>
          , pages
          <volume>769</volume>
          {
          <fpage>774</fpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <given-names>Ashish</given-names>
            <surname>Vaswani</surname>
          </string-name>
          , Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez,
          <string-name>
            <surname>Lukasz Kaiser</surname>
            , and
            <given-names>Illia</given-names>
          </string-name>
          <string-name>
            <surname>Polosukhin</surname>
          </string-name>
          .
          <article-title>Attention is all you need</article-title>
          .
          <source>In Advances in Neural Information Processing Systems</source>
          , pages
          <fpage>5998</fpage>
          {
          <fpage>6008</fpage>
          ,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <surname>[WBGL15] John Wieting</surname>
            , Mohit Bansal, Kevin Gimpel, and
            <given-names>Karen</given-names>
          </string-name>
          <string-name>
            <surname>Livescu</surname>
          </string-name>
          .
          <article-title>Towards universal paraphrastic sentence embeddings</article-title>
          .
          <source>arXiv preprint arXiv:1511.08198</source>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>