edits-0.1.0.1: show the differences between 2 pieces of Text using the Levenshtein distance
Safe HaskellSafe-Inferred
LanguageGHC2021

Data.Text.Shorten

Contents

Description

This module provides functions to shorten a piece of text where parts of the text are delimited to highlight the difference with another piece of text Then only the parts outside the difference are being shortened

Synopsis

Documentation

data ShortenOptions Source #

Size used to decide if a piece of text needs to be shortened

Constructors

ShortenOptions 

Instances

Instances details
Show ShortenOptions Source # 
Instance details

Defined in Data.Text.Shorten

Eq ShortenOptions Source # 
Instance details

Defined in Data.Text.Shorten

half :: ShortenOptions -> ShortenOptions Source #

Cut the shorten size in 2

shortenTokens :: ShortenOptions -> Token -> Token -> [Token] -> [Token] Source #

Shorten a piece of text that has already been tokenized

splitOnDelimiters :: Token -> Token -> [Token] -> [[Token]] Source #

Split a list of tokens into several lists when a delimiter is found abcd[efgh]ijkl[mnop]qrst -> [abcd, [efgh], ijkl, [mnop], qrst]

shortenLeft :: ShortenOptions -> [Token] -> [Token] Source #

Shorten some token on the left: ...tokens

shortenRight :: ShortenOptions -> [Token] -> [Token] Source #

Shorten some token on the right: tokens...

shortenCenter :: ShortenOptions -> [Token] -> [Token] Source #

Shorten some token in the center: ...tokens...

whenTooLong :: ShortenOptions -> [Token] -> [Token] -> [Token] Source #

Depending on the shorten option and the original list of tokens used a shorter version

Helpers

updateLast :: [a] -> (a -> a) -> [a] Source #

Update the last element of a list