<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
    <teiHeader>
        <fileDesc>
            <titleStmt>
                <title>Evaluating Hierarchical Clustering Methods for Corpora with Chronological Order</title>
                <author>
                    <persName>
                        <surname>Gambette</surname>
                        <forename>Philippe</forename>
                    </persName>
                    <affiliation>Université Gustave Eiffel; Lattice (Langues, Textes, Traitements informatiques, Cognition) - UMR 8094</affiliation>
                    <email>philippe.gambette@univ-eiffel.fr</email>
                </author>
                <author>
                    <persName>
                        <surname>Seminck</surname>
                        <forename>Olga</forename>
                    </persName>
                    <affiliation>Centre national de la recherche scientifique; Lattice (Langues, Textes, Traitements informatiques, Cognition) - UMR 8094</affiliation>
                    <email>olga.seminck@cri-paris.org</email>
                </author>
                <author>
                    <persName>
                        <surname>Legallois</surname>
                        <forename>Dominique</forename>
                    </persName>
                    <affiliation>Université Sorbonne nouvelle; Lattice (Langues, Textes, Traitements informatiques, Cognition) - UMR 8094</affiliation>
                    <email>dominique.legallois@sorbonne-nouvelle.fr</email>
                </author>
                <author>
                    <persName>
                        <surname>Poibeau</surname>
                        <forename>Thierry</forename>
                    </persName>
                    <affiliation>Centre national de la recherche scientifique; Lattice (Langues, Textes, Traitements informatiques, Cognition) - UMR 8094</affiliation>
                    <email>thierry.poibeau@ens.psl.eu</email>
                </author>
            </titleStmt>
            <editionStmt>
                <edition>
                    <date>2021-06-23T15:52:00Z</date>
                </edition>
            </editionStmt>
            <publicationStmt>
                <publisher>Elisabeth Burr, University of Leipzig</publisher>
                <address>
                    <addrLine>Beethovenstr. 15</addrLine>
                    <addrLine>04107 Leipzig</addrLine>
                    <addrLine>Germany</addrLine>
                    <addrLine>Elisabeth Burr</addrLine>
                </address>
            </publicationStmt>
            <sourceDesc>
                <p>Converted from a Word document</p>
            </sourceDesc>
        </fileDesc>
        <encodingDesc>
            <appInfo>
                <application ident="DHCONVALIDATOR" version="1.22">
                    <label>DHConvalidator</label>
                </application>
            </appInfo>
        </encodingDesc>
        <profileDesc>
            <textClass>
                <keywords scheme="ConfTool" n="category">
                    <term>Paper</term>
                </keywords>
                <keywords scheme="ConfTool" n="subcategory">
                    <term>Short Paper</term>
                </keywords>
                <keywords scheme="ConfTool" n="keywords">
                    <term>Hierarchical Clustering</term>
                    <term>Dendrogram</term>
                    <term>Algorithms</term>
                    <term>Corpus Linguistics</term>
                    <term>Style</term>
                    <term>Idiolect</term>
                </keywords>
                <keywords scheme="ConfTool" n="topics">
                    <term>Discovering</term>
                    <term>Programming</term>
                    <term>Network Analysis</term>
                    <term>Stylistic Analysis</term>
                    <term>Visualization</term>
                    <term>Modeling</term>
                    <term>Theorizing</term>
                    <term>Identifying</term>
                    <term>Commenting</term>
                    <term>Sharing</term>
                    <term>Meta: Assessing</term>
                    <term>Text</term>
                    <term>Language</term>
                    <term>Software</term>
                    <term>Methods</term>
                    <term>Metadata</term>
                    <term>Literature</term>
                    <term>not applicable</term>
                    <term>English</term>
                </keywords>
            </textClass>
        </profileDesc>
    </teiHeader>
    <text>
        <body>
            <p>The style and language of an author evolves over time, but how and to what extent? Is evolution linear or is it more erratic? In stylometry, those questions are often addressed with hierarchical clustering. Hierarchical clustering is popular in Digital Humanities to classify texts by degree of similarity. When texts can be ordered chronologically, it is often expected that texts which are closer in the chronology will also be more similar, therefore the tree obtained from hierarchical clustering is also expected to be consistent with the chronological order of texts. This hypothesis appears not only in stylometry, when studying the evolution of the style of an author, but also in Historical Linguistics, when analysing for example a collection of Old English, Middle English, and Early Modern English texts (Moisl 2020), or in discourse analysis, for example with New Year’s greetings by presidents of the French Fifth Republic (Leblanc 2016: 63, 67, 86, 87).</p>
            <p>Hierarchical clustering can traditionally be represented through a dendrogram: a rooted tree whose leaves are documents, the length of the path between two leaves representing the stylistic/linguistic distance between the documents (see Figure 1). Clusters correspond to branching nodes: the shorter the distance between two nodes, the more they are expected to share stylistic and linguistic features. Hierarchical clustering is a method that is easily accessible thanks to freely accessible implementations, with the R package Stylo (Eder et al. 2016) for example. </p>
            <p>We wonder how much the resulting dendrogram is consistent with the chronological order of writing. Indeed, this would provide us with a method of evaluating the result of the clustering. More precisely, the question we want to answer is: can the branching nodes of the dendrogram be re-ordered so that its leaves follow a chronological order as best as possible, while of course preserving the structure of the dendrogram?</p>
            <p>One needs to keep in mind that hierarchical clustering does not provide a fixed order
                on the leaves of the output dendrogram: given a binary partition of a corpus in part
                A and B, A can be represented before or after B. "Seriation" approaches have been
                introduced in the literature to find an optimal order of the leaves, based on
                various criteria (Bar-Joseph et al 2001; Chae / Chen 2011). Here, we introduce a
                more straightforward approach to evaluate, directly on the dendrogram obtained by
                hierarchical clustering, how much its topology is consistent with an ordered list of
                items (novels ordered chronologically in our case). In the ideal case, if the
                clusters below each node of the dendrogram can be reordered so that the order of the
                leaves corresponds exactly with the chronology of the novels, it means that the
                clusters displayed by the dendrogram are consistent with a chronological evolution
                of the style of an author. </p>
            <p>We thus developed methods based on two criteria to reorder the branching nodes of the dendrogram, so that the obtained order on the leaves is as close as possible to the actual chronological order.</p>
            <p>The first criterion is the minimum number of conflicts between the chronological order and the order on the leaves of the dendrogram. More precisely, we want to minimize the number of pairs of leaves which are ordered differently in the dendrogram and in the chronological ordering. The second criterion is the minimum number of leaves which have to be deleted before the dendrogram respects the chronological order. This criterion is particularly relevant if the input chronological order may contain errors.</p>
            <p>Both criteria are illustrated in Figure 1, where the dendrogram is built from a corpus of novels by Émile Zola extracted from corpus CIDRE (Seminck et al. 2021), classified using 
                <hi rend="italic">motifs</hi> (Legallois et al. 2018) and analysed with Stylo. 
            </p>
            <figure>
                <graphic n="1001" width="16.002cm" height="9.002888888888888cm" url="Pictures/d51d6cd2ab63d5db6cb7070555eafc5a.jpg" rend="inline"/>
            </figure>
            <p>Figure 1. A dendrogram built from motifs of novels by Émile Zola gathered in corpus CIDRE, where the file name starts with the first publication year (left): the vertical arrows are located next to each branching node whose left and right child should be exchanged in order to get a leaf ordering with 8 leaves to delete (10, 14, 19, 20, 21, 22, 27, 28) to get the remaining leaves in the chronological order (right), which minimizes the number of conflicts with the chronological order (each of the 30 red rectangles corresponds to a conflict between the two orders)</p>
            <p>It is also possible to evaluate in both cases whether the obtained value for each criterion is lower than what we would expect by chance (for example for small dendrograms). To this aim, we can compare with the results obtained if the input order is not the chronological order but a random order. This would correspond to a situation where no chronological signal could be captured from the dendrogram built from the clustering algorithm. Therefore, for each criterion, we can estimate a probability that the obtained value is lower than what would be expected on random data, by comparing this value with those computed on the same dendrogram and 10 000 orders picked uniformly at random.</p>
            <p>This estimation relies on fast algorithms, implemented in Python (available at 
                <ref target="https://github.com/oseminck/tree_order_evaluation">
                    https://github.com/oseminck/tree_order_evaluation
                </ref>), which run in polynomial time for both criteria on dendrograms where each branching node has a fixed maximum number of children.
            </p>
            <p>Thanks to these two evaluation algorithms, we can test whether our models of the
                evolution of the individual style of different authors (generated by the R package
                Stylo), which will be described in more details in upcoming publications, are able
                to capture the signal of a chronological evolution, and to quantify how improbable
                it is that this signal could be caused by chance. Future work will also contain a
                stage of interpretation: determining what is linguistically significant in the
                evolution of the style of an author and what may explain conflicts between the
                expected order and the observed order. </p>
            <p rend="DH-Heading2">Acknowledgements</p>
            <p>This work was funded in part by the French government under the management of the Agence Nationale de la Recherche as part of the "Investissements d’avenir" program, reference ANR-19-P3IA-0001 (PRAIRIE 3IA Institute).</p>
        </body>
        <back>
            <div type="bibliogr">
                <listBibl>
                    <head>Bibliography</head>
                    <bibl>
                        <hi rend="bold">Bar-Joseph, Ziv</hi> / <hi rend="bold">Gifford, David
                            K.</hi> / <hi rend="bold">Jaakkola, Tommi S.</hi> (2001): "Fast optimal
                        leaf ordering for hierarchical clustering", in: <hi rend="italic"
                            >Bioinformatics</hi> 17, supp. 1: S22–S29. </bibl>
                    <bibl>
                        <hi rend="bold">Chae, Minho</hi> / <hi rend="bold">Chen, James J.</hi>
                        (2011): "Reordering hierarchical tree based on bilateral symmetric
                        distance", in: <hi rend="italic">PLOS One</hi> 6, 8: e22546. </bibl>
                    <bibl>
                        <hi rend="bold">Eder, Maciej</hi> / <hi rend="bold">Rybicki, Jan</hi> / <hi
                            rend="bold">Kestemont, Mike</hi> (2016): "Stylometry with R: a package
                        for computational text analysis", in: <hi rend="italic">R Journal</hi> 8, 1:
                        107–121. </bibl>
                    <bibl>
                        <hi rend="bold">Leblanc, Jean-Marc</hi> (2016): <hi rend="italic">Analyses
                            lexicométriques des vœux présidentiels</hi>. London: ISTE editions.  </bibl>
                    <bibl>
                        <hi rend="bold">Legallois, Dominique</hi> / <hi rend="bold">Charnois,
                            Thierry</hi> / <hi rend="bold">Larjavaara, Meri</hi> (2018): "The
                        Balance Between Quantitative and Qualitative Literary Stylistics: How the
                        Method of ‘Motifs’ Can Help", in: Legallois, Dominique / Charnois, Thierry /
                        Larjavaara, Meri (eds.): <hi rend="italic">The Grammar of Genres and
                            Styles</hi>. From Discrete to Non-discrete Units. Berlin / New York: de
                        Gruyter 164–193. </bibl>
                    <bibl>
                        <hi rend="bold">Moisl, Hermann</hi> (2020): "How to visualize
                        high-dimensional data: a roadmap", in: <hi rend="italic">Journal of Data
                            Mining and Digital Humanities</hi>. Special Issue on Visualisations in
                        Historical Linguistics 1–19. </bibl>
                    <bibl>
                        <hi rend="bold">Seminck, Olga</hi> / <hi rend="bold">Gambette, Philippe</hi>
                        / <hi rend="bold">Legallois, Dominique</hi> / <hi rend="bold">Poibeau,
                            Thierry </hi> (2021): "The Corpus for Idiolectal Research (CIDRE)", in:
                            <hi rend="italic"> The Journal of Open Humanities Data (JOHD)</hi>, to
                        appear. </bibl>
                </listBibl>
            </div>
        </back>
    </text>
</TEI>
