(self, min_length = 0, text_truncation = None, novel_italics = False)
return summary, text
Used to annotate fragments for website visualization.

        Arguments:

            - min_length (int): minimum length overlap to count (default = 0)
            - text_truncation (int): tuncated text length (default = None)
            - novel_italics (bool): italicize novel words (default = True)

        Returns:

            - a tuple of strings: (summary HTML, text HTML)
def annotate(self, min_length = 0, text_truncation = None, novel_italics = False):

        """

        Used to annotate fragments for website visualization.

        Arguments:

            - min_length (int): minimum length overlap to count (default = 0)
            - text_truncation (int): tuncated text length (default = None)
            - novel_italics (bool): italicize novel words (default = True)

        Returns:

            - a tuple of strings: (summary HTML, text HTML)

        """

        start = """
            <u
            style="color: {color}; border-color: {color};"
            data-ref="{ref}" title="Length: {length}"
            >
        """.strip()

        end = """
            </u>
        """.strip()

        # Here we tokenize carefully to preserve sane-looking whitespace.
        # (This part does require text to use a SpaCy tokenization.)

        summary = self._htmltokens(self.summary)
        text = self._htmltokens(self.text)

        # Compute novel word set, if requested.

        if novel_italics:

            novel = set(self._norm_summary) - set(self._norm_text)

            for word_whitespace in summary:

                if word_whitespace[0].lower() in novel:
                    word_whitespace[0] = "<em>" + word_whitespace[0] + "</em>"

        # Truncate text, if requested.
        # Must be careful later on with this.

        if text_truncation is not None:
            text = text[:text_truncation]

        # March through overlaps, replacing tokens with HTML-tagged strings.

        colors = self._itercolors()

        for overlap in self.overlaps():

            # Skip overlaps that are too short.

            if overlap.length < min_length:
                continue

            # Reference ID for JavaScript highlighting.
            # This is random, but shared between corresponding fragments.

            ref = _random.randint(0, 1e10)
            color = next(colors)

            # Summary starting tag.

            summary[overlap.summary][0] = start.format(
                color = color,
                ref = ref,
                length = overlap.length,
            ) + summary[overlap.summary][0]

            # Text starting tag.

            text[overlap.text][0] = start.format(
                color = color,
                ref = ref,
                length = overlap.length,
            ) + text[overlap.text][0]

            # Summary ending tag.

            summary[overlap.summary + overlap.length - 1][0] += end

            # Text ending tag.

            text[overlap.text + overlap.length - 1][0] += end

        # Carefully join tokens and whitespace to reconstruct the string.

        summary = " ".join("".join("".join(tw) for tw in summary).split())
        text = " ".join("".join("".join(tw) for tw in text).split())

        # Return the tuple.

        return summary, text
def annotate ( self , min_length = 0 , text_truncation = None , novel_italics = False ) : start = """
            <u
            style="color: {color}; border-color: {color};"
            data-ref="{ref}" title="Length: {length}"
            >
        """ . strip ( ) end = """
            </u>
        """ . strip ( ) # Here we tokenize carefully to preserve sane-looking whitespace. # (This part does require text to use a SpaCy tokenization.) summary = self . _htmltokens ( self . summary ) text = self . _htmltokens ( self . text ) # Compute novel word set, if requested. if novel_italics : novel = set ( self . _norm_summary ) - set ( self . _norm_text ) for word_whitespace in summary : if word_whitespace [ 0 ] . lower ( ) in novel : word_whitespace [ 0 ] = "<em>" + word_whitespace [ 0 ] + "</em>" # Truncate text, if requested. # Must be careful later on with this. if text_truncation is not None : text = text [ : text_truncation ] # March through overlaps, replacing tokens with HTML-tagged strings. colors = self . _itercolors ( ) for overlap in self . overlaps ( ) : # Skip overlaps that are too short. if overlap . length < min_length : continue # Reference ID for JavaScript highlighting. # This is random, but shared between corresponding fragments. ref = _random . randint ( 0 , 1e10 ) color = next ( colors ) # Summary starting tag. summary [ overlap . summary ] [ 0 ] = start . format ( color = color , ref = ref , length = overlap . length , ) + summary [ overlap . summary ] [ 0 ] # Text starting tag. text [ overlap . text ] [ 0 ] = start . format ( color = color , ref = ref , length = overlap . length , ) + text [ overlap . text ] [ 0 ] # Summary ending tag. summary [ overlap . summary + overlap . length - 1 ] [ 0 ] += end # Text ending tag. text [ overlap . text + overlap . length - 1 ] [ 0 ] += end # Carefully join tokens and whitespace to reconstruct the string. summary = " " . join ( "" . join ( "" . join ( tw ) for tw in summary ) . split ( ) ) text = " " . join ( "" . join ( "" . join ( tw ) for tw in text ) . split ( ) ) # Return the tuple. return summary , text